Merge branch 'master_test_gn' of http://60.1.1.230/backend/jieling_server into master_test_gn

back_recharge
jiahuiwen 2021-10-14 19:38:11 +08:00
commit 09591d21e0
4 changed files with 137 additions and 16 deletions

View File

@ -3,13 +3,52 @@ package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.logic.dao.root.User;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public class ItemManager extends MongoBase {
private Map<Integer, Item> itemMap = new ConcurrentHashMap<>();
///兼容线上数据,计算统计装备(为了做白金装备图鉴,需要初始化统计一次用户身上所有装备)true:已经计算过了 false未计算
private boolean isAbsEquip;
public boolean getIsAbsEquip() {
return isAbsEquip;
}
public void setAbsEquip(boolean absEquip) {
isAbsEquip = absEquip;
updateString("isAbsEquip", isAbsEquip);
}
private Map<Integer, Long> equipBookMap = new HashMap<>();
public Map<Integer, Long> getEquipBookMap() {
return equipBookMap;
}
public void setEquipBookMap(int equipId,long addNum) {
long _num=addNum;
if (this.equipBookMap.containsKey(equipId)){
_num+=this.equipBookMap.get(equipId);
}
this.equipBookMap.put(equipId,_num);
updateString("equipBookMap." + equipId, _num);
}
private Set<Integer> equipBookEnabled = new HashSet<>();
public Set<Integer> getEquipBookEnabled() {
return equipBookEnabled;
}
public void addEquipBookEnabled(int bookId) {
this.equipBookEnabled.add(bookId);
updateString("equipBookEnabled", equipBookEnabled);
}
public ItemManager() {
this.setRootCollection(User._COLLECTION_NAME);

View File

@ -2273,7 +2273,9 @@ public class HeroLogic{
if (!bookEnabled.isEmpty()){
Map<Integer, SSpiritAnimalBook> config = STableManager.getConfig(SSpiritAnimalBook.class);
for(int bootId:bookEnabled){
int[][] activePara = config.get(bootId).getActivePara();
SSpiritAnimalBook animalBook=config.get(bootId);
if (animalBook==null)continue;
int[][] activePara = animalBook.getActivePara();
combinedAttribute(activePara,heroAllAttribute);
}
}
@ -2317,6 +2319,9 @@ public class HeroLogic{
//魂印图鉴加成
Set<Integer> equipBookEnabled = equipManager.getEquipBookEnabled();
bonuses(equipBookEnabled,heroAllAttribute);
//白金装备加成
Set<Integer> whiteBookEnabled = user.getItemManager().getEquipBookEnabled();
bonuses(whiteBookEnabled,heroAllAttribute);
//英雄皮肤加成 记得判断皮肤过期
int skin = hero.getSkin();
if(skin!=0){
@ -3888,9 +3893,33 @@ public class HeroLogic{
for (int enabled:user.getEquipManager().getEquipBookEnabled()){
builder.addAllBookEnabled(enabled);
}
//添加白金装备羁绊
for (Integer enabled : user.getItemManager().getEquipBookEnabled()) {
builder.addAllBookEnabled(enabled);
}
for (Integer equip:equipManager.getEquipList()) {
builder.addEquipGot(equip);
}
if (!user.getItemManager().getIsAbsEquip()) {
for (Map.Entry<Integer, Item> equipEntry : user.getItemManager().getItemMap().entrySet()) {
if (SItem.getsItemMap().get(equipEntry.getKey()).getItemType()==3) {
user.getItemManager().setEquipBookMap(equipEntry.getValue().getItemId(),equipEntry.getValue().getItemNum());
}
}
for (Map.Entry<String, Hero> stringHeroEntry : user.getHeroManager().getHeroMap().entrySet()) {
for (Map.Entry<Integer, Integer> entry : stringHeroEntry.getValue().getEquipByPositionMap().entrySet()) {
user.getItemManager().setEquipBookMap(entry.getValue(),1);
}
}
user.getItemManager().setAbsEquip(true);
}
for (Map.Entry<Integer, Long> entry : user.getItemManager().getEquipBookMap().entrySet()) {
CommonProto.EquipBookInfo equipBook=CommonProto.EquipBookInfo.newBuilder()
.setEquipId(entry.getKey())
.setNum(entry.getValue().intValue())
.build();
builder.addEquipList(equipBook);
}
MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.GET_ALL_PROPERTY_INFO_RESPONSE_VALUE,builder.build(),true);
}
@ -3911,7 +3940,7 @@ public class HeroLogic{
if(user.getPlayerInfoManager().getLevel()<bookConfig.getOpenLevel()){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
int[] teamers = bookConfig.getTeamers();
int[][] teamers = bookConfig.getTeamers();
int[][] reward = bookConfig.getReward();
CommonProto.Drop.Builder drop = null;
//神将激活
@ -3929,9 +3958,8 @@ public class HeroLogic{
}
}
//判断羁绊神将是否在集合
for(int tmp:teamers){
if(!hero.contains(tmp)){
System.out.println(tmp);
for(int[]tmp:teamers){
if(!hero.contains(tmp[0])){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
}
@ -3946,8 +3974,8 @@ public class HeroLogic{
if(equipManager.getEquipBookEnabled().contains(bookId)){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
for (int equip:teamers){
if (!equipManager.getEquipList().contains(equip)){
for (int[]equip:teamers){
if (!equipManager.getEquipList().contains(equip[0])){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
}
@ -3961,14 +3989,29 @@ public class HeroLogic{
if(pokemonManager.getPokemonBookEnabled().contains(bookId)){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
for(int pokemon:teamers){
if(!pokemonManager.getPokemonGot().contains(pokemon)){
for(int[]pokemon:teamers){
if(!pokemonManager.getPokemonGot().contains(pokemon[0])){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
}
pokemonManager.addPokemonBookEnabled(bookId);
drop = ItemUtil.drop(user,reward , BIReason.ACTIVATION_HERO_FETTER);
}
//白金装备激活
if(bookConfig.getFetterType()==4){
ItemManager itemManager = user.getItemManager();
if(itemManager.getEquipBookEnabled().contains(bookId)){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
for(int[]pokemon:teamers){
if(!itemManager.getEquipBookMap().containsKey(pokemon[0])||itemManager.getEquipBookMap().get(pokemon[0])<pokemon[1]){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
}
itemManager.addEquipBookEnabled(bookId);
drop = ItemUtil.drop(user,reward , BIReason.ACTIVATION_HERO_FETTER);
}
PlayerInfoProto.UseAndPriceItemResponse.Builder useAndPriceItemResponse = PlayerInfoProto.UseAndPriceItemResponse.newBuilder();
if (drop != null) {
useAndPriceItemResponse.setDrop(drop);

View File

@ -33,6 +33,7 @@ import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
import com.ljsd.jieling.logic.store.newRechargeInfo.PushRechargeType;
import com.ljsd.jieling.network.session.ISession;
import rpc.protocols.CommonProto;
import rpc.protocols.HeroInfoProto;
import rpc.protocols.MessageTypeProto;
import rpc.protocols.PlayerInfoProto;
import config.SGameSetting;
@ -598,12 +599,19 @@ public class ItemUtil {
List<CommonProto.Item> sendToFront = new CopyOnWriteArrayList<>();
//超过上限不能直接获得
Map<Integer,Integer> extraItem = new HashMap<>(itemMap.size());
List<Integer>changeEquipList=null;
for (Map.Entry<Integer, Long> entry : itemMap.entrySet()) {
SItem sItem = SItem.getsItemMap().get (entry.getKey());
if (sItem.getItemBaseType()==6){
equipManager.addEquipList(entry.getKey());
}
if (sItem.getItemType()==3){
if (changeEquipList==null) {
changeEquipList=new ArrayList<>();
}
itemManager.setEquipBookMap(entry.getKey(),entry.getValue());
changeEquipList.add(entry.getKey());
}
long itemNumlimit = sItem.getItemNumlimit();
long itemNum = entry.getValue().intValue();
if(itemNum <= 0){
@ -680,6 +688,9 @@ public class ItemUtil {
//日志记录
ItemLogic.getInstance().addItemLog(new ItemLog(user.getId(),0,user.getPlayerInfoManager().getLevel(),String.valueOf(TimeUtils.now()),reason,sItem.getId(),itemNum,item.getItemNum()));
}
//发送装备图鉴修改推送
SendEquipBookIndication(user.getId(),itemManager,changeEquipList);
for(Map.Entry<Integer,Integer> entry:extraItem.entrySet()){
itemProtoList.add(CBean2Proto.getItem(itemManager.getItemMap().get(entry.getKey()),entry.getValue()));
}
@ -720,12 +731,19 @@ public class ItemUtil {
List<CommonProto.Item> sendToFront = new CopyOnWriteArrayList<>();
//超过上限不能直接获得
Map<Integer,Integer> extraItem = new HashMap<>(itemMap.size());
List<Integer>changeEquipList=null;
for (Map.Entry<Integer, Long> entry : itemMap.entrySet()) {
SItem sItem = SItem.getsItemMap().get (entry.getKey());
if (sItem.getItemBaseType()==6){
equipManager.addEquipList(entry.getKey());
}
if (sItem.getItemType()==3){
if (changeEquipList==null) {
changeEquipList=new ArrayList<>();
}
itemManager.setEquipBookMap(entry.getKey(),entry.getValue());
changeEquipList.add(entry.getKey());
}
long itemNumlimit = sItem.getItemNumlimit();
long itemNum = entry.getValue().intValue();
@ -803,6 +821,10 @@ public class ItemUtil {
//日志记录
ItemLogic.getInstance().addItemLog(new ItemLog(user.getId(),0,user.getPlayerInfoManager().getLevel(),String.valueOf(TimeUtils.now()),reason,sItem.getId(),itemNum,item.getItemNum()));
}
//发送装备图鉴修改推送
SendEquipBookIndication(user.getId(),itemManager,changeEquipList);
for(Map.Entry<Integer,Integer> entry:extraItem.entrySet()){
itemProtoList.add(CBean2Proto.getItem(itemManager.getItemMap().get(entry.getKey()),entry.getValue()));
}
@ -826,8 +848,25 @@ public class ItemUtil {
return 1;
}
///发送装备图鉴修改推送
private static void SendEquipBookIndication(int _uid,ItemManager _itemManage, List<Integer>_equipList){
if (_equipList==null||_equipList.isEmpty())return;
List<CommonProto.EquipBookInfo>equipList=new ArrayList<>();
for (Integer integer : _equipList) {
if (_itemManage.getEquipBookMap().containsKey(integer)) {
CommonProto.EquipBookInfo equipInfo=CommonProto.EquipBookInfo.newBuilder()
.setEquipId(integer)
.setNum(_itemManage.getEquipBookMap().get(integer).intValue())
.build();
equipList.add(equipInfo);
}
}
HeroInfoProto.EquipBookIndication build=HeroInfoProto.EquipBookIndication.newBuilder()
.addAllChangeEquipList(equipList)
.build();
ISession sessionByUid = OnlineUserManager.getSessionByUid(_uid);
MessageUtil.sendIndicationMessage(sessionByUid,1, MessageTypeProto.MessageType.EQUIP_BOOK_INDICATION_VALUE,build,true);
}
/**
* //zsx 保留 TODO 由事件分发到 playlogic 去处理

View File

@ -10,7 +10,7 @@ public class SSpiritAnimalBook implements BaseConfig {
private int id;
private int[] teamers;
private int[][] teamers;
private int[][] activePara;
@ -33,7 +33,7 @@ public class SSpiritAnimalBook implements BaseConfig {
return id;
}
public int[] getTeamers() {
public int[][] getTeamers() {
return teamers;
}