英雄置换

back_recharge
zhangshanxue 2020-08-12 14:16:08 +08:00
parent efc21ecbf3
commit 4e0dd14dce
6 changed files with 51 additions and 23 deletions

View File

@ -24,11 +24,21 @@ public abstract class MongoBase implements Serializable {
} }
public void updateString(String fieldName, Object value) { public void updateString(String fieldName, Object value) {
if(null == value){
if("".equals(mongoKey)){
MongoUpdateCacheThreadLocal.removeRequest(this, fieldName);
}else{
MongoUpdateCacheThreadLocal.removeRequest(this, mongoKey + "." + fieldName);
}
}else {
if("".equals(mongoKey)){ if("".equals(mongoKey)){
MongoUpdateCacheThreadLocal.addUpdateRequest(this, fieldName, value); MongoUpdateCacheThreadLocal.addUpdateRequest(this, fieldName, value);
}else{ }else{
MongoUpdateCacheThreadLocal.addUpdateRequest(this, mongoKey + "." + fieldName, value); MongoUpdateCacheThreadLocal.addUpdateRequest(this, mongoKey + "." + fieldName, value);
} }
}
} }

View File

@ -8,10 +8,12 @@ import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.Hero; import com.ljsd.jieling.logic.dao.Hero;
import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.protocols.CommonProto; import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.HeroInfoProto; import com.ljsd.jieling.protocols.HeroInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.ItemUtil; import com.ljsd.jieling.util.ItemUtil;
import config.SCHero; import config.SCHero;
import config.SSpecialConfig; import config.SSpecialConfig;
@ -48,9 +50,9 @@ public class DoHeroChangeRequestHandler extends BaseHandler<HeroInfoProto.DoHer
throw new ErrorCodeException(ErrorCode.CFG_NULL); throw new ErrorCodeException(ErrorCode.CFG_NULL);
} }
int[][] ints = new int[1][2]; // int[][] ints = new int[1][2];
ints[0][0]=hero.getChangeId(); // ints[0][0]=hero.getChangeId();
ints[0][1]= 1; // ints[0][1]= 1;
//check in team //check in team
int[] teamId = SSpecialConfig.getOnceArrayValue(SSpecialConfig.HERO_RESOLVE_LICENCE); int[] teamId = SSpecialConfig.getOnceArrayValue(SSpecialConfig.HERO_RESOLVE_LICENCE);
@ -59,9 +61,13 @@ public class DoHeroChangeRequestHandler extends BaseHandler<HeroInfoProto.DoHer
throw new ErrorCodeException(ErrorCode.ITEM_DECOMPOSE_HERO_TEAM); throw new ErrorCodeException(ErrorCode.ITEM_DECOMPOSE_HERO_TEAM);
} }
user.getHeroManager().removeHero(uid,hero.getId());
CommonProto.Drop.Builder drop = ItemUtil.dropPer(user, ints, BIReason.HERO_CHANGE); CommonProto.Drop.Builder drop = CommonProto.Drop.newBuilder();
//random tempid
Hero newHero = new Hero(uid,hero.getChangeId(),hero.getStar(),hero);
user.getHeroManager().addHero(newHero);
drop.addHero(CBean2Proto.getHero(newHero));
return HeroInfoProto.DoHeroChangeResponse.newBuilder().setDrop(drop).build(); return HeroInfoProto.DoHeroChangeResponse.newBuilder().setDrop(drop).build();
} }
} }

View File

@ -91,7 +91,10 @@ public class SaveHeroChangeRequestHandler extends BaseHandler<HeroInfoProto.Save
//random Hero //random Hero
int result =hero.getTemplateId();
int j=0;
while (j<1000&&result==hero.getTemplateId()){
j++;
//所有获得物品 //所有获得物品
int[][] resultRandom = new int[perCount][]; int[][] resultRandom = new int[perCount][];
//进行抽取 //进行抽取
@ -100,13 +103,16 @@ public class SaveHeroChangeRequestHandler extends BaseHandler<HeroInfoProto.Save
SLotteryRewardConfig sLotteryRewardConfig = STableManager.getConfig(SLotteryRewardConfig.class).get(rewardId); SLotteryRewardConfig sLotteryRewardConfig = STableManager.getConfig(SLotteryRewardConfig.class).get(rewardId);
resultRandom[i] =sLotteryRewardConfig.getReward(); resultRandom[i] =sLotteryRewardConfig.getReward();
} }
result = resultRandom[0][0];
int result = resultRandom[0][0];
if(result==0){
LOGGER.error("随机失败");
throw new ErrorCodeException(ErrorCode.CFG_NULL);
} }
if(result==0){
System.out.println("j = " + j+"result = " + result+"hero = " + hero.getTemplateId());
LOGGER.error("随机失败"+j);
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
System.out.println("j = " + j+"result = " + result+"hero = " + hero.getTemplateId());
hero.getTemplateId();
hero.setChangeId(result); hero.setChangeId(result);
return HeroInfoProto.SaveHeroChangeResponse.newBuilder().setHeroTempId(result).build(); return HeroInfoProto.SaveHeroChangeResponse.newBuilder().setHeroTempId(result).build();

View File

@ -189,7 +189,13 @@ public class Hero extends MongoBase {
public Map<Integer, Integer> getSoulEquipByPositionMap() { public Map<Integer, Integer> getSoulEquipByPositionMap() {
return soulEquipByPositionMap==null?new HashMap<>():soulEquipByPositionMap; if(soulEquipByPositionMap == null){
Map<Integer,Integer> map = new HashMap<>();
updateString("soulEquipByPositionMap" ,map);
return map;
}else {
return soulEquipByPositionMap;
}
} }
public void updateSoulEquipPositionMap(int position,int equipId) { public void updateSoulEquipPositionMap(int position,int equipId) {

View File

@ -2615,7 +2615,7 @@ public class HeroLogic{
} }
Map<Integer,Integer> returnItems = new HashMap<>(); Map<Integer,Integer> returnItems = new HashMap<>();
equipIdsList.forEach(e->{ equipIdsList.forEach(e->{
soulEquipByPositionMap.remove(e.getPosition()); hero.removeSoulEquip(e.getPosition());
returnItems.put(e.getEquipId(),1); returnItems.put(e.getEquipId(),1);
}); });
ItemUtil.dropMap(user,returnItems,BIReason.UNLOAD_SOUL_REWARD); ItemUtil.dropMap(user,returnItems,BIReason.UNLOAD_SOUL_REWARD);

View File

@ -47,7 +47,7 @@ public class SLotterySetting implements BaseConfig {
}else if (entry.getValue().getLotteryType()==8){ }else if (entry.getValue().getLotteryType()==8){
Map<Integer, Integer> orDefault = integerMapMap.getOrDefault(5, new HashMap<>()); Map<Integer, Integer> orDefault = integerMapMap.getOrDefault(5, new HashMap<>());
orDefault.put(entry.getValue().getPropertyType(),entry.getKey()); orDefault.put(entry.getValue().getPropertyType(),entry.getKey());
integerMapMap.put(4,orDefault); integerMapMap.put(5,orDefault);
} }
} }
changeIds = integerMapMap; changeIds = integerMapMap;