From cd8777c4496095f1beaae661d45dfaf62ad03507 Mon Sep 17 00:00:00 2001 From: yuanshuai <243578945@qq.com> Date: Thu, 21 Oct 2021 14:34:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E8=A1=8C=E6=8A=80=E8=83=BD=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E8=84=9A=E6=9C=AC=E4=BF=AE=E6=94=B9=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ljsd/CoreService.java | 4 + .../ljsd/jieling/logic/hero/HeroLogic.java | 2728 +++++++++-------- .../com/ljsd/jieling/util/FightDataUtil.java | 95 +- .../src/main/java/config/SPlayerSkill.java | 14 +- 4 files changed, 1481 insertions(+), 1360 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/CoreService.java b/serverlogic/src/main/java/com/ljsd/CoreService.java index c08d5b669..ba57b7a4a 100644 --- a/serverlogic/src/main/java/com/ljsd/CoreService.java +++ b/serverlogic/src/main/java/com/ljsd/CoreService.java @@ -188,6 +188,10 @@ public class CoreService implements RPCRequestIFace.Iface { //坐骑技能 rpcArenaManager.setSkill(Arrays.asList(user.getPlayerInfoManager().getUserMountValidTime().keySet().toArray(new Integer[0]))); rpcArenaManager.setFourSpirit(user.getPlayerInfoManager().getFourChallengeTotal()); + ///修行技能数据 + rpcArenaManager.setPracticeSkillMap(user.getHeroManager().getPracticeSkillMap()); + + rpcArenaManager.setMaxHistoryForce(user.getPlayerInfoManager().getMaxForce()); return rpcArenaManager; }catch (Exception e){ diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index 87c6e371c..6b875ce6c 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -69,10 +69,10 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; -public class HeroLogic{ +public class HeroLogic { private static final Logger LOGGER = LoggerFactory.getLogger(HeroLogic.class); - public HeroLogic(){ + public HeroLogic() { //英雄事件监听 Poster.getPoster().listenEvent(new HeroFiveStarGetEventHandler(), HeroFiveStarGetEvent.class); Poster.getPoster().listenEvent(new PokemonFiveStarGetEventHandler(), PokemonFiveStarGetEvent.class); @@ -80,9 +80,10 @@ public class HeroLogic{ public static List transTemplate = new ArrayList<>(); public static List equipSkillPositionTemaplge = new ArrayList<>(6); - private static Map> transTemplateByHeroPropertyName = new HashMap<>(); + private static Map> transTemplateByHeroPropertyName = new HashMap<>(); private static List pokemonTemplate = new ArrayList<>(); + static { transTemplate.add(HeroAttributeEnum.CurHP.getPropertyId()); // 生命 transTemplate.add(HeroAttributeEnum.Hp.getPropertyId()); // 最大生命 @@ -116,12 +117,12 @@ public class HeroLogic{ // transTemplate.add(HeroAttributeEnum.DarkDamageBonusFactor.getPropertyId()); // 暗系伤害加成系数 transTemplate.add(HeroAttributeEnum.DarkDamageReduceFactor.getPropertyId()); // 暗系伤害减免系数 - transTemplateByHeroPropertyName.put(1,new ArrayList<>(transTemplate)); - transTemplateByHeroPropertyName.put(2,new ArrayList<>(transTemplate)); - transTemplateByHeroPropertyName.put(3,new ArrayList<>(transTemplate)); - transTemplateByHeroPropertyName.put(4,new ArrayList<>(transTemplate)); - transTemplateByHeroPropertyName.put(5,new ArrayList<>(transTemplate)); - transTemplateByHeroPropertyName.put(6,new ArrayList<>(transTemplate)); + transTemplateByHeroPropertyName.put(1, new ArrayList<>(transTemplate)); + transTemplateByHeroPropertyName.put(2, new ArrayList<>(transTemplate)); + transTemplateByHeroPropertyName.put(3, new ArrayList<>(transTemplate)); + transTemplateByHeroPropertyName.put(4, new ArrayList<>(transTemplate)); + transTemplateByHeroPropertyName.put(5, new ArrayList<>(transTemplate)); + transTemplateByHeroPropertyName.put(6, new ArrayList<>(transTemplate)); transTemplateByHeroPropertyName.get(1).add(HeroAttributeEnum.FireDamageBonusFactor.getPropertyId()); transTemplateByHeroPropertyName.get(2).add(HeroAttributeEnum.WindDamageBonusFactor.getPropertyId()); @@ -153,20 +154,22 @@ public class HeroLogic{ pokemonTemplate.add(HeroAttributeEnum.TreatFacter.getPropertyId()); // 治疗加成系数 pokemonTemplate.add(HeroAttributeEnum.CureFacter.getPropertyId()); // 受治疗 } - public static final String VERTICAL = "|"; - public static final String DIVISION = "#"; + + public static final String VERTICAL = "|"; + public static final String DIVISION = "#"; public static final int HERO_MAX_STAR = 10; // 英雄最大星级,大于10星为觉醒 /** * 获取装备、法宝信息、魂印 + * * @param iSession * @param index * @param type * @throws Exception */ - public void getAllEquipInfo(ISession iSession,int index,int type) throws Exception { + public void getAllEquipInfo(ISession iSession, int index, int type) throws Exception { int uid = iSession.getUid(); User user = UserManager.getUser(uid); List equipList = new ArrayList<>(); @@ -205,17 +208,17 @@ public class HeroLogic{ } ; //宝器 - if(type==4){ + if (type == 4) { Map equipMap = user.getEquipManager().getEquipMap(); Set needRemove = new HashSet<>(equipMap.size()); - for(Map.Entry equipInfoEntry : equipMap.entrySet()){ + for (Map.Entry equipInfoEntry : equipMap.entrySet()) { PropertyItem value = equipInfoEntry.getValue(); if (value == null) { needRemove.add(equipInfoEntry.getKey()); LOGGER.info("getAllEquipInfo uid={} remove null jewel{}", uid, equipInfoEntry.getKey()); continue; } - if(value instanceof Jewel) { + if (value instanceof Jewel) { equipList.add(CBean2Proto.getEquipProto(value)); } } @@ -224,29 +227,29 @@ public class HeroLogic{ equipManager.remove(id); } } - }else { + } else { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } boolean isSendFinish = false; - int endIndex = index + Global.SEND_EQUIP_COUNT; + int endIndex = index + Global.SEND_EQUIP_COUNT; if (index < equipList.size()) { if (endIndex >= equipList.size()) { endIndex = equipList.size(); } - if (equipList.size() == endIndex){ + if (equipList.size() == endIndex) { isSendFinish = true; } equipList = equipList.subList(index, endIndex); - }else{ + } else { isSendFinish = true; } HeroInfoProto.GetAllEquipResponse build = HeroInfoProto.GetAllEquipResponse.newBuilder() .addAllEquip(equipList) .setIsSendFinish(isSendFinish) .build(); - MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.GET_ALL_EQUIP_RESPONSE_VALUE,build,true); + MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_ALL_EQUIP_RESPONSE_VALUE, build, true); } public Object getRobotHeroSkills(List skillIds, StringBuilder skillSb) { @@ -266,8 +269,7 @@ public class HeroLogic{ } - - public void random(ISession session,int type) throws Exception { + public void random(ISession session, int type) throws Exception { long time = System.currentTimeMillis(); int uid = session.getUid(); User user = UserManager.getUser(uid); @@ -277,27 +279,27 @@ public class HeroLogic{ } int perCount = sLotterySetting.getPerCount(); int maxTimes = sLotterySetting.getMaxTimes(); - if(maxTimes!=0 && !PlayerLogic.getInstance().checkAndUpdate(user,maxTimes, perCount)){ + if (maxTimes != 0 && !PlayerLogic.getInstance().checkAndUpdate(user, maxTimes, perCount)) { throw new ErrorCodeException("已抽取今日最大次数"); } HeroManager heroManager = user.getHeroManager(); - if(type==11&&heroManager.getFirstTenth()==0){ + if (type == 11 && heroManager.getFirstTenth() == 0) { heroManager.updateFirstTenth(); } - if(sLotterySetting.getLotteryType()==3){ + if (sLotterySetting.getLotteryType() == 3) { //活动抽卡校验 - if(!user.getActivityManager().getActivityMissionMap().containsKey(sLotterySetting.getActivityId())){ + if (!user.getActivityManager().getActivityMissionMap().containsKey(sLotterySetting.getActivityId())) { throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN); } SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(sLotterySetting.getActivityId()); long endTimeLong = ToolsUtil.getEndTimeLong(activity.getStartTimeLong(), activity.getEndTimeLong(), activity.getTime(), user.getPlayerInfoManager().getCreateTime(), activity.getGapTime()); - if(endTimeLong!=0&&TimeUtils.now()>endTimeLong){ + if (endTimeLong != 0 && TimeUtils.now() > endTimeLong) { throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN); } } - if(heroManager!=null&& heroManager.getHeroMap()!=null){ + if (heroManager != null && heroManager.getHeroMap() != null) { //只有抽英雄才校验 - if(sLotterySetting.getGainType()==1&&heroManager.getHeroMap().size() + perCount > STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getHeroNumlimit()){ + if (sLotterySetting.getGainType() == 1 && heroManager.getHeroMap().size() + perCount > STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getHeroNumlimit()) { throw new ErrorCodeException(ErrorCode.HERO_MAX); } } @@ -306,42 +308,42 @@ public class HeroLogic{ boolean allowFree = false; int[] costAmount = new int[1]; int privilege = sLotterySetting.getFreeTimes(); - if(privilege!=0){ - allowFree = PlayerLogic.getInstance().checkAndUpdate(user,privilege, perCount); + if (privilege != 0) { + allowFree = PlayerLogic.getInstance().checkAndUpdate(user, privilege, perCount); } - if(!allowFree){ - boolean enoughCost = false; - for (int[] cost:sLotterySetting.getCostItem()){ + if (!allowFree) { + boolean enoughCost = false; + for (int[] cost : sLotterySetting.getCostItem()) { int[] costItem = new int[cost.length]; - for(int i= 0; i missingType = SPrivilegeTypeConfig.privilegeByType.get(sLotterySetting.getDiscountTimes()); - Arrays.stream(costItems).forEach(n->{ - for(SPrivilegeTypeConfig config:missingType){ - if(user.getPlayerInfoManager().containPrivilageId(config.getId())){ - n[1] =(int)(n[1]/10000d*(10000+config.getCondition()[0][1])); + Arrays.stream(costItems).forEach(n -> { + for (SPrivilegeTypeConfig config : missingType) { + if (user.getPlayerInfoManager().containPrivilageId(config.getId())) { + n[1] = (int) (n[1] / 10000d * (10000 + config.getCondition()[0][1])); } } } ); } } - enoughCost = ItemUtil.itemCost(user, costItems,BIReason.RANDOM_HERO_CONSUME,type); - if(enoughCost){ + enoughCost = ItemUtil.itemCost(user, costItems, BIReason.RANDOM_HERO_CONSUME, type); + if (enoughCost) { costAmount = cost; break; } } - if(!enoughCost){ + if (!enoughCost) { throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); } } @@ -349,75 +351,76 @@ public class HeroLogic{ //抽卡必得积分 int[][] tenTimesMustGetItem = sLotterySetting.getTenTimesMustGetItem(); //所有获得物品 - int[][] resultRandom = new int[perCount+tenTimesMustGetItem.length][]; + int[][] resultRandom = new int[perCount + tenTimesMustGetItem.length][]; //进行抽取 int index = 0; - for(int i = 0 ;i lotteryListByDifferentType = SLotterySpecialConfig.getLotteryListByDifferentType(7); - if(lotteryListByDifferentType.size()==1){ + if (lotteryListByDifferentType.size() == 1) { SLotterySpecialConfig next = lotteryListByDifferentType.iterator().next(); - builder.setMustCount(next.getCount()-heroManager.getRandomPoolByType().get(sLotterySetting.getMergePool()).getOrDefault(7,0)); + builder.setMustCount(next.getCount() - heroManager.getRandomPoolByType().get(sLotterySetting.getMergePool()).getOrDefault(7, 0)); } } - user.getUserMissionManager().onGameEvent(user,GameEvent.RANDOM_HERO,sLotterySetting.getLotteryType(),perCount); - if(sLotterySetting.getLotteryType()==11){ + user.getUserMissionManager().onGameEvent(user, GameEvent.RANDOM_HERO, sLotterySetting.getLotteryType(), perCount); + if (sLotterySetting.getLotteryType() == 11) { //只记录新将招募次数 - user.getUserMissionManager().onGameEvent(user, GameEvent.NEW_HERO_ZHAOMU,sLotterySetting.getPerCount()); + user.getUserMissionManager().onGameEvent(user, GameEvent.NEW_HERO_ZHAOMU, sLotterySetting.getPerCount()); } - if(sLotterySetting.getActivityId() == 8201){ - Poster.getPoster().dispatchEvent(new UserLevelEvent(user.getId(),0)); + if (sLotterySetting.getActivityId() == 8201) { + Poster.getPoster().dispatchEvent(new UserLevelEvent(user.getId(), 0)); } - heroManager.updateRandCount(type,perCount); - CommonProto.Drop.Builder drop = ItemUtil.dropPer(user, resultRandom,BIReason.HERO_RANDOM); - fiveStarPushByRandom(user,resultRandom); - fiveStarPokemonPushByRandom(user,resultRandom); + heroManager.updateRandCount(type, perCount); + CommonProto.Drop.Builder drop = ItemUtil.dropPer(user, resultRandom, BIReason.HERO_RANDOM); + fiveStarPushByRandom(user, resultRandom); + fiveStarPokemonPushByRandom(user, resultRandom); builder.setDrop(drop); builder.addAllDrawTimes(CBean2Proto.getRandomTypeNums(user)); MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE, builder.build(), true); - if(sLotterySetting.getLotteryType() == GlobalsDef.RANDOM_LOTTERY_TYPE && !user.getPlayerInfoManager().isHasRandomLotteryType()&&sLotterySetting.getPerCount()!=1){ + if (sLotterySetting.getLotteryType() == GlobalsDef.RANDOM_LOTTERY_TYPE && !user.getPlayerInfoManager().isHasRandomLotteryType() && sLotterySetting.getPerCount() != 1) { //首次神将召唤 10连抽 给个攻略邮件 String title = SErrorCodeEerverConfig.getI18NMessage("zhanneixin_title"); - String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("zhanneixin_content",new Object[]{ user.getPlayerInfoManager().getNickName()},new int[]{0},"#"); - MailLogic.getInstance().sendSpecialMail(uid,title,content,"",(int) (TimeUtils.now() / 1000),Global.MAIL_EFFECTIVE_TIME,1,1); + String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("zhanneixin_content", new Object[]{user.getPlayerInfoManager().getNickName()}, new int[]{0}, "#"); + MailLogic.getInstance().sendSpecialMail(uid, title, content, "", (int) (TimeUtils.now() / 1000), Global.MAIL_EFFECTIVE_TIME, 1, 1); user.getPlayerInfoManager().setHasRandomLotteryType(true); } } /** * 英雄卡池抽卡封装 + * * @param user * @param sLotteryRewardConfig * @param sLotterySetting * @return */ - private int[] drawCard(User user, SLotteryRewardConfig sLotteryRewardConfig, SLotterySetting sLotterySetting)throws Exception{ + private int[] drawCard(User user, SLotteryRewardConfig sLotteryRewardConfig, SLotterySetting sLotterySetting) throws Exception { HeroManager heroManager = user.getHeroManager(); // 参数 int type = sLotterySetting.getLotteryType(); @@ -425,28 +428,28 @@ public class HeroLogic{ // 限制满足次数 int value = SSpecialConfig.getIntegerValue(SSpecialConfig.UNLOCKCARDWISH); // 对应卡池抽奖次数 - Integer num = heroManager.getRandomCountByType().getOrDefault(type,0); + Integer num = heroManager.getRandomCountByType().getOrDefault(type, 0); // 心愿抽卡 int[] result; - if (type == 1 && num >= value){ + if (type == 1 && num >= value) { // 钻石抽卡并且次数满足 - result = wishDrawCardCheck(user,reward,type); - } else if(sLotterySetting.getLotteryType() == 3&& + result = wishDrawCardCheck(user, reward, type); + } else if (sLotterySetting.getLotteryType() == 3 && isActivityBeautyBag(sLotterySetting.getActivityId())) {//乾坤宝盒-许愿魂印 result = BeautyBagDrawCard(user, sLotteryRewardConfig); - }else { + } else { result = reward; } //活动抽奖计数 - if(isActivityByIdAndType(sLotterySetting.getActivityId(), ActivityType.BEAUTY_BAG)){ + if (isActivityByIdAndType(sLotterySetting.getActivityId(), ActivityType.BEAUTY_BAG)) { //乾坤宝盒抽奖 计次数 - user.getUserMissionManager().onGameEvent(user, GameEvent.QIAN_KUN_BOX,1); - }else if(isActivityByIdAndType(sLotterySetting.getActivityId(), ActivityType.SPECIAL_MONSTER_RANDOM_ACTIVITY)){ + user.getUserMissionManager().onGameEvent(user, GameEvent.QIAN_KUN_BOX, 1); + } else if (isActivityByIdAndType(sLotterySetting.getActivityId(), ActivityType.SPECIAL_MONSTER_RANDOM_ACTIVITY)) { //灵兽招募 计次数 - user.getUserMissionManager().onGameEvent(user, GameEvent.SOUL_RECRUIT,1); + user.getUserMissionManager().onGameEvent(user, GameEvent.SOUL_RECRUIT, 1); } //记录卡池抽奖次数 - heroManager.putRandomType(type,num+result[1]); + heroManager.putRandomType(type, num + result[1]); return result; } @@ -454,37 +457,38 @@ public class HeroLogic{ private int[] BeautyBagDrawCard(User user, SLotteryRewardConfig sLotteryRewardConfig) { int count = SSpecialConfig.getIntegerValue(SSpecialConfig.NUMOFCHOOSEREDSIGN); List list = SLotteryRewardConfig.getSLotteryRewardConfigListByPoolId(sLotteryRewardConfig.getPool()); - if(list==null){ + if (list == null) { return sLotteryRewardConfig.getReward(); } int index = list.indexOf(sLotteryRewardConfig); - if(index>=count){ + if (index >= count) { return sLotteryRewardConfig.getReward(); } - if(user.getHeroManager().getBeautyBagCardInfoMap().containsKey(index+1)==false){ + if (user.getHeroManager().getBeautyBagCardInfoMap().containsKey(index + 1) == false) { return sLotteryRewardConfig.getReward(); } int[] result = new int[2]; - result[0] = user.getHeroManager().getBeautyBagCardInfoMap().get(index+1); + result[0] = user.getHeroManager().getBeautyBagCardInfoMap().get(index + 1); result[1] = sLotteryRewardConfig.getReward()[1]; - LOGGER.info("抽到了UP---->"+sLotteryRewardConfig.getReward()[0]+"替换为---->"+result[0]); + LOGGER.info("抽到了UP---->" + sLotteryRewardConfig.getReward()[0] + "替换为---->" + result[0]); return result; } - private boolean isActivityBeautyBag(int activityId){ + private boolean isActivityBeautyBag(int activityId) { SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(activityId); - if(activity==null){ + if (activity == null) { return false; } return activity.getType() == ActivityType.BEAUTY_BAG; } - private boolean isActivityByIdAndType(int activityId,int activityType){ + + private boolean isActivityByIdAndType(int activityId, int activityType) { SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(activityId); - if(activity==null){ + if (activity == null) { return false; } @@ -493,20 +497,21 @@ public class HeroLogic{ /** * 心愿抽卡校验 + * * @param user * @param item * @return */ - private int[] wishDrawCardCheck(User user,int[] item,int type){ + private int[] wishDrawCardCheck(User user, int[] item, int type) { // 查找物品 SItem sItem = SItem.getsItemMap().get(item[0]); // 非英雄奖励直接返回 - if (sItem.getItemType() != GlobalItemType.CARD){ + if (sItem.getItemType() != GlobalItemType.CARD) { return item; } // 非五星英雄 SCHero scHero = SCHero.getsCHero().get(item[0]); - if (scHero == null || scHero.getStar() < 5){ + if (scHero == null || scHero.getStar() < 5) { return item; } // 更新抽奖次数, 记录卡池 @@ -514,14 +519,14 @@ public class HeroLogic{ // 获取类型抽奖次数 Map randomStar = heroManager.getWishStar(type); // 更新次数 - int num = heroManager.getWishStar(type).getOrDefault(scHero.getStar(), 0)+1; - randomStar.put(scHero.getStar(),num); - heroManager.putWishStar(type,randomStar); + int num = heroManager.getWishStar(type).getOrDefault(scHero.getStar(), 0) + 1; + randomStar.put(scHero.getStar(), num); + heroManager.putWishStar(type, randomStar); /* ======================= 中不中心愿 ======================= */ // 获取钻石抽奖抽中五星的次数 boolean randomBol = (num - 1) % 3 == 0; - LOGGER.error("*************************************是否中心愿;num:{},random:{}",num, randomBol); - if (!randomBol){ + LOGGER.error("*************************************是否中心愿;num:{},random:{}", num, randomBol); + if (!randomBol) { // 不到次数,不走心愿 return item; } @@ -532,33 +537,33 @@ public class HeroLogic{ int empty = SSpecialConfig.getIntegerValue(SSpecialConfig.CARDWISHBLOCKRATE); // 计算权重map HashMap map = new HashMap<>(); - cardInfoMap.forEach((k,v)->{ - if (v.getStatus() == 0){ - if (v.getHeroTid() == 0){ + cardInfoMap.forEach((k, v) -> { + if (v.getStatus() == 0) { + if (v.getHeroTid() == 0) { // 空格子 - map.put(k,empty); - }else { + map.put(k, empty); + } else { // 英雄格子 int heroWeight = Optional.ofNullable(SCHero.getsCHero().get(v.getHeroTid())).map(SCHero::getWeight).orElse(0); - map.put(k,heroWeight); + map.put(k, heroWeight); } } }); // 全部抽中 - if (map.isEmpty()){ + if (map.isEmpty()) { return item; } // 随机权重 int weight = map.values().stream().mapToInt(Integer::intValue).sum(); int randomInt = MathUtils.randomInt(weight); - LOGGER.error("*************************************心愿抽奖权重,总权重:{},随机值:{},map:{}",weight,randomInt,map.toString()); + LOGGER.error("*************************************心愿抽奖权重,总权重:{},随机值:{},map:{}", weight, randomInt, map.toString()); // 遍历权重 for (Map.Entry entry : map.entrySet()) { - if (randomInt <= entry.getValue()){ + if (randomInt <= entry.getValue()) { // 读取格子信息 WishDrawCardInfo cardInfo = cardInfoMap.get(entry.getKey()); // null表示未中心愿, 该格子已锁定, 是空格子 - if (cardInfo == null || cardInfo.getStatus() == 1 || cardInfo.getHeroTid() == 0){ + if (cardInfo == null || cardInfo.getStatus() == 1 || cardInfo.getHeroTid() == 0) { return item; } // new int[] @@ -574,28 +579,29 @@ public class HeroLogic{ return result; } // 权重递减 - randomInt-=entry.getValue(); + randomInt -= entry.getValue(); } return item; } /** * 推送心愿格子信息到客户端 + * * @param user */ - private void sendWishCardIndication(User user){ + private void sendWishCardIndication(User user) { List wishCard = CBean2Proto.getWishCard(user); HeroInfoProto.wishDrawCardIndication.Builder list = HeroInfoProto.wishDrawCardIndication.newBuilder().addAllInfoList(wishCard); - MessageUtil.sendIndicationMessage(user.getId(),list.build()); + MessageUtil.sendIndicationMessage(user.getId(), list.build()); } /** * 重置心愿格子信息 */ - public void resetWishDrawCardInfoMap(User user){ + public void resetWishDrawCardInfoMap(User user) { // 重置状态 HashMap map = user.getHeroManager().getWishDrawCardInfoMap(); - map.values().forEach(v->v.setStatus(0)); + map.values().forEach(v -> v.setStatus(0)); user.getHeroManager().setWishDrawCardInfoMap(map); // 推送消息 sendWishCardIndication(user); @@ -603,6 +609,7 @@ public class HeroLogic{ /** * 修改英雄格子 + * * @param user * @param list * @throws ErrorCodeException @@ -612,9 +619,9 @@ public class HeroLogic{ // 英雄拷贝 HashMap map = new HashMap<>(wishDrawCardInfoMap.size()); - wishDrawCardInfoMap.forEach((k,v)->{ + wishDrawCardInfoMap.forEach((k, v) -> { try { - map.put(k,v.clone()); + map.put(k, v.clone()); } catch (CloneNotSupportedException e) { e.printStackTrace(); } @@ -624,7 +631,7 @@ public class HeroLogic{ for (CommonProto.wishDrawCardInfo v : list) { WishDrawCardInfo cardInfo = map.get(v.getId()); // 英雄未锁定 - if (cardInfo != null && cardInfo.getStatus() == 0){ + if (cardInfo != null && cardInfo.getStatus() == 0) { // 替换英雄 cardInfo.setHeroTid(v.getHeroTid()); } @@ -632,8 +639,8 @@ public class HeroLogic{ // 获取已选择英雄的类型set集合 Set race = new HashSet<>(); - map.values().forEach(v->{ - if (v.getHeroTid() != 0){ + map.values().forEach(v -> { + if (v.getHeroTid() != 0) { SCHero scHero = SCHero.getsCHero().get(v.getHeroTid()); race.add(scHero.getPropertyName()); } @@ -641,10 +648,10 @@ public class HeroLogic{ // 去除空格子后队列的长度 List infos = new ArrayList<>(map.values()); - infos.removeIf(v->v.getHeroTid() == 0); + infos.removeIf(v -> v.getHeroTid() == 0); // 类型唯一, 如果长度不一致代表有重复类型英雄 - if (race.size() != infos.size()){ + if (race.size() != infos.size()) { throw new ErrorCodeException("有重复类型英雄,替换失败"); } // 入库 @@ -655,10 +662,11 @@ public class HeroLogic{ /** * 获取可以加入 + * * @param user * @return */ - public Set getWishOpenHeroList(User user){ + public Set getWishOpenHeroList(User user) { // 开服时间戳 long openTime = TimeUtils.stringToTimeLong2(GameApplication.serverConfig.getOpenTime()); // 当前时间戳 @@ -670,13 +678,13 @@ public class HeroLogic{ // 全部的英雄列表 Map heroMap = SCHero.getsCHero(); // 满足条件的放入set - heroMap.values().stream().filter(v->v.getJoinWishDay() > 0 && time >= v.getJoinWishDay()*TimeUtils.DAY).forEach(v->set.add(v.getId())); + heroMap.values().stream().filter(v -> v.getJoinWishDay() > 0 && time >= v.getJoinWishDay() * TimeUtils.DAY).forEach(v -> set.add(v.getId())); // set, 返回给客户端,最新的set HashSet result = new HashSet<>(); // 目前存储的全部set Set heroList = user.getHeroManager().getWishOpenHeroList(); // 之前没有记录的为新开放,需要返回给客户端 - set.stream().filter(v->!heroList.contains(v)).forEach(result::add); + set.stream().filter(v -> !heroList.contains(v)).forEach(result::add); // 更新玩家数据库 user.getHeroManager().setWishOpenHeroList(set); return result; @@ -684,51 +692,53 @@ public class HeroLogic{ /** * 从抽卡获取服务器开服时间 + * * @return */ - public int getServerOpenTimeByWishCard(){ + public int getServerOpenTimeByWishCard() { // 开服时间 long openTime = TimeUtils.stringToTimeLong2(GameApplication.serverConfig.getOpenTime()); // 根据格式获取时间戳 例子 :20210720 int value = SSpecialConfig.getIntegerValue(SSpecialConfig.Data_Of_Unlock_All_Wish_Hero); long time = TimeUtils.stringToTimeLong(String.valueOf(value), "yyyyMMdd"); // 规定时间之前开服的返回0 - if (openTime <= time){ + if (openTime <= time) { return 0; - }else { - return (int) (openTime/1000); + } else { + return (int) (openTime / 1000); } } - private void changeRandomItem(User user,int activityId,int[][] random){ + private void changeRandomItem(User user, int activityId, int[][] random) { ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(activityId); - if(activityMission==null||activityMission.getActivityMissionMap().get(0)==null){ + if (activityMission == null || activityMission.getActivityMissionMap().get(0) == null) { return; } // Map> spiritAnimalSummonMapByActivityId = SSpiritAnimalSummo.spiritAnimalSummonMapByActivityId; ActivityProgressInfo activityProgressInfo = activityMission.getActivityMissionMap().get(0); - if(activityProgressInfo==null||activityProgressInfo.getProgrss()==0){ + if (activityProgressInfo == null || activityProgressInfo.getProgrss() == 0) { return; } Map config = STableManager.getConfig(SSpiritAnimalSummon.class); - if(!config.containsKey(activityProgressInfo.getProgrss())){ + if (!config.containsKey(activityProgressInfo.getProgrss())) { return; } SSpiritAnimalSummon sSpiritAnimalSummon = config.get(activityProgressInfo.getProgrss()); - if(sSpiritAnimalSummon.getActivityID()!=activityId){ + if (sSpiritAnimalSummon.getActivityID() != activityId) { return; } //进行替换 - for(int[] randomItem:random){ - int length = Math.min(sSpiritAnimalSummon.getOriginalItemList().length,sSpiritAnimalSummon.getTargetItemList().length); - for(int i = 0 ; i = 2) { - ReportUtil.onReportEvent(user, eventEnum.getType(), activityId==0?"":activityId, String.valueOf(sLotterySetting.getPerCount()), String.valueOf(costItem[0]), costItem[1], result); + ReportUtil.onReportEvent(user, eventEnum.getType(), activityId == 0 ? "" : activityId, String.valueOf(sLotterySetting.getPerCount()), String.valueOf(costItem[0]), costItem[1], result); } else { - ReportUtil.onReportEvent(user, eventEnum.getType(), activityId==0?"":activityId, String.valueOf(sLotterySetting.getPerCount()), "", "", result); + ReportUtil.onReportEvent(user, eventEnum.getType(), activityId == 0 ? "" : activityId, String.valueOf(sLotterySetting.getPerCount()), "", "", result); } } catch (Exception e) { e.printStackTrace(); } } + /** * 修改魂印格子 + * * @param user * @param list * @throws ErrorCodeException */ public void updateBeautyBagCardInfo(User user, List list) throws ErrorCodeException { - HashMap map = new HashMap<>(); + HashMap map = new HashMap<>(); int count = SSpecialConfig.getIntegerValue(SSpecialConfig.NUMOFCHOOSEREDSIGN); - for(CommonProto.beautyBagCardInfo info:list){ - if(map.containsValue(info.getEquip())){ + for (CommonProto.beautyBagCardInfo info : list) { + if (map.containsValue(info.getEquip())) { throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } - if(map.containsKey(info.getId())){ + if (map.containsKey(info.getId())) { throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } SEquipConfig config = STableManager.getConfig(SEquipConfig.class).get(info.getEquip()); - if(config==null){ + if (config == null) { throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } - if(config.getQuality()!=6){ + if (config.getQuality() != 6) { throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } - if(info.getId()<1||info.getId()>count){ + if (info.getId() < 1 || info.getId() > count) { throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } - map.put(info.getId(),info.getEquip()); + map.put(info.getId(), info.getEquip()); } user.getHeroManager().setBeautyBagCardInfoMap(map); @@ -841,12 +853,13 @@ public class HeroLogic{ /** * 每次抽取 + * * @param user * @param type * @return * @throws Exception */ - public static int randomOne(User user,int type) throws Exception { + public static int randomOne(User user, int type) throws Exception { SLotterySetting sLotterySetting = STableManager.getConfig(SLotterySetting.class).get(type); int mergePool = sLotterySetting.getMergePool(); List specialConfigs = SLotterySpecialConfig.getLotterySpecialConfigListByType(mergePool); @@ -854,43 +867,43 @@ public class HeroLogic{ Set mustSet = new HashSet<>(); Map> randomPoolByType = heroManager.getRandomPoolByType(); //设置用户必出计数器 - if(specialConfigs!=null&&!specialConfigs.isEmpty()){ - if(!randomPoolByType.containsKey(mergePool)){ - randomPoolByType.put(mergePool,new HashMap<>()); - for(SLotterySpecialConfig config:specialConfigs){ - randomPoolByType.get(mergePool).put(config.getDifferentType(),0); + if (specialConfigs != null && !specialConfigs.isEmpty()) { + if (!randomPoolByType.containsKey(mergePool)) { + randomPoolByType.put(mergePool, new HashMap<>()); + for (SLotterySpecialConfig config : specialConfigs) { + randomPoolByType.get(mergePool).put(config.getDifferentType(), 0); } } //保底次数计算 - for(Map.Entry countEntry:randomPoolByType.get(mergePool).entrySet()){ + for (Map.Entry countEntry : randomPoolByType.get(mergePool).entrySet()) { SLotterySpecialConfig config = null; // if(specialConfigs.isEmpty()){ // continue; // } - for(SLotterySpecialConfig everyConfig:specialConfigs){ - if(everyConfig.getDifferentType()!=countEntry.getKey()){ + for (SLotterySpecialConfig everyConfig : specialConfigs) { + if (everyConfig.getDifferentType() != countEntry.getKey()) { continue; } config = everyConfig; } - if(config==null){ + if (config == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } //本次是否触发保底 - if(countEntry.getValue()+1 mustRandomCount = heroManager.getMustRandomCount(); - if(mustRandomCount.containsKey(countEntry.getKey())) { + if (mustRandomCount.containsKey(countEntry.getKey())) { //是否已经到了保底触发上限 - if(config.getMin_num()!=0&&mustRandomCount.get(countEntry.getKey())>=config.getMin_num()) { + if (config.getMin_num() != 0 && mustRandomCount.get(countEntry.getKey()) >= config.getMin_num()) { continue; - }else{ - mustRandomCount.put(countEntry.getKey(), mustRandomCount.get(countEntry.getKey())+1); + } else { + mustRandomCount.put(countEntry.getKey(), mustRandomCount.get(countEntry.getKey()) + 1); } - }else{ - mustRandomCount.put(countEntry.getKey(),1); + } else { + mustRandomCount.put(countEntry.getKey(), 1); } heroManager.setMustRandomCount(mustRandomCount); mustSet.add(countEntry.getKey()); @@ -899,7 +912,7 @@ public class HeroLogic{ SLotteryRewardConfig sLotteryRewardConfig; //是否有必出 int currStarId = 0; - if(mustSet.isEmpty()){ + if (mustSet.isEmpty()) { int pooId = getPooId(sLotterySetting); sLotteryRewardConfig = randomHeroByPoolId(pooId, user); // if(randomPoolByType.get(mergePool)!=null) { @@ -912,38 +925,38 @@ public class HeroLogic{ // } // } // } - if(sLotteryRewardConfig!=null){ + if (sLotteryRewardConfig != null) { currStarId = sLotteryRewardConfig.getStar(); - LOGGER.info("随机到了{}-->对应star-->{}",sLotteryRewardConfig.getId(),currStarId); + LOGGER.info("随机到了{}-->对应star-->{}", sLotteryRewardConfig.getId(), currStarId); } - }else{ + } else { //有必出时比较各个优先级,取优先级高的 int maxId = 0; - for(int mustId:mustSet){ - maxId = mustId>maxId?mustId:maxId; + for (int mustId : mustSet) { + maxId = mustId > maxId ? mustId : maxId; } LOGGER.info("randomOne uid=>{} 触发必出=>{}", user.getId(), maxId); SLotterySpecialConfig onConfig = null; - for(SLotterySpecialConfig everyConfig:specialConfigs){ - if(everyConfig.getDifferentType()!=maxId){ + for (SLotterySpecialConfig everyConfig : specialConfigs) { + if (everyConfig.getDifferentType() != maxId) { continue; } onConfig = everyConfig; } - if(onConfig==null){ + if (onConfig == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } sLotteryRewardConfig = randomHeroByPoolId(onConfig.getpool_id(), user); currStarId = maxId; } - if(randomPoolByType.get(mergePool)!=null) { + if (randomPoolByType.get(mergePool) != null) { for (int key : randomPoolByType.get(mergePool).keySet()) { //如果生效次数是0可重置 List lotteryListByDifferentType = SLotterySpecialConfig.getLotteryListByDifferentType(key); if (currStarId >= key && lotteryListByDifferentType != null && lotteryListByDifferentType.iterator().hasNext() && lotteryListByDifferentType.iterator().next().getMin_num() == 0) { - LOGGER.info("清除计数{}下的--->{}",mergePool,key); + LOGGER.info("清除计数{}下的--->{}", mergePool, key); randomPoolByType.get(mergePool).put(key, 0); } else { int curValue = randomPoolByType.get(mergePool).getOrDefault(key, 0); @@ -951,32 +964,32 @@ public class HeroLogic{ } } } - heroManager.updateRandomPoolByType(mergePool,randomPoolByType.get(mergePool)); + heroManager.updateRandomPoolByType(mergePool, randomPoolByType.get(mergePool)); int result = sLotteryRewardConfig.getId(); heroManager.addRandomPoolInfo(sLotteryRewardConfig.getPool()); return result; } - private int getSpecialPoolByRandcount(SLotterySetting sLotterySetting, int randCount,int poolCount) { + private int getSpecialPoolByRandcount(SLotterySetting sLotterySetting, int randCount, int poolCount) { int id = sLotterySetting.getId(); List list = SLotterySpecialConfig.getLotterySpecialConfigListByType(id); if (list == null) { list = SLotterySpecialConfig.getLotterySpecialConfigListByType(sLotterySetting.getMergePool()); - if(list == null){ + if (list == null) { return 0; } } int poolId = 0; for (SLotterySpecialConfig data : list) { - int n ; - if(data.getDifferentType() == 2 ){ - if(poolCount%data.getCount()!=0){ + int n; + if (data.getDifferentType() == 2) { + if (poolCount % data.getCount() != 0) { continue; } n = poolCount / data.getCount(); - }else{ + } else { if (randCount % data.getCount() != 0) { continue; } @@ -996,16 +1009,16 @@ public class HeroLogic{ private static int getPooId(SLotterySetting sLotterySetting) throws Exception { int[][] diamondBoxContain = sLotterySetting.getDiamondBoxContain(); int totalWeight = 0; - for(int i=0;i sLotteryRewardConfigs = new ArrayList<>(); List sLotteryRewardConfigListByPoolId = SLotteryRewardConfig.getSLotteryRewardConfigListByPoolId(poolId); - int totalCountByPoolId =0; - for(SLotteryRewardConfig sLotteryRewardConfig : sLotteryRewardConfigListByPoolId ){ + int totalCountByPoolId = 0; + for (SLotteryRewardConfig sLotteryRewardConfig : sLotteryRewardConfigListByPoolId) { int[] openRules = sLotteryRewardConfig.getOpenRules(); boolean canAdd = true; if (openRules != null && openRules.length > 0) { @@ -1040,7 +1052,7 @@ public class HeroLogic{ int openValue = openRules[1]; switch (openType) { case 1: - canAdd = user.getHeroManager().getRandomPoolInfo().getOrDefault(poolId,0) > openValue; + canAdd = user.getHeroManager().getRandomPoolInfo().getOrDefault(poolId, 0) > openValue; break; case 2: canAdd = user.getPlayerInfoManager().getLevel() > openValue; @@ -1050,18 +1062,18 @@ public class HeroLogic{ } } } - if(canAdd){ + if (canAdd) { sLotteryRewardConfigs.add(sLotteryRewardConfig); - totalCountByPoolId+=sLotteryRewardConfig.getWeight(); + totalCountByPoolId += sLotteryRewardConfig.getWeight(); } } int randCount = MathUtils.randomInt(totalCountByPoolId) + 1; - int weight =0; - for(SLotteryRewardConfig sLotteryRewardConfig :sLotteryRewardConfigs){ + int weight = 0; + for (SLotteryRewardConfig sLotteryRewardConfig : sLotteryRewardConfigs) { weight += sLotteryRewardConfig.getWeight(); - if(weight>=randCount){ - return sLotteryRewardConfig; + if (weight >= randCount) { + return sLotteryRewardConfig; } } return null; @@ -1073,7 +1085,7 @@ public class HeroLogic{ TeamPosManager teamPosManager = user.getTeamPosManager(); Map> teamPosForHero = teamPosManager.getTeamPosForHero(); Map teamNames = teamPosManager.getTeamNames(); - for(Map.Entry> item :teamPosForHero.entrySet()){ + for (Map.Entry> item : teamPosForHero.entrySet()) { int teamId = item.getKey(); List teamPosHeroInfoList = item.getValue(); // if(teamId==501){ @@ -1082,11 +1094,11 @@ public class HeroLogic{ // } // } String teamName = teamNames.get(teamId); - if(StringUtil.isEmpty(teamName)){ - teamName=""; + if (StringUtil.isEmpty(teamName)) { + teamName = ""; } List teamHeroInfoList = new ArrayList<>(); - for(TeamPosHeroInfo teamPosHeroInfo :teamPosHeroInfoList ){ + for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfoList) { teamHeroInfoList.add( CommonProto.TeamHeroInfo.newBuilder().setPosition(teamPosHeroInfo.getPosition()).setHeroId(teamPosHeroInfo.getHeroId()).build() ); @@ -1100,62 +1112,62 @@ public class HeroLogic{ ); } HeroInfoProto.GetAllTeamPosResponse build = HeroInfoProto.GetAllTeamPosResponse.newBuilder().addAllTeamPosInfo(teamPosInfoList).build(); - MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.GET_TEAMPOS_INFO_RESPONSE_VALUE,build,true); + MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.GET_TEAMPOS_INFO_RESPONSE_VALUE, build, true); } public void saveTeamPos(ISession iSession, int teamId, List heroIds) throws Exception { User user = UserManager.getUser(iSession.getUid()); HeroManager heroManager = user.getHeroManager(); Set set = new HashSet<>(); - if(teamId==GlobalsDef.EXPEDITION_TEAM){ + if (teamId == GlobalsDef.EXPEDITION_TEAM) { - heroIds.forEach(heroId->{ - if(heroManager.getHeroMap().containsKey(heroId.getHeroId())){ + heroIds.forEach(heroId -> { + if (heroManager.getHeroMap().containsKey(heroId.getHeroId())) { set.add(heroManager.getHero(heroId.getHeroId()).getTemplateId()); } - if(user.getExpeditionManager().getHeroMap().containsKey(heroId.getHeroId())){ + if (user.getExpeditionManager().getHeroMap().containsKey(heroId.getHeroId())) { set.add(user.getExpeditionManager().getHero(heroId.getHeroId()).getTemplateId()); } }); - }else if(teamId==GlobalsDef.TRIAL_TEAM){ - if(heroIds.size()!=1){ + } else if (teamId == GlobalsDef.TRIAL_TEAM) { + if (heroIds.size() != 1) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - heroIds.forEach(heroId->set.add(user.getMapManager().getTrialInfo().getHeroInfo().get(heroId.getHeroId()).getTmpId())); - } else if(teamId == GlobalsDef.ENDLESS_TEAM){ - for(CommonProto.TeamHeroInfo teamHeroInfo:heroIds){ + heroIds.forEach(heroId -> set.add(user.getMapManager().getTrialInfo().getHeroInfo().get(heroId.getHeroId()).getTmpId())); + } else if (teamId == GlobalsDef.ENDLESS_TEAM) { + for (CommonProto.TeamHeroInfo teamHeroInfo : heroIds) { Hero hero = heroManager.getEndlessHeroInfo().get(teamHeroInfo.getHeroId()); - if(hero==null){ + if (hero == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } int templateId = hero.getTemplateId(); - if(!heroManager.getHeroHandBook().containsKey(templateId)){ + if (!heroManager.getHeroHandBook().containsKey(templateId)) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } } - heroIds.forEach(heroId->set.add(heroManager.getEndlessHeroInfo().get(heroId.getHeroId()).getTemplateId())); - }else if (FourChallengeLogic.isFourChallengeTeam(teamId)){ - heroIds.forEach(heroId->{ - if(heroManager.getHeroMap().containsKey(heroId.getHeroId())){ + heroIds.forEach(heroId -> set.add(heroManager.getEndlessHeroInfo().get(heroId.getHeroId()).getTemplateId())); + } else if (FourChallengeLogic.isFourChallengeTeam(teamId)) { + heroIds.forEach(heroId -> { + if (heroManager.getHeroMap().containsKey(heroId.getHeroId())) { set.add(heroManager.getHero(heroId.getHeroId()).getTemplateId()); } HelpHero helpHero = HelpHeroLogic.getHelpHeroByHeroId(user.getId(), heroId.getHeroId()); - if (helpHero != null){ + if (helpHero != null) { set.add(helpHero.getHero().getTemplateId()); } }); - }else { - heroIds.forEach(heroId->set.add(heroManager.getHero(heroId.getHeroId()).getTemplateId())); + } else { + heroIds.forEach(heroId -> set.add(heroManager.getHero(heroId.getHeroId()).getTemplateId())); } - if(set.size()!=heroIds.size()){ + if (set.size() != heroIds.size()) { throw new ErrorCodeException(ErrorCode.NO_USE_SAME_HERO); } - String err = checkTeamPos(user, teamId,heroIds); - if(teamId != GlobalsDef.ENDLESS_TEAM&&!"".equals(err)){ + String err = checkTeamPos(user, teamId, heroIds); + if (teamId != GlobalsDef.ENDLESS_TEAM && !"".equals(err)) { throw new ErrorCodeException(ErrorCode.newDefineCode(err)); } - user.getTeamPosManager().changeTeamInfo(teamId,heroIds); + user.getTeamPosManager().changeTeamInfo(teamId, heroIds); //401图内可以更改编队 if (teamId == GlobalsDef.ENDLESS_TEAM) { List teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId); @@ -1218,44 +1230,44 @@ public class HeroLogic{ CrossServiceLogic.getInstance().dispose(user); } //跨服 玉虚论道 - if (teamId == GlobalsDef.CROSS_YU_XU_LUN_DAO_ONE||teamId == GlobalsDef.CROSS_YU_XU_LUN_DAO_TWO||teamId == GlobalsDef.CROSS_YU_XU_LUN_DAO_THREE) { + if (teamId == GlobalsDef.CROSS_YU_XU_LUN_DAO_ONE || teamId == GlobalsDef.CROSS_YU_XU_LUN_DAO_TWO || teamId == GlobalsDef.CROSS_YU_XU_LUN_DAO_THREE) { CrossServiceLogic.getInstance().saveBasicPlayerToRedis(user); } - user.getUserMissionManager().onGameEvent(user,GameEvent.HERO_IN_TEAM,heroIds.size()); - MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.TEAM_POS_SAVE_RESPONSE_VALUE,null,true); + user.getUserMissionManager().onGameEvent(user, GameEvent.HERO_IN_TEAM, heroIds.size()); + MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.TEAM_POS_SAVE_RESPONSE_VALUE, null, true); } - private String checkTeamPos(User user, int teamId,List heroIds){ - if(heroIds ==null || heroIds.isEmpty()){ + private String checkTeamPos(User user, int teamId, List heroIds) { + if (heroIds == null || heroIds.isEmpty()) { return ""; } Set cacheHeroIds = new HashSet<>(); - for(CommonProto.TeamHeroInfo teamHeroInfo: heroIds){ + for (CommonProto.TeamHeroInfo teamHeroInfo : heroIds) { String heroId = teamHeroInfo.getHeroId(); - if(teamId==GlobalsDef.EXPEDITION_TEAM){ - if(user.getHeroManager().getHero(heroId) == null&&!user.getExpeditionManager().getHeroMap().containsKey(heroId)) { + if (teamId == GlobalsDef.EXPEDITION_TEAM) { + if (user.getHeroManager().getHero(heroId) == null && !user.getExpeditionManager().getHeroMap().containsKey(heroId)) { // 卡牌不存在 return "card not exists"; } - }else if(teamId==GlobalsDef.TRIAL_TEAM){ - if(!user.getMapManager().getTrialInfo().getHeroInfo().containsKey(heroId)){ + } else if (teamId == GlobalsDef.TRIAL_TEAM) { + if (!user.getMapManager().getTrialInfo().getHeroInfo().containsKey(heroId)) { return "card not exists"; } - }else if (FourChallengeLogic.isFourChallengeTeam(teamId)){ - if(user.getHeroManager().getHero(heroId) == null&&HelpHeroLogic.getHelpHeroByHeroId(user.getId(),heroId) == null){ + } else if (FourChallengeLogic.isFourChallengeTeam(teamId)) { + if (user.getHeroManager().getHero(heroId) == null && HelpHeroLogic.getHelpHeroByHeroId(user.getId(), heroId) == null) { return "card not exists"; } - }else { - if(user.getHeroManager().getHero(heroId) == null) { + } else { + if (user.getHeroManager().getHero(heroId) == null) { // 卡牌不存在 return "card not exists"; } } // 卡牌重复 卡牌已上阵 - if(cacheHeroIds.contains(heroId)){ + if (cacheHeroIds.contains(heroId)) { return "card repeated"; } @@ -1278,98 +1290,98 @@ public class HeroLogic{ } - public void upHeroLevel(ISession session,String heroId,int targetLevel) throws Exception { + public void upHeroLevel(ISession session, String heroId, int targetLevel) throws Exception { User user = UserManager.getUser(session.getUid()); Hero hero = user.getHeroManager().getHero(heroId); - if( null == hero){ + if (null == hero) { throw new ErrorCodeException(ErrorCode.newDefineCode("hero null")); } SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId()); int[] growthSwitch = scHero.getGrowthSwitch(); - if(growthSwitch!=null&&growthSwitch.length>0){ - Set operateSet= Arrays.stream(growthSwitch).boxed().collect(Collectors.toSet()); - if(operateSet.contains(1)){ + if (growthSwitch != null && growthSwitch.length > 0) { + Set operateSet = Arrays.stream(growthSwitch).boxed().collect(Collectors.toSet()); + if (operateSet.contains(1)) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } } int oldLevel = hero.getLevel(user.getHeroManager()); //判断需要进行升级还是进行突破 - Map scHeroRankUpConfigByType = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.BREAK_TYPE,scHero.getStar()); + Map scHeroRankUpConfigByType = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.BREAK_TYPE, scHero.getStar()); SCHeroRankUpConfig scHeroRankUpConfig = null; - if(scHeroRankUpConfigByType!=null){ + if (scHeroRankUpConfigByType != null) { scHeroRankUpConfig = scHeroRankUpConfigByType.get(oldLevel); - if(scHeroRankUpConfig!=null ){ - if(hero.getStar() < scHeroRankUpConfig.getLimitStar()){ + if (scHeroRankUpConfig != null) { + if (hero.getStar() < scHeroRankUpConfig.getLimitStar()) { throw new ErrorCodeException(ErrorCode.HERO_LEVE_MAX); } } } - boolean isBreak =false; + boolean isBreak = false; int[][] consume; int breakId = hero.getBreakId(); Map consumeMap = new HashMap<>(); - if(scHeroRankUpConfig!=null && breakId!=scHeroRankUpConfig.getId()){ - isBreak =true; + if (scHeroRankUpConfig != null && breakId != scHeroRankUpConfig.getId()) { + isBreak = true; consume = scHeroRankUpConfig.getConsumeMaterial(); // combinedAttribute(consume,consumeMap); - for(int[] item : consume){ + for (int[] item : consume) { int propertyId = item[0]; int propertyValue = item[1]; - consumeMap.put(propertyId,consumeMap.getOrDefault(propertyId, 0)+propertyValue); + consumeMap.put(propertyId, consumeMap.getOrDefault(propertyId, 0) + propertyValue); } breakId = scHeroRankUpConfig.getId(); - }else{ - if(hero.getLevel(user.getHeroManager())>targetLevel){ + } else { + if (hero.getLevel(user.getHeroManager()) > targetLevel) { throw new ErrorCodeException(ErrorCode.newDefineCode("level wrong")); } - for(;oldLevel scHeroRankUpConfig.getOpenLevel()){ + if (targetLevel > scHeroRankUpConfig.getOpenLevel()) { throw new ErrorCodeException(ErrorCode.HERO_LEVE_MAX); } } //校验消耗 - boolean result = ItemUtil.itemCost(user, consumeMap,BIReason.UP_HERO_LEVEL_CONSUME,hero.getTemplateId()); - if(!result){ + boolean result = ItemUtil.itemCost(user, consumeMap, BIReason.UP_HERO_LEVEL_CONSUME, hero.getTemplateId()); + if (!result) { int heroLevel = hero.getLevel(user.getHeroManager()); - for(;oldLevel0){ - Set operateSet= Arrays.stream(growthSwitch).boxed().collect(Collectors.toSet()); - if(operateSet.contains(2)){ + if (growthSwitch != null && growthSwitch.length > 0) { + Set operateSet = Arrays.stream(growthSwitch).boxed().collect(Collectors.toSet()); + if (operateSet.contains(2)) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } } - Map scHeroRankUpConfigByType = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.UP_STAR_TYPE,scHero.getStar()); + Map scHeroRankUpConfigByType = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.UP_STAR_TYPE, scHero.getStar()); SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByType.get(oldStar); - if( targetHero.getLevel(user.getHeroManager()) < scHeroRankUpConfig.getLimitLevel()){ + if (targetHero.getLevel(user.getHeroManager()) < scHeroRankUpConfig.getLimitLevel()) { throw new ErrorCodeException(ErrorCode.HERO_LEVE_DOWN); } - Map consumeMaterialInfoByPosition = scHero.getConsumeMaterialInfoOfPositionByStar(oldStar + 1); - if(consumeMaterialInfoByPosition ==null){ + Map consumeMaterialInfoByPosition = scHero.getConsumeMaterialInfoOfPositionByStar(oldStar + 1); + if (consumeMaterialInfoByPosition == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } int needTotalHeroNums = 0; - if(consumeMaterialInfoByPosition.size()!=consumeMaterialsList.size()){ + if (consumeMaterialInfoByPosition.size() != consumeMaterialsList.size()) { throw new ErrorCodeException(ErrorCode.HERO_UN_MATCH); } //判断编队 - for(HeroInfoProto.ConsumeMaterial consumeMaterial1 : consumeMaterialsList) { + for (HeroInfoProto.ConsumeMaterial consumeMaterial1 : consumeMaterialsList) { List heroIdsList = new ArrayList<>(); consumeMaterial1.getHeroIdsList().stream() - .filter(v->v.getType() == 1) - .forEach(v->heroIdsList.add(v.getItemId())); + .filter(v -> v.getType() == 1) + .forEach(v -> heroIdsList.add(v.getItemId())); ErrorCode err = null; - if (heroIdsList.size() > 0){ + if (heroIdsList.size() > 0) { err = ItemLogic.getInstance().checkHeroResolve(heroIdsList, user); } - if(null!=err){ + if (null != err) { throw new ErrorCodeException(err); } } @@ -1442,11 +1455,11 @@ public class HeroLogic{ HashMap removeItemMap = new HashMap<>(); StringBuilder reportConsumeHero = new StringBuilder(); - for(HeroInfoProto.ConsumeMaterial consumeMaterial1 : consumeMaterialsList){ + for (HeroInfoProto.ConsumeMaterial consumeMaterial1 : consumeMaterialsList) { int position = consumeMaterial1.getPosition(); SCHero.ConsumeMaterialInfo consumeMaterialInfo = consumeMaterialInfoByPosition.get(position); int nums = consumeMaterialInfo.getNums(); - needTotalHeroNums+=nums; + needTotalHeroNums += nums; List list = consumeMaterial1.getHeroIdsList(); SHeroRankupGroup sHeroRankupGroup = STableManager.getConfig(SHeroRankupGroup.class).get(consumeMaterialInfo.getGroupID()); int isSame = sHeroRankupGroup.getIssame(); @@ -1457,42 +1470,42 @@ public class HeroLogic{ List items = Arrays.stream(sHeroRankupGroup.getItems()).boxed().collect(Collectors.toList()); // 专属道具代替 int[][] itemCamp = sHeroRankupGroup.getItemCamp(); - for(HeroInfoProto.ConsumeItem consume : list){ + for (HeroInfoProto.ConsumeItem consume : list) { // 英雄 - if (consume.getType() == 1){ + if (consume.getType() == 1) { Hero hero = heroManager.getHero(consume.getItemId()); - if( null == hero ){ + if (null == hero) { throw new ErrorCodeException(ErrorCode.HERO_UN_MATCH); } //上报消耗的英雄数据 - if(reportConsumeHero.length()>0){ + if (reportConsumeHero.length() > 0) { reportConsumeHero.append("|"); } reportConsumeHero.append(hero.getTemplateId()).append("-").append(hero.getStar()).append("-").append(hero.getLevel(user.getHeroManager())); - if( 1 == isSame) { - if(hero.getTemplateId() != targetHero.getTemplateId()){ + if (1 == isSame) { + if (hero.getTemplateId() != targetHero.getTemplateId()) { throw new ErrorCodeException(ErrorCode.HERO_UN_MATCH); } } - if( starLimit != 0 ) { - if(hero.getStar() != starLimit){ + if (starLimit != 0) { + if (hero.getStar() != starLimit) { throw new ErrorCodeException(ErrorCode.HERO_UN_MATCH); } } - if( 1 == isSameClan) { + if (1 == isSameClan) { SCHero scHeroTmp = SCHero.getsCHero().get(hero.getTemplateId()); SCHero targetSHero = SCHero.getsCHero().get(targetHero.getTemplateId()); - if( scHeroTmp.getPropertyName() != targetSHero.getPropertyName() ){ + if (scHeroTmp.getPropertyName() != targetSHero.getPropertyName()) { throw new ErrorCodeException(ErrorCode.HERO_UN_MATCH); } } - if(isId != 0) { - if(hero.getTemplateId() != isId){ + if (isId != 0) { + if (hero.getTemplateId() != isId) { throw new ErrorCodeException(ErrorCode.HERO_UN_MATCH); } } @@ -1501,52 +1514,52 @@ public class HeroLogic{ // 道具 else { int itemId = Integer.parseInt(consume.getItemId()); - if (!items.contains(itemId)){ + if (!items.contains(itemId)) { boolean camp = upStartItemCamp(scHero.getPropertyName(), itemCamp, itemId); - if (!camp){ + if (!camp) { throw new ErrorCodeException(ErrorCode.HERO_ITEM_NOT); } } Integer num = removeItemMap.getOrDefault(itemId, 0); - removeItemMap.put(itemId,num+1); + removeItemMap.put(itemId, num + 1); } } // 校验道具数量 boolean cost = ItemUtil.checkCost(user, removeItemMap); - if (!cost){ + if (!cost) { throw new ErrorCodeException(ErrorCode.HERO_ITEM_NOT); } } - if(needTotalHeroNums != (removeHeroIds.size()+removeItemMap.size())){ + if (needTotalHeroNums != (removeHeroIds.size() + removeItemMap.size())) { LOGGER.error("hero num not enough"); throw new ErrorCodeException(ErrorCode.HERO_UN_MATCH); } int[][] consumeMaterial = scHeroRankUpConfig.getConsumeMaterial(); - boolean enoughCost = ItemUtil.itemCost(user, consumeMaterial,BIReason.UP_HEROSTAR_CONSUME,targetHero.getTemplateId()); - if(!enoughCost){ + boolean enoughCost = ItemUtil.itemCost(user, consumeMaterial, BIReason.UP_HEROSTAR_CONSUME, targetHero.getTemplateId()); + if (!enoughCost) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } //改成归元获得,同时返还法宝获得 - CommonProto.Drop.Builder baseBuilder = heroBackDrop(user,new ArrayList<>(removeHeroIds),10000,BIReason.UPHERO_DECOMPOS_HERO_REWARD,true); + CommonProto.Drop.Builder baseBuilder = heroBackDrop(user, new ArrayList<>(removeHeroIds), 10000, BIReason.UPHERO_DECOMPOS_HERO_REWARD, true); // 删除英雄 - for(String rmHeroId:removeHeroIds){ - heroManager.removeHero(uid,rmHeroId); + for (String rmHeroId : removeHeroIds) { + heroManager.removeHero(uid, rmHeroId); } // 消耗道具 - ItemUtil.itemCost(user,removeItemMap,BIReason.COMPLEX_EQUIP_CONSUME,0); + ItemUtil.itemCost(user, removeItemMap, BIReason.COMPLEX_EQUIP_CONSUME, 0); rankUpHeroExecute(targetHero); - user.getHeroManager().addHeroStar(targetHero.getTemplateId(),targetHero.getStar()); - Poster.getPoster().dispatchEvent(new HeroUpStarEvent(user.getId(),targetHero.getTemplateId(),targetHero.getStar())); - Poster.getPoster().dispatchEvent(new NewWelfareEvent(user,NewWelfareTypeEnum.UPSTAR.getType(),targetHero.getTemplateId())); + user.getHeroManager().addHeroStar(targetHero.getTemplateId(), targetHero.getStar()); + Poster.getPoster().dispatchEvent(new HeroUpStarEvent(user.getId(), targetHero.getTemplateId(), targetHero.getStar())); + Poster.getPoster().dispatchEvent(new NewWelfareEvent(user, NewWelfareTypeEnum.UPSTAR.getType(), targetHero.getTemplateId())); targetHero.setStarBreakId(scHeroRankUpConfig.getId()); - user.getUserMissionManager().onGameEvent(user,GameEvent.HERO_UP,2,targetHero.getTemplateId(),targetHero.getStar()); - user.getUserMissionManager().onGameEvent(user,GameEvent.GET_HERO,targetHero.getTemplateId(),targetHero.getStar()); - if(isInTeam(user,heroId,1)){ + user.getUserMissionManager().onGameEvent(user, GameEvent.HERO_UP, 2, targetHero.getTemplateId(), targetHero.getStar()); + user.getUserMissionManager().onGameEvent(user, GameEvent.GET_HERO, targetHero.getTemplateId(), targetHero.getStar()); + if (isInTeam(user, heroId, 1)) { Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(session.getUid())); } @@ -1562,35 +1575,36 @@ public class HeroLogic{ //鸿蒙阵 addOrUpdateHongmeng(session); - MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.UP_HERO_STAR_RESPONSE_VALUE,baseBuilder.build(),true); + MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.UP_HERO_STAR_RESPONSE_VALUE, baseBuilder.build(), true); // 觉醒飘字 if (targetHero.getStar() >= SSpecialConfig.getIntegerValue(SSpecialConfig.lamp_awaken_hero_content_parm)) { String message = SErrorCodeEerverConfig.getI18NMessageNeedConvert("animal_awaken_broadcast_content", new Object[]{user.getPlayerInfoManager().getNameColor(), user.getPlayerInfoManager().getNickName(), scHero.getReadingName()}, - new int[]{0,0,1}); + new int[]{0, 0, 1}); ChatLogic.getInstance().sendSysChatMessage(message, Global.DILIGENT, String.valueOf(targetHero.getTemplateId()), 0, 0, 0, 0, 0); } else if (targetHero.getStar() >= SSpecialConfig.getIntegerValue(SSpecialConfig.lamp_rankup_hero_content_parm)) { String message = SErrorCodeEerverConfig.getI18NMessageNeedConvert("lamp_rankup_hero_content", new Object[]{user.getPlayerInfoManager().getNameColor(), user.getPlayerInfoManager().getNickName(), scHero.getReadingName(), targetHero.getStar()}, - new int[]{0,0,1,0}); - ChatLogic.getInstance().sendSysChatMessage(message, Global.DILIGENT,String.valueOf(targetHero.getTemplateId()), 0, 0, 0, 0, 0); + new int[]{0, 0, 1, 0}); + ChatLogic.getInstance().sendSysChatMessage(message, Global.DILIGENT, String.valueOf(targetHero.getTemplateId()), 0, 0, 0, 0, 0); } String consume = StringUtil.parseArrayToString(consumeMaterial); - Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.hero_star.getType(),targetHero.getStar())); - ReportUtil.onReportEvent(user, ReportEventEnum.HERO_STRENGTHEN.getType(),String.valueOf(targetHero.getTemplateId()),String.valueOf(oldStar),String.valueOf(targetHero.getStar()),consume,reportConsumeHero.toString()); + Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.hero_star.getType(), targetHero.getStar())); + ReportUtil.onReportEvent(user, ReportEventEnum.HERO_STRENGTHEN.getType(), String.valueOf(targetHero.getTemplateId()), String.valueOf(oldStar), String.valueOf(targetHero.getStar()), consume, reportConsumeHero.toString()); } /** * 升星验证同系道具 + * * @param type * @param itemCamp * @param itemId * @return */ - private boolean upStartItemCamp(int type,int[][] itemCamp,int itemId){ + private boolean upStartItemCamp(int type, int[][] itemCamp, int itemId) { for (int[] ints : itemCamp) { - if (type == ints[0] && itemId == ints[1]){ + if (type == ints[0] && itemId == ints[1]) { return true; } } @@ -1598,96 +1612,96 @@ public class HeroLogic{ } - private void rankUpHeroExecute(Hero hero)throws Exception { + private void rankUpHeroExecute(Hero hero) throws Exception { //是否解锁法宝 SGameSetting gameSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting(); int[][] equipTalismanaUnlock = gameSetting.getEquipTalismanaUnlock(); - for(int [] lockLimit:equipTalismanaUnlock){ + for (int[] lockLimit : equipTalismanaUnlock) { //英雄星级解锁 - if(lockLimit[0]==2) { + if (lockLimit[0] == 2) { if (hero.getStar() < lockLimit[1] && hero.getStar() + 1 >= lockLimit[1]) { hero.updateEspecial(1); } } } - hero.upStar( 1 ); + hero.upStar(1); } //初始属性*(1+化境增长)*等级系数 + 初始属性*突破系数 - private Map calHeroAllAttribute(User user, Hero hero,boolean isForce){ - Map result = new HashMap<>(); + private Map calHeroAllAttribute(User user, Hero hero, boolean isForce) { + Map result = new HashMap<>(); int templateId = hero.getTemplateId(); SCHero scHero = SCHero.getsCHero().get(templateId); SHeroLevlConfig sHeroLevlConfig = SHeroLevlConfig.getsCHero().get(hero.getLevel(user.getHeroManager())); int[][] characterLevelPara = sHeroLevlConfig.getCharacterLevelPara(); Map paraForHero = getParaForHero(user, hero); - Map baseValueMap = new HashMap<>(); - baseValueMap.put(GlobalsDef.HP_TYPE,getBaseValueByType(scHero,GlobalsDef.HP_TYPE)); - baseValueMap.put(GlobalsDef.ATTACK_TYPE,getBaseValueByType(scHero,GlobalsDef.ATTACK_TYPE)); - baseValueMap.put(GlobalsDef.PHYSICAL_DEFENCE_TYPE,getBaseValueByType(scHero,GlobalsDef.PHYSICAL_DEFENCE_TYPE)); - baseValueMap.put(GlobalsDef.MAGIC_DEFENCE_TYPE,getBaseValueByType(scHero,GlobalsDef.MAGIC_DEFENCE_TYPE)); - for(Map.Entry item : baseValueMap.entrySet()){ + Map baseValueMap = new HashMap<>(); + baseValueMap.put(GlobalsDef.HP_TYPE, getBaseValueByType(scHero, GlobalsDef.HP_TYPE)); + baseValueMap.put(GlobalsDef.ATTACK_TYPE, getBaseValueByType(scHero, GlobalsDef.ATTACK_TYPE)); + baseValueMap.put(GlobalsDef.PHYSICAL_DEFENCE_TYPE, getBaseValueByType(scHero, GlobalsDef.PHYSICAL_DEFENCE_TYPE)); + baseValueMap.put(GlobalsDef.MAGIC_DEFENCE_TYPE, getBaseValueByType(scHero, GlobalsDef.MAGIC_DEFENCE_TYPE)); + for (Map.Entry item : baseValueMap.entrySet()) { Integer attributeType = item.getKey(); Float heroBaseValue = item.getValue(); int[] levelAttr = Arrays.stream(characterLevelPara).filter(param -> param[0] == attributeType).findFirst().get(); float value = heroBaseValue + levelAttr[1]; int[][] rankUpParam = (int[][]) paraForHero.get(GlobalsDef.RANKUP_PARA_TYPE); - if(rankUpParam!=null){ + if (rankUpParam != null) { int[] rankAttr = Arrays.stream(rankUpParam).filter(param -> param[0] == attributeType).findFirst().get(); - value = value *(rankAttr[2] == 0 ? 1 : (rankAttr[2] / 10000.f))+rankAttr[1]; + value = value * (rankAttr[2] == 0 ? 1 : (rankAttr[2] / 10000.f)) + rankAttr[1]; } int[][] breakParam = (int[][]) paraForHero.get(GlobalsDef.BREAK_PARA_TYPE); - if(breakParam!=null){ + if (breakParam != null) { int[] breakAttr = Arrays.stream(breakParam).filter(param -> param[0] == attributeType).findFirst().get(); value += breakAttr[1]; } result.put(attributeType, (long) value); } - if(!isForce){ + if (!isForce) { Map secondaryFactorMap = scHero.getSecondaryFactorMap(); - if(secondaryFactorMap!=null && !secondaryFactorMap.isEmpty()){ - secondaryFactorMap.forEach((k,v)->result.put(k,(long)v)); + if (secondaryFactorMap != null && !secondaryFactorMap.isEmpty()) { + secondaryFactorMap.forEach((k, v) -> result.put(k, (long) v)); } } return result; } - private Map calRobotHeroAllAttribute(int templateId,int heroLevl,int heroBreakId,boolean isForce){ - Map result = new HashMap<>(); + private Map calRobotHeroAllAttribute(int templateId, int heroLevl, int heroBreakId, boolean isForce) { + Map result = new HashMap<>(); SCHero scHero = SCHero.getsCHero().get(templateId); SHeroLevlConfig sHeroLevlConfig = SHeroLevlConfig.getsCHero().get(heroLevl); int[][] characterLevelPara = sHeroLevlConfig.getCharacterLevelPara(); - Map paraForHero = getParaForRobotHero(scHero,heroLevl,templateId); - Map baseValueMap = new HashMap<>(); - baseValueMap.put(GlobalsDef.HP_TYPE,getBaseValueByType(scHero,GlobalsDef.HP_TYPE)); - baseValueMap.put(GlobalsDef.ATTACK_TYPE,getBaseValueByType(scHero,GlobalsDef.ATTACK_TYPE)); - baseValueMap.put(GlobalsDef.PHYSICAL_DEFENCE_TYPE,getBaseValueByType(scHero,GlobalsDef.PHYSICAL_DEFENCE_TYPE)); - baseValueMap.put(GlobalsDef.MAGIC_DEFENCE_TYPE,getBaseValueByType(scHero,GlobalsDef.MAGIC_DEFENCE_TYPE)); - for(Map.Entry item : baseValueMap.entrySet()){ + Map paraForHero = getParaForRobotHero(scHero, heroLevl, templateId); + Map baseValueMap = new HashMap<>(); + baseValueMap.put(GlobalsDef.HP_TYPE, getBaseValueByType(scHero, GlobalsDef.HP_TYPE)); + baseValueMap.put(GlobalsDef.ATTACK_TYPE, getBaseValueByType(scHero, GlobalsDef.ATTACK_TYPE)); + baseValueMap.put(GlobalsDef.PHYSICAL_DEFENCE_TYPE, getBaseValueByType(scHero, GlobalsDef.PHYSICAL_DEFENCE_TYPE)); + baseValueMap.put(GlobalsDef.MAGIC_DEFENCE_TYPE, getBaseValueByType(scHero, GlobalsDef.MAGIC_DEFENCE_TYPE)); + for (Map.Entry item : baseValueMap.entrySet()) { Integer attributeType = item.getKey(); Float heroBaseValue = item.getValue(); int[] levelAttr = Arrays.stream(characterLevelPara).filter(param -> param[0] == attributeType).findFirst().get(); float value = heroBaseValue + levelAttr[1]; int[][] rankUpParam = (int[][]) paraForHero.get(GlobalsDef.RANKUP_PARA_TYPE); - if(rankUpParam!=null){ + if (rankUpParam != null) { int[] rankAttr = Arrays.stream(rankUpParam).filter(param -> param[0] == attributeType).findFirst().get(); - value *= rankAttr[1] == 0 ? 1 : rankAttr[1] / 10000.f+rankAttr[2]; + value *= rankAttr[1] == 0 ? 1 : rankAttr[1] / 10000.f + rankAttr[2]; } int[][] breakParam = (int[][]) paraForHero.get(GlobalsDef.BREAK_PARA_TYPE); - if(breakParam!=null){ + if (breakParam != null) { int[] breakAttr = Arrays.stream(breakParam).filter(param -> param[0] == attributeType).findFirst().get(); value += breakAttr[1]; } result.put(attributeType, (long) value); } - if(!isForce){ + if (!isForce) { Map secondaryFactorMap = scHero.getSecondaryFactorMap(); - if(secondaryFactorMap!=null && !secondaryFactorMap.isEmpty()){ - secondaryFactorMap.forEach((k,v)->result.put(k,(long)v)); + if (secondaryFactorMap != null && !secondaryFactorMap.isEmpty()) { + secondaryFactorMap.forEach((k, v) -> result.put(k, (long) v)); } } return result; @@ -1695,30 +1709,31 @@ public class HeroLogic{ /** * 根据英雄等级计算出starBreaklId + * * @param heroTid * @param heroLevel * @return */ - public int calRobotStarBreakByLevel(int heroTid,int heroLevel){ + public int calRobotStarBreakByLevel(int heroTid, int heroLevel) { // 获取进阶属性 int star = SCHero.getsCHero().get(heroTid).getStar(); - Map byStar = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.UP_STAR_TYPE,star); - if(byStar != null){ + Map byStar = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.UP_STAR_TYPE, star); + if (byStar != null) { // 换个对象,尽量不要修改原值 List rankUpConfigs = new ArrayList<>(byStar.values()); // 聚合::根据openlevel倒序,输出list List collect = rankUpConfigs.stream().sorted(Comparator.comparing(SCHeroRankUpConfig::getOpenLevel).reversed()).collect(Collectors.toList()); - for(SCHeroRankUpConfig scHeroRankUpConfig : collect){ - if (heroLevel == scHeroRankUpConfig.getOpenLevel()){ - if (scHeroRankUpConfig.getOpenStar() > 10){ + for (SCHeroRankUpConfig scHeroRankUpConfig : collect) { + if (heroLevel == scHeroRankUpConfig.getOpenLevel()) { + if (scHeroRankUpConfig.getOpenStar() > 10) { continue; } return scHeroRankUpConfig.getId(); - }else if (heroLevel > scHeroRankUpConfig.getOpenLevel()){ - if (scHeroRankUpConfig.getOpenStar() > 10){ + } else if (heroLevel > scHeroRankUpConfig.getOpenLevel()) { + if (scHeroRankUpConfig.getOpenStar() > 10) { continue; } - return scHeroRankUpConfig.getId()+1; + return scHeroRankUpConfig.getId() + 1; } } } @@ -1728,20 +1743,21 @@ public class HeroLogic{ /** * 根据英雄等级计算出BreaklId + * * @param heroTid * @param heroLevel * @return */ - public int calRobotBreakByLevel(int heroTid,int heroLevel){ + public int calRobotBreakByLevel(int heroTid, int heroLevel) { // 初始等级 int star = SCHero.getsCHero().get(heroTid).getStar(); - Map byBreak = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.BREAK_TYPE,star); - if(byBreak != null){ + Map byBreak = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.BREAK_TYPE, star); + if (byBreak != null) { List rankUpConfigs = new ArrayList<>(byBreak.values()); // 聚合:根据openlevel倒叙排序,输出成list List collect = rankUpConfigs.stream().sorted(Comparator.comparing(SCHeroRankUpConfig::getOpenLevel).reversed()).collect(Collectors.toList()); - for(SCHeroRankUpConfig scHeroRankUpConfig : collect){ - if (heroLevel > scHeroRankUpConfig.getLimitLevel()){ + for (SCHeroRankUpConfig scHeroRankUpConfig : collect) { + if (heroLevel > scHeroRankUpConfig.getLimitLevel()) { return scHeroRankUpConfig.getId(); } } @@ -1751,41 +1767,42 @@ public class HeroLogic{ /** * 根据等级计算英雄星级 + * * @param heroTid * @param heroLevel * @return */ - public int calRobotStarByLevel(int heroTid,int heroLevel){ + public int calRobotStarByLevel(int heroTid, int heroLevel) { SCHero scHero = SCHero.getsCHero().get(heroTid); // 英雄初始星级 int star = scHero.getStar(); // 进阶,根据初始星级获取不同分区,先进行进阶验证,再进行突破验证 - Map byStar = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.UP_STAR_TYPE,star); - if (byStar != null){ + Map byStar = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.UP_STAR_TYPE, star); + if (byStar != null) { // 换个对象,尽量不要修改原值 List rankUpStar = new ArrayList<>(byStar.values()); // 聚合::根据openlevel倒序,输出list List collect = rankUpStar.stream().sorted(Comparator.comparing(SCHeroRankUpConfig::getOpenLevel).reversed()).collect(Collectors.toList()); - for(SCHeroRankUpConfig val : collect){ - if (heroLevel > val.getOpenLevel()){ + for (SCHeroRankUpConfig val : collect) { + if (heroLevel > val.getOpenLevel()) { // 计算星级需要+1操作 - int result = val.getOpenStar()+1; + int result = val.getOpenStar() + 1; // 机器人生成星级,最高10星 - return result>10?10:result; + return result > 10 ? 10 : result; } } } // 突破,根据初始星级获取不同分区 - Map byBreak = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.BREAK_TYPE,star); - if (byBreak != null){ + Map byBreak = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.BREAK_TYPE, star); + if (byBreak != null) { List rankUpBreak = new ArrayList<>(byBreak.values()); // 聚合:根据openlevel倒叙排序,输出成list List collect = rankUpBreak.stream().sorted(Comparator.comparing(SCHeroRankUpConfig::getOpenLevel).reversed()).collect(Collectors.toList()); - for(SCHeroRankUpConfig val : collect){ - if (heroLevel > val.getLimitLevel()){ - return val.getOpenStar()>10?10:val.getOpenStar(); + for (SCHeroRankUpConfig val : collect) { + if (heroLevel > val.getLimitLevel()) { + return val.getOpenStar() > 10 ? 10 : val.getOpenStar(); } } } @@ -1793,52 +1810,52 @@ public class HeroLogic{ return star; } - private Map getParaRate(SCHero scHero,int heroStar,int heroLevel,int heroBreakId){ - Map result = new HashMap<>(2); - Object rankupPara=null; + private Map getParaRate(SCHero scHero, int heroStar, int heroLevel, int heroBreakId) { + Map result = new HashMap<>(2); + Object rankupPara = null; //突破系数 - Object breakPara=null; - Map scHeroRankUpConfigByTypeOfStar = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByType(GlobalsDef.UP_STAR_TYPE,scHero.getStar()); - if(scHeroRankUpConfigByTypeOfStar!= null){ - SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByTypeOfStar.get(heroStar-1); - if( scHeroRankUpConfig!=null && heroLevel >= scHeroRankUpConfig.getLimitLevel()){ - if(scHeroRankUpConfig.getType() == GlobalsDef.BREAK_TYPE){ + Object breakPara = null; + Map scHeroRankUpConfigByTypeOfStar = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByType(GlobalsDef.UP_STAR_TYPE, scHero.getStar()); + if (scHeroRankUpConfigByTypeOfStar != null) { + SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByTypeOfStar.get(heroStar - 1); + if (scHeroRankUpConfig != null && heroLevel >= scHeroRankUpConfig.getLimitLevel()) { + if (scHeroRankUpConfig.getType() == GlobalsDef.BREAK_TYPE) { breakPara = scHeroRankUpConfig.getRankupPara(); - }else{ + } else { rankupPara = scHeroRankUpConfig.getRankupPara(); } } } - Map scHeroRankUpConfigByTypOfBreak = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByType(GlobalsDef.BREAK_TYPE,scHero.getStar()); - for( SCHeroRankUpConfig scHeroRankUpConfigTmp :scHeroRankUpConfigByTypOfBreak.values()){ + Map scHeroRankUpConfigByTypOfBreak = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByType(GlobalsDef.BREAK_TYPE, scHero.getStar()); + for (SCHeroRankUpConfig scHeroRankUpConfigTmp : scHeroRankUpConfigByTypOfBreak.values()) { // && breakPara< scHeroRankUpConfigTmp.getRankupPara() - if( heroLevel >= scHeroRankUpConfigTmp.getLimitLevel() && heroBreakId>= scHeroRankUpConfigTmp.getId() ){ + if (heroLevel >= scHeroRankUpConfigTmp.getLimitLevel() && heroBreakId >= scHeroRankUpConfigTmp.getId()) { breakPara = scHeroRankUpConfigTmp.getRankupPara(); } - if(heroLevel < scHeroRankUpConfigTmp.getOpenLevel()){ + if (heroLevel < scHeroRankUpConfigTmp.getOpenLevel()) { break; } } - result.put(GlobalsDef.RANKUP_PARA_TYPE,rankupPara); - result.put(GlobalsDef.BREAK_PARA_TYPE,breakPara); + result.put(GlobalsDef.RANKUP_PARA_TYPE, rankupPara); + result.put(GlobalsDef.BREAK_PARA_TYPE, breakPara); return result; } - private Map getParaForHero(User user, Hero hero){ + private Map getParaForHero(User user, Hero hero) { SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId()); return getParaRate(scHero, hero.getStar(), hero.getLevel(user.getHeroManager()), hero.getBreakIdByHongMeng(user.getHeroManager())); } //todo - private Map getParaForRobotHero(SCHero scHero,int level,int breakId){ - return getParaRate(scHero, scHero.getStar(),level, breakId); + private Map getParaForRobotHero(SCHero scHero, int level, int breakId) { + return getParaRate(scHero, scHero.getStar(), level, breakId); } - private float getBaseValueByType(SCHero scHero,int type){ + private float getBaseValueByType(SCHero scHero, int type) { float result = 0.0f; - switch (type){ + switch (type) { case GlobalsDef.HP_TYPE: result = scHero.getHp(); break; @@ -1854,18 +1871,18 @@ public class HeroLogic{ case GlobalsDef.SPEED_TYPE: result = scHero.getSpeed(); break; - default: - break; + default: + break; } return result; } - public List getHeroSkillList(User user,Hero hero){ + public List getHeroSkillList(User user, Hero hero) { List skillList = new ArrayList<>(); SCHero tempHero = SCHero.getsCHero().get(hero.getTemplateId()); List skillListByStar = tempHero.getSkillListByStar(hero.getStar()); - if(skillListByStar!=null){ + if (skillListByStar != null) { skillList.addAll(skillListByStar); } // 大于10星,觉醒技 @@ -1880,18 +1897,18 @@ public class HeroLogic{ //魂印 Map soulEquipByPositionMap = hero.getSoulEquipByPositionMap(); Map config = STableManager.getConfig(SEquipConfig.class); - soulEquipByPositionMap.values().forEach(e->{ + soulEquipByPositionMap.values().forEach(e -> { Arrays.stream(config.get(e).getPassiveSkill()).forEach(skillList::add); }); //法宝技能 int[] equipTalismana = tempHero.getEquipTalismana(); - if(equipTalismana.length >= 2 && hero.getStar() >= equipTalismana[0]){ - int especialEquipLevel = hero.getEspecialEquipLevelByHongmeng(user.getHeroManager(),hero.getId()); + if (equipTalismana.length >= 2 && hero.getStar() >= equipTalismana[0]) { + int especialEquipLevel = hero.getEspecialEquipLevelByHongmeng(user.getHeroManager(), hero.getId()); int especialEquipId = equipTalismana[1]; - Map sEquipTalismana = SEquipTalismana.equipTalismanaStarMap.get(especialEquipId); - sEquipTalismana.forEach((k,v)->{ - if(k<=especialEquipLevel&&v.getOpenSkillRules()!=null){ + Map sEquipTalismana = SEquipTalismana.equipTalismanaStarMap.get(especialEquipId); + sEquipTalismana.forEach((k, v) -> { + if (k <= especialEquipLevel && v.getOpenSkillRules() != null) { Arrays.stream(v.getOpenSkillRules()).forEach(skillList::add); } }); @@ -1899,18 +1916,18 @@ public class HeroLogic{ // 紫府神印技能 Collection seals = user.getHeroManager().getPurpleMansionSeal().values(); - seals.forEach(v->{ + seals.forEach(v -> { // 使用中神印 - if (v.getState() == 1){ + if (v.getState() == 1) { // 附身神印 - if (v.getType() == 1){ - if (v.getSubId().equals(hero.getId())){ - getPurpleMansionSealSkill(v.getSealId(),tempHero,skillList); + if (v.getType() == 1) { + if (v.getSubId().equals(hero.getId())) { + getPurpleMansionSealSkill(v.getSealId(), tempHero, skillList); } } // 通用神印 else { - getPurpleMansionSealSkill(v.getSealId(),tempHero,skillList); + getPurpleMansionSealSkill(v.getSealId(), tempHero, skillList); } } }); @@ -1919,11 +1936,11 @@ public class HeroLogic{ } - public StringBuilder getCrossHeroSkillStr(ArenaOfUser user, ArenaOfHero hero){ + public StringBuilder getCrossHeroSkillStr(ArenaOfUser user, ArenaOfHero hero) { List skillList = new ArrayList<>(); SCHero tempHero = SCHero.getsCHero().get(hero.getTemplateId()); List skillListByStar = tempHero.getSkillListByStar(hero.getStar()); - if(skillListByStar!=null){ + if (skillListByStar != null) { skillList.addAll(skillListByStar); } // 大于10星,觉醒技 @@ -1938,51 +1955,51 @@ public class HeroLogic{ //魂印 Map soulEquipByPositionMap = hero.getSoulEquipByPositionMap(); Map config = STableManager.getConfig(SEquipConfig.class); - soulEquipByPositionMap.values().forEach(e->{ + soulEquipByPositionMap.values().forEach(e -> { Arrays.stream(config.get(e).getPassiveSkill()).forEach(skillList::add); }); //法宝技能 int[] equipTalismana = tempHero.getEquipTalismana(); - if(equipTalismana.length>=1 &&hero.getStar()>=equipTalismana[0]){ + if (equipTalismana.length >= 1 && hero.getStar() >= equipTalismana[0]) { int especialEquipLevel = hero.getEspecialEquipLevel(); int especialEquipId = equipTalismana[1]; - Map sEquipTalismana = SEquipTalismana.equipTalismanaStarMap.get(especialEquipId); - sEquipTalismana.forEach((k,v)->{ - if(k<=especialEquipLevel&&v.getOpenSkillRules()!=null){ - Arrays.stream(v.getOpenSkillRules()).forEach(i->skillList.add(i)); + Map sEquipTalismana = SEquipTalismana.equipTalismanaStarMap.get(especialEquipId); + sEquipTalismana.forEach((k, v) -> { + if (k <= especialEquipLevel && v.getOpenSkillRules() != null) { + Arrays.stream(v.getOpenSkillRules()).forEach(i -> skillList.add(i)); } }); } // 紫府神印技能 Collection seals = user.getSeals().values(); - seals.forEach(v->{ + seals.forEach(v -> { // 使用中神印 - if (v.getState() == 1){ + if (v.getState() == 1) { // 附身神印 - if (v.getType() == 1){ - if (v.getSubId().equals(hero.getId())){ - getPurpleMansionSealSkill(v.getSealId(),tempHero,skillList); + if (v.getType() == 1) { + if (v.getSubId().equals(hero.getId())) { + getPurpleMansionSealSkill(v.getSealId(), tempHero, skillList); } } // 通用神印 else { - getPurpleMansionSealSkill(v.getSealId(),tempHero,skillList); + getPurpleMansionSealSkill(v.getSealId(), tempHero, skillList); } } }); StringBuilder sb = new StringBuilder(); coverSkill(skillList); - for(int i=0;i skillList = new ArrayList<>(); SCHero tempHero = SCHero.getsCHero().get(hero.getTemplateId()); List skillListByStar = tempHero.getSkillListByStar(hero.getStar()); - if(skillListByStar!=null){ + if (skillListByStar != null) { skillList.addAll(skillListByStar); } // 大于10星,觉醒技 @@ -2011,63 +2028,64 @@ public class HeroLogic{ //魂印 Map soulEquipByPositionMap = hero.getSoulEquipByPositionMap(); Map config = STableManager.getConfig(SEquipConfig.class); - soulEquipByPositionMap.values().forEach(e->{ + soulEquipByPositionMap.values().forEach(e -> { Arrays.stream(config.get(e).getPassiveSkill()).forEach(skillList::add); }); //法宝技能 int[] equipTalismana = tempHero.getEquipTalismana(); - if(equipTalismana.length>=1 &&hero.getStar()>=equipTalismana[0]){ + if (equipTalismana.length >= 1 && hero.getStar() >= equipTalismana[0]) { int especialEquipLevel = hero.getEspecialEquipLevel(); int especialEquipId = equipTalismana[1]; - Map sEquipTalismana = SEquipTalismana.equipTalismanaStarMap.get(especialEquipId); - sEquipTalismana.forEach((k,v)->{ - if(k<=especialEquipLevel&&v.getOpenSkillRules()!=null){ - Arrays.stream(v.getOpenSkillRules()).forEach(i->skillList.add(i)); + Map sEquipTalismana = SEquipTalismana.equipTalismanaStarMap.get(especialEquipId); + sEquipTalismana.forEach((k, v) -> { + if (k <= especialEquipLevel && v.getOpenSkillRules() != null) { + Arrays.stream(v.getOpenSkillRules()).forEach(i -> skillList.add(i)); } }); } // 紫府神印技能 - Collection seals = user.getHeroManager().getPurpleMansionSeal().values(); - seals.forEach(v->{ + Collection seals = user.getHeroManager().getPurpleMansionSeal().values(); + seals.forEach(v -> { // 使用中神印 - if (v.getState() == 1){ + if (v.getState() == 1) { // 附身神印 - if (v.getType() == 1){ - if (v.getSubId().equals(hero.getId())){ - getPurpleMansionSealSkill(v.getSealId(),tempHero,skillList); + if (v.getType() == 1) { + if (v.getSubId().equals(hero.getId())) { + getPurpleMansionSealSkill(v.getSealId(), tempHero, skillList); } } // 通用神印 else { - getPurpleMansionSealSkill(v.getSealId(),tempHero,skillList); + getPurpleMansionSealSkill(v.getSealId(), tempHero, skillList); } } }); StringBuilder sb = new StringBuilder(); coverSkill(skillList); - for(int i=0;i skillList = new ArrayList<>(); SCHero tempHero = SCHero.getsCHero().get(hero.getTemplateId()); List skillListByStar = tempHero.getSkillListByStar(hero.getStar()); - if(skillListByStar!=null){ + if (skillListByStar != null) { skillList.addAll(skillListByStar); } // 大于10星,觉醒技 @@ -2082,19 +2100,19 @@ public class HeroLogic{ //魂印 Map soulEquipByPositionMap = hero.getSoulEquipByPositionMap(); Map config = STableManager.getConfig(SEquipConfig.class); - soulEquipByPositionMap.values().forEach(e->{ + soulEquipByPositionMap.values().forEach(e -> { Arrays.stream(config.get(e).getPassiveSkill()).forEach(skillList::add); }); //法宝技能 int[] equipTalismana = tempHero.getEquipTalismana(); - if(equipTalismana.length>=1 &&hero.getStar()>=equipTalismana[0]){ + if (equipTalismana.length >= 1 && hero.getStar() >= equipTalismana[0]) { int especialEquipLevel = hero.getEspecialEquipLevel(); int especialEquipId = equipTalismana[1]; - Map sEquipTalismana = SEquipTalismana.equipTalismanaStarMap.get(especialEquipId); - sEquipTalismana.forEach((k,v)->{ - if(k<=especialEquipLevel&&v.getOpenSkillRules()!=null){ - Arrays.stream(v.getOpenSkillRules()).forEach(i->skillList.add(i)); + Map sEquipTalismana = SEquipTalismana.equipTalismanaStarMap.get(especialEquipId); + sEquipTalismana.forEach((k, v) -> { + if (k <= especialEquipLevel && v.getOpenSkillRules() != null) { + Arrays.stream(v.getOpenSkillRules()).forEach(i -> skillList.add(i)); } }); } @@ -2102,28 +2120,28 @@ public class HeroLogic{ // 紫府神印技能 //Collection seals = user.getHeroManager().getPurpleMansionSeal().values(); Collection seals = crossArenaManager.getSeals().values(); - seals.forEach(v->{ + seals.forEach(v -> { // 使用中神印 - if (v.getState() == 1){ + if (v.getState() == 1) { // 附身神印 - if (v.getType() == 1){ - if (v.getSubId().equals(hero.getId())){ - getPurpleMansionSealSkill(v.getSealId(),tempHero,skillList); + if (v.getType() == 1) { + if (v.getSubId().equals(hero.getId())) { + getPurpleMansionSealSkill(v.getSealId(), tempHero, skillList); } } // 通用神印 else { - getPurpleMansionSealSkill(v.getSealId(),tempHero,skillList); + getPurpleMansionSealSkill(v.getSealId(), tempHero, skillList); } } }); // 坐骑技能 - for(int skill : crossArenaManager.getSkill()){ - if(!SPlayerHeadIcon.getHeadIconMap().containsKey(skill)){ + for (int skill : crossArenaManager.getSkill()) { + if (!SPlayerHeadIcon.getHeadIconMap().containsKey(skill)) { continue; } SPlayerHeadIcon sPlayerHeadIcon = SPlayerHeadIcon.getHeadIconMap().get(skill); - if (sPlayerHeadIcon.getSkill() == null || sPlayerHeadIcon.getSkill().length <= 0){ + if (sPlayerHeadIcon.getSkill() == null || sPlayerHeadIcon.getSkill().length <= 0) { continue; } skillList.add(sPlayerHeadIcon.getSkill()[0][0]); @@ -2133,7 +2151,7 @@ public class HeroLogic{ Iterator> iterator = hero.getEquipByPositionMap().entrySet().iterator(); // 套装list初始化 ArrayList suiteNumList = new ArrayList<>(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { Map.Entry next = iterator.next(); SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(next.getValue()); // 添加到套装list @@ -2142,36 +2160,36 @@ public class HeroLogic{ Collections.sort(suiteNumList); // 记录当前长度(位置) int num = suiteNumList.size(); - if (!suiteNumList.isEmpty()){ + if (!suiteNumList.isEmpty()) { // 遍历套装list for (SEquipConfig item : suiteNumList) { //根据星级读取配置表,为空表示不是套装 - SEquipSuiteConfig sEquipSuiteConfig =SEquipSuiteConfig.config.get(item.getStar()); - if (null != sEquipSuiteConfig){ + SEquipSuiteConfig sEquipSuiteConfig = SEquipSuiteConfig.config.get(item.getStar()); + if (null != sEquipSuiteConfig) { // 根据套装数量读表,为空标是套装数量不足 Integer integer = sEquipSuiteConfig.getSuiteSkills().get(num); if (integer == null) { - num-=1; + num -= 1; continue; } skillList.add(integer); //sb.append(integer).append(DIVISION); } // 不管是否是套装,都要-1 - num-=1; + num -= 1; } } StringBuilder sb = new StringBuilder(); coverSkill(skillList); - for(int i=0;i skillList){ + private void getPurpleMansionSealSkill(int sealId, SCHero tempHero, List skillList) { SXiuXianSkill xianSkill = STableManager.getConfig(SXiuXianSkill.class).get(sealId); // 技能数组转list int skillId = xianSkill.getSkillId(); - if (skillId <= 0){ + if (skillId <= 0) { return; } // 适用范围 int[] fitList = xianSkill.getFitList(); - switch (fitList[0]){ + switch (fitList[0]) { case 0: // 不限 skillList.add(skillId); break; case 1: // 阵营限制 - if (tempHero.getPropertyName() == fitList[1]){ + if (tempHero.getPropertyName() == fitList[1]) { skillList.add(skillId); } break; case 2: // 职业限制 - if (tempHero.getProfession() == fitList[1]){ + if (tempHero.getProfession() == fitList[1]) { skillList.add(skillId); } break; @@ -2216,35 +2235,35 @@ public class HeroLogic{ } } - public void coverSkill(List heroSkillList){ + public void coverSkill(List heroSkillList) { Set coverSkillIds = new HashSet<>(); - heroSkillList.forEach(skill->{ + heroSkillList.forEach(skill -> { SPassiveSkillLogicConfig config = SPassiveSkillLogicConfig.getConfig(skill); - if(config!=null &&config.getCoverID()!=0){ + if (config != null && config.getCoverID() != 0) { coverSkillIds.add(config.getCoverID()); } }); heroSkillList.removeAll(coverSkillIds); } - public StringBuilder getHeroSkills(User user,Hero hero, StringBuilder sb){ + public StringBuilder getHeroSkills(User user, Hero hero, StringBuilder sb) { List heroSkillList = getHeroSkillList(user, hero); coverSkill(heroSkillList); - for(int i=0;i> iterator = hero.getEquipByHongmengPositionMap(user.getHeroManager()).entrySet().iterator(); // 套装list初始化 ArrayList suiteNumList = new ArrayList<>(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { Map.Entry next = iterator.next(); SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(next.getValue()); // 添加到套装list @@ -2253,31 +2272,31 @@ public class HeroLogic{ Collections.sort(suiteNumList); // 记录当前长度(位置) int num = suiteNumList.size(); - if (!suiteNumList.isEmpty()){ + if (!suiteNumList.isEmpty()) { // 遍历套装list for (SEquipConfig item : suiteNumList) { //根据星级读取配置表,为空表示不是套装 - SEquipSuiteConfig sEquipSuiteConfig =SEquipSuiteConfig.config.get(item.getStar()); - if (null != sEquipSuiteConfig){ + SEquipSuiteConfig sEquipSuiteConfig = SEquipSuiteConfig.config.get(item.getStar()); + if (null != sEquipSuiteConfig) { // 根据套装数量读表,为空标是套装数量不足 Integer integer = sEquipSuiteConfig.getSuiteSkills().get(num); if (integer == null) { - num-=1; + num -= 1; continue; } sb.append(integer).append(DIVISION); } // 不管是否是套装,都要-1 - num-=1; + num -= 1; } } // 坐骑技能 - for(Map.Entry entry : user.getPlayerInfoManager().getUserMountValidTime().entrySet()){ - if(!SPlayerHeadIcon.getHeadIconMap().containsKey(entry.getKey())){ + for (Map.Entry entry : user.getPlayerInfoManager().getUserMountValidTime().entrySet()) { + if (!SPlayerHeadIcon.getHeadIconMap().containsKey(entry.getKey())) { continue; } SPlayerHeadIcon sPlayerHeadIcon = SPlayerHeadIcon.getHeadIconMap().get(entry.getKey()); - if (sPlayerHeadIcon.getSkill() == null || sPlayerHeadIcon.getSkill().length <= 0){ + if (sPlayerHeadIcon.getSkill() == null || sPlayerHeadIcon.getSkill().length <= 0) { continue; } sb.append(sPlayerHeadIcon.getSkill()[0][0]).append(DIVISION); @@ -2285,34 +2304,34 @@ public class HeroLogic{ return sb; } - public StringBuilder getHeroProperty(User user, Hero hero, StringBuilder sb,boolean isMySelf,int teamId){ + public StringBuilder getHeroProperty(User user, Hero hero, StringBuilder sb, boolean isMySelf, int teamId) { int curMapId = user.getMapManager().getCurMapId(); Map heroAttributeMap; - if(!isMySelf || curMapId == 0 || (teamId!=GlobalsDef.TRIAL_TEAM&&teamId!=GlobalsDef.ENDLESS_TEAM)){ - heroAttributeMap=calHeroNotBufferAttribute(user, hero,false,teamId); - }else { - heroAttributeMap=calHeroFinalAttributeWhenInMap(user, hero,false,teamId); + if (!isMySelf || curMapId == 0 || (teamId != GlobalsDef.TRIAL_TEAM && teamId != GlobalsDef.ENDLESS_TEAM)) { + heroAttributeMap = calHeroNotBufferAttribute(user, hero, false, teamId); + } else { + heroAttributeMap = calHeroFinalAttributeWhenInMap(user, hero, false, teamId); } - return getHeroPropertyBuilder(sb,hero.getTemplateId(),hero.getLevel(user.getHeroManager()),heroAttributeMap); + return getHeroPropertyBuilder(sb, hero.getTemplateId(), hero.getLevel(user.getHeroManager()), heroAttributeMap); } - public StringBuilder getHeroPropertyBuilder(StringBuilder sb,int tempId,int heroLevel,Map heroAttributeMap){ + public StringBuilder getHeroPropertyBuilder(StringBuilder sb, int tempId, int heroLevel, Map heroAttributeMap) { sb.append(heroLevel).append(DIVISION); SCHero scHero = SCHero.getsCHero().get(tempId); List templatePropetyIds = transTemplateByHeroPropertyName.get(scHero.getPropertyName()); - for(Integer templatePropetyId:templatePropetyIds){ + for (Integer templatePropetyId : templatePropetyIds) { Long propertyValue = heroAttributeMap.get(templatePropetyId); - if(propertyValue == null){ + if (propertyValue == null) { propertyValue = 0L; } SPropertyConfig sPropertyConfig = SPropertyConfig.getsPropertyConfigByPID(templatePropetyId); - if(sPropertyConfig.getIfFormula() == 1){ - sb.append(propertyValue/(heroLevel+10)/100).append(DIVISION); - }else{ - if(sPropertyConfig.getStyle() == GlobalsDef.PERCENT_TYPE){ - sb.append(propertyValue/10000f).append(DIVISION); + if (sPropertyConfig.getIfFormula() == 1) { + sb.append(propertyValue / (heroLevel + 10) / 100).append(DIVISION); + } else { + if (sPropertyConfig.getStyle() == GlobalsDef.PERCENT_TYPE) { + sb.append(propertyValue / 10000f).append(DIVISION); - }else{ + } else { sb.append(propertyValue).append(DIVISION); } } @@ -2321,28 +2340,28 @@ public class HeroLogic{ return sb; } - public StringBuilder getHeroPropertyBuilder(StringBuilder sb, FamilyHeroInfo hero, Map heroAttributeMap){ + public StringBuilder getHeroPropertyBuilder(StringBuilder sb, FamilyHeroInfo hero, Map heroAttributeMap) { return getHeroPropertyBuilder(sb, hero.getTempleteId(), hero.getLevel(), heroAttributeMap); } - public StringBuilder getRobotHeroProperty(SArenaRobotConfig sArenaRobotConfig,SCHero scHero, StringBuilder sb,Map robotHeroAttribute){ + public StringBuilder getRobotHeroProperty(SArenaRobotConfig sArenaRobotConfig, SCHero scHero, StringBuilder sb, Map robotHeroAttribute) { int robotLevel = sArenaRobotConfig.getRoleLv(); sb.append(robotLevel).append(DIVISION); List templatePropetyIds = transTemplateByHeroPropertyName.get(scHero.getPropertyName()); - for(Integer templatePropetyId:templatePropetyIds){ + for (Integer templatePropetyId : templatePropetyIds) { Long propertyValue = robotHeroAttribute.get(templatePropetyId); - if(propertyValue == null){ + if (propertyValue == null) { propertyValue = 0L; } SPropertyConfig sPropertyConfig = SPropertyConfig.getsPropertyConfigByPID(templatePropetyId); - if(sPropertyConfig.getIfFormula() == 1){ - sb.append(propertyValue*0.1/(sArenaRobotConfig.getRoleLv()+10)/100).append(DIVISION); - }else{ - if(sPropertyConfig.getStyle() == GlobalsDef.PERCENT_TYPE){ - sb.append(propertyValue/10000f).append(DIVISION); - }else{ + if (sPropertyConfig.getIfFormula() == 1) { + sb.append(propertyValue * 0.1 / (sArenaRobotConfig.getRoleLv() + 10) / 100).append(DIVISION); + } else { + if (sPropertyConfig.getStyle() == GlobalsDef.PERCENT_TYPE) { + sb.append(propertyValue / 10000f).append(DIVISION); + } else { sb.append(propertyValue).append(DIVISION); } } @@ -2351,7 +2370,33 @@ public class HeroLogic{ return sb; } - public List getPokemonSkills(User user){ + ///获取修行技能数据 + public void getPracticeSkill(List infoList, Map practiceSkillMap,long maxForce) { + if (practiceSkillMap.isEmpty()) { + return; + } + StringBuilder skillStr = new StringBuilder(); + for (Map.Entry entry : practiceSkillMap.entrySet()) { + int skillId = SPlayerSkill.GetSPlayerSkill(entry.getKey(), entry.getValue()).getId(); + if (skillStr.toString().isEmpty()) { + skillStr.append(skillId); + } else { + skillStr.append("#").append(skillId); + } + } + CommonProto.FightUnitInfo skillInfo = CommonProto.FightUnitInfo + .newBuilder() + .setUnitId("0") + .setUnitSkillIds(skillStr.toString()) + .setProperty("0") + .setPosition(100) + .setSkinId(0) + .setForceScore(maxForce) + .build(); + infoList.add(skillInfo); + } + + public List getPokemonSkills(User user) { //todo 灵兽 Map pokemonTeamMap = user.getPokemonManager().getPokemonTeamMap(); PokemonManager pokemonManager = user.getPokemonManager(); @@ -2368,15 +2413,15 @@ public class HeroLogic{ // } // } List pokemonInfos = new ArrayList<>(); - for(Map.Entry entry:pokemonTeamMap.entrySet()){ + for (Map.Entry entry : pokemonTeamMap.entrySet()) { Pokemon pokemon = pokemonManager.getPokemonMap().get(entry.getValue()); - if(pokemon==null){ + if (pokemon == null) { continue; } SSpiritAnimalSkill sSpiritAnimalSkill = SSpiritAnimalSkill.skillByAnimalAndStar.get(pokemon.getTmpId()).get(pokemon.getStar()); Map map = calOnePokemonAttribute(pokemonManager, entry.getValue()); - StringBuilder propertyBuilder = getOnePokemonProperty(map,pokemon.getLevel()); + StringBuilder propertyBuilder = getOnePokemonProperty(map, pokemon.getLevel()); CommonProto.FightUnitInfo info = CommonProto.FightUnitInfo.newBuilder() .setPosition(entry.getKey()) .setStar(pokemon.getStar()) @@ -2386,40 +2431,23 @@ public class HeroLogic{ .build(); pokemonInfos.add(info); } - String skillStr=""; - for (Map.Entry entry : user.getHeroManager().getPracticeSkillMap().entrySet()) { - int skillId=SPlayerSkill.GetSPlayerSkill(entry.getKey(),entry.getValue()).getId(); - if (skillStr.isEmpty()){ - skillStr+= skillId; - }else{ - skillStr+= "#"+skillId; - } - } - CommonProto.FightUnitInfo skillInfo = CommonProto.FightUnitInfo - .newBuilder() - .setUnitId("0") - .setUnitSkillIds(skillStr) - .setProperty("0") - .setPosition(100) - .setSkinId(0) - .build(); - pokemonInfos.add(skillInfo); + getPracticeSkill(pokemonInfos, user.getHeroManager().getPracticeSkillMap(),user.getPlayerInfoManager().getMaxForce()); return pokemonInfos; } - public List getCrossPokemonSkills(ArenaOfUser user){ + public List getCrossPokemonSkills(ArenaOfUser user) { //todo 灵兽 Map pokemons = user.getPokemons(); List pokemonInfos = new ArrayList<>(); - for(Map.Entry entry:pokemons.entrySet()){ + for (Map.Entry entry : pokemons.entrySet()) { Pokemon pokemon = entry.getValue(); - if(pokemon==null){ + if (pokemon == null) { continue; } SSpiritAnimalSkill sSpiritAnimalSkill = SSpiritAnimalSkill.skillByAnimalAndStar.get(pokemon.getTmpId()).get(pokemon.getStar()); - Map map = calOnePokemonAttribute(pokemon.getTmpId(),pokemon.getStar(),pokemon.getLevel()); - StringBuilder propertyBuilder = getOnePokemonProperty(map,pokemon.getLevel()); + Map map = calOnePokemonAttribute(pokemon.getTmpId(), pokemon.getStar(), pokemon.getLevel()); + StringBuilder propertyBuilder = getOnePokemonProperty(map, pokemon.getLevel()); CommonProto.FightUnitInfo info = CommonProto.FightUnitInfo.newBuilder() .setPosition(entry.getKey()) .setStar(pokemon.getStar()) @@ -2427,30 +2455,31 @@ public class HeroLogic{ .setUnitId(String.valueOf(pokemon.getTmpId())).setUnitSkillIds(String.valueOf(sSpiritAnimalSkill.getId())).build(); pokemonInfos.add(info); } + return pokemonInfos; } - public List getCrossPokemon(CrossArenaManager crossArenaManager){ + public List getCrossPokemon(CrossArenaManager crossArenaManager) { //todo 灵兽 Map pokemonMap = crossArenaManager.getPokemons(); Map teamMap = crossArenaManager.getPokemonTeamMap(); - Map pokemons = new HashMap<>(); + Map pokemons = new HashMap<>(); List pokemonInfos = new ArrayList<>(); - for(Map.Entry entry : teamMap.entrySet()){ + for (Map.Entry entry : teamMap.entrySet()) { com.ljsd.jieling.thrift.idl.Pokemon pokemon = pokemonMap.get(entry.getValue()); - pokemons.put(entry.getKey(),pokemon); + pokemons.put(entry.getKey(), pokemon); } - for(Map.Entry entry:pokemons.entrySet()){ + for (Map.Entry entry : pokemons.entrySet()) { com.ljsd.jieling.thrift.idl.Pokemon pokemon = entry.getValue(); - if(pokemon==null){ + if (pokemon == null) { continue; } SSpiritAnimalSkill sSpiritAnimalSkill = SSpiritAnimalSkill.skillByAnimalAndStar.get(pokemon.getTmpId()).get(pokemon.getStar()); - Map map = calOnePokemonAttribute(pokemon.getTmpId(),pokemon.getStar(),pokemon.getLevel()); - StringBuilder propertyBuilder = getOnePokemonProperty(map,pokemon.getLevel()); + Map map = calOnePokemonAttribute(pokemon.getTmpId(), pokemon.getStar(), pokemon.getLevel()); + StringBuilder propertyBuilder = getOnePokemonProperty(map, pokemon.getLevel()); CommonProto.FightUnitInfo info = CommonProto.FightUnitInfo.newBuilder() .setPosition(entry.getKey()) .setStar(pokemon.getStar()) @@ -2458,31 +2487,32 @@ public class HeroLogic{ .setUnitId(String.valueOf(pokemon.getTmpId())).setUnitSkillIds(String.valueOf(sSpiritAnimalSkill.getId())).build(); pokemonInfos.add(info); } + getPracticeSkill(pokemonInfos,crossArenaManager.getPracticeSkillMap(),crossArenaManager.getMaxHistoryForce()); return pokemonInfos; } - public List getCrossPokemonSkills(User user){ + public List getCrossPokemonSkills(User user) { //todo 灵兽 // 灵兽 - Map pokemons = new HashMap<>(); + Map pokemons = new HashMap<>(); Map pokemonMap = user.getPokemonManager().getPokemonMap(); Map teamMap = user.getPokemonManager().getPokemonTeamMap(); for (Map.Entry entry : teamMap.entrySet()) { // clone 深度复制 - Pokemon pokemon = (Pokemon)pokemonMap.get(entry.getValue()).clone(); - pokemons.put(entry.getKey(),pokemon); + Pokemon pokemon = (Pokemon) pokemonMap.get(entry.getValue()).clone(); + pokemons.put(entry.getKey(), pokemon); } //Map pokemons = user.getPokemons(); List pokemonInfos = new ArrayList<>(); - for(Map.Entry entry:pokemons.entrySet()){ + for (Map.Entry entry : pokemons.entrySet()) { Pokemon pokemon = entry.getValue(); - if(pokemon==null){ + if (pokemon == null) { continue; } SSpiritAnimalSkill sSpiritAnimalSkill = SSpiritAnimalSkill.skillByAnimalAndStar.get(pokemon.getTmpId()).get(pokemon.getStar()); - Map map = calOnePokemonAttribute(pokemon.getTmpId(),pokemon.getStar(),pokemon.getLevel()); - StringBuilder propertyBuilder = getOnePokemonProperty(map,pokemon.getLevel()); + Map map = calOnePokemonAttribute(pokemon.getTmpId(), pokemon.getStar(), pokemon.getLevel()); + StringBuilder propertyBuilder = getOnePokemonProperty(map, pokemon.getLevel()); CommonProto.FightUnitInfo info = CommonProto.FightUnitInfo.newBuilder() .setPosition(entry.getKey()) .setStar(pokemon.getStar()) @@ -2490,11 +2520,12 @@ public class HeroLogic{ .setUnitId(String.valueOf(pokemon.getTmpId())).setUnitSkillIds(String.valueOf(sSpiritAnimalSkill.getId())).build(); pokemonInfos.add(info); } + getPracticeSkill(pokemonInfos,user.getHeroManager().getPracticeSkillMap(),user.getPlayerInfoManager().getMaxForce()); return pokemonInfos; } - public String getPokenmonPassiveSkills(User user,int teamId){ + public String getPokenmonPassiveSkills(User user, int teamId) { //todo 灵兽 目前用不到 // Map pokemonMap = user.getPokemonManager().getPokemonMap(); // Collections.sort(teamPosForPokenInfos); @@ -2515,30 +2546,30 @@ public class HeroLogic{ return ""; } - public String getRobotPokenmonSkills(SArenaRobotConfig sArenaRobotConfig){ + public String getRobotPokenmonSkills(SArenaRobotConfig sArenaRobotConfig) { StringBuilder pokenSkillResult = new StringBuilder(); int[] differDemonsId = sArenaRobotConfig.getDifferDemonsId(); int differDemonsLv = sArenaRobotConfig.getDifferDemonsLv(); - int position =1; + int position = 1; int size = differDemonsId.length; - int i=0; - for(Integer pokemonId:differDemonsId){ - SDifferDemonsStageConfig sDifferDemonsStageConfig = SDifferDemonsStageConfig.getsDifferDemonsStageConfigMap(pokemonId*100 + differDemonsLv); + int i = 0; + for (Integer pokemonId : differDemonsId) { + SDifferDemonsStageConfig sDifferDemonsStageConfig = SDifferDemonsStageConfig.getsDifferDemonsStageConfigMap(pokemonId * 100 + differDemonsLv); pokenSkillResult.append(position).append("#").append(sDifferDemonsStageConfig.getSkillId()); - if(i++!=size-1){ + if (i++ != size - 1) { pokenSkillResult.append("|"); } } return pokenSkillResult.toString(); } - public String getRobotPokenmonPassiveSkills(SArenaRobotConfig sArenaRobotConfig){ + public String getRobotPokenmonPassiveSkills(SArenaRobotConfig sArenaRobotConfig) { StringBuilder pokenSkillPassiveResult = new StringBuilder(); int[] differDemonsId = sArenaRobotConfig.getDifferDemonsId(); int differDemonsLv = sArenaRobotConfig.getDifferDemonsLv(); - for(Integer pokemonId:differDemonsId){ - SDifferDemonsStageConfig sDifferDemonsStageConfig = SDifferDemonsStageConfig.getsDifferDemonsStageConfigMap(pokemonId*100 + differDemonsLv); - if(!StringUtil.isEmpty(sDifferDemonsStageConfig.getPassiveSkillString())){ + for (Integer pokemonId : differDemonsId) { + SDifferDemonsStageConfig sDifferDemonsStageConfig = SDifferDemonsStageConfig.getsDifferDemonsStageConfigMap(pokemonId * 100 + differDemonsLv); + if (!StringUtil.isEmpty(sDifferDemonsStageConfig.getPassiveSkillString())) { pokenSkillPassiveResult.append(sDifferDemonsStageConfig.getPassiveSkillString()).append("|"); } @@ -2548,149 +2579,150 @@ public class HeroLogic{ } //图鉴属性加成 - public void bonuses(Set bookEnabled,Map heroAllAttribute){ - if (!bookEnabled.isEmpty()){ + public void bonuses(Set bookEnabled, Map heroAllAttribute) { + if (!bookEnabled.isEmpty()) { Map config = STableManager.getConfig(SSpiritAnimalBook.class); - for(int bootId:bookEnabled){ + for (int bootId : bookEnabled) { int[][] activePara = Optional.ofNullable(config.get(bootId)).map(SSpiritAnimalBook::getActivePara).orElse(new int[0][]); - combinedAttribute(activePara,heroAllAttribute); + combinedAttribute(activePara, heroAllAttribute); } } } /** * 计算队伍战力 + * * @param user * @param hero * @param isForce * @param teamId * @return */ - public Map calHeroNotBufferAttribute(User user, Hero hero,boolean isForce,int teamId){ - Map heroAllAttribute = calHeroAllAttribute(user, hero,isForce); - heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(),heroAllAttribute.get(GlobalsDef.HP_TYPE)); + public Map calHeroNotBufferAttribute(User user, Hero hero, boolean isForce, int teamId) { + Map heroAllAttribute = calHeroAllAttribute(user, hero, isForce); + heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), heroAllAttribute.get(GlobalsDef.HP_TYPE)); PokemonManager pokemonManager = user.getPokemonManager(); - HeroManager heroManager=user.getHeroManager(); - EquipManager equipManager=user.getEquipManager(); + HeroManager heroManager = user.getHeroManager(); + EquipManager equipManager = user.getEquipManager(); SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId()); - if(teamId!=0){ + if (teamId != 0) { int heroNum = user.getTeamPosManager().getTeamPosForHero().get(teamId).size(); - if(teamId==GlobalsDef.TRIAL_TEAM){ + if (teamId == GlobalsDef.TRIAL_TEAM) { //森罗环境固定为5 heroNum = 5; } int[][] pokemonAttr = calPokemonAttribute(pokemonManager); - for(int i = 0 ; i pokemonBookEnabled = pokemonManager.getPokemonBookEnabled(); - bonuses(pokemonBookEnabled,heroAllAttribute); + bonuses(pokemonBookEnabled, heroAllAttribute); //神将羁绊加成 Set heroBookEnabled = heroManager.getHeroHandBookEnabled(); - bonuses(heroBookEnabled,heroAllAttribute); + bonuses(heroBookEnabled, heroAllAttribute); //魂印图鉴加成 Set equipBookEnabled = equipManager.getEquipBookEnabled(); - bonuses(equipBookEnabled,heroAllAttribute); + bonuses(equipBookEnabled, heroAllAttribute); //白金装备加成 Set whiteBookEnabled = user.getItemManager().getEquipBookEnabled(); - bonuses(whiteBookEnabled,heroAllAttribute); + bonuses(whiteBookEnabled, heroAllAttribute); //英雄皮肤加成 记得判断皮肤过期 int skin = hero.getSkin(); - if(skin!=0){ + if (skin != 0) { Map skinInfo = user.getHeroManager().getSkinInfo(); SHeroSkin sHeroSkin = SHeroSkin.skinMapByType.get(skin); - if(sHeroSkin!=null&&sHeroSkin.getMonomerProperty()!=null&&sHeroSkin.getMonomerProperty().length>0){ - if(skinInfo.containsKey(skin)&&(skinInfo.get(skin)==-1||skinInfo.get(skin)>TimeUtils.nowInt())){ - combinedAttribute(sHeroSkin.getMonomerProperty(),heroAllAttribute); + if (sHeroSkin != null && sHeroSkin.getMonomerProperty() != null && sHeroSkin.getMonomerProperty().length > 0) { + if (skinInfo.containsKey(skin) && (skinInfo.get(skin) == -1 || skinInfo.get(skin) > TimeUtils.nowInt())) { + combinedAttribute(sHeroSkin.getMonomerProperty(), heroAllAttribute); } } } //玩家皮肤加成 - for(Map.Entry entry : user.getPlayerInfoManager().getUserSkinValidTime().entrySet()){ - if(!SPlayerHeadIcon.getHeadIconMap().containsKey(entry.getKey())){ + for (Map.Entry entry : user.getPlayerInfoManager().getUserSkinValidTime().entrySet()) { + if (!SPlayerHeadIcon.getHeadIconMap().containsKey(entry.getKey())) { continue; } - combinedAttribute(SPlayerHeadIcon.getHeadIconMap().get(entry.getKey()).getUnlockProperty(),heroAllAttribute); + combinedAttribute(SPlayerHeadIcon.getHeadIconMap().get(entry.getKey()).getUnlockProperty(), heroAllAttribute); } //玩家称号加成 - for(Map.Entry entry : user.getPlayerInfoManager().getUserTitleValidTime().entrySet()){ - if(!SPlayerHeadIcon.getHeadIconMap().containsKey(entry.getKey())){ + for (Map.Entry entry : user.getPlayerInfoManager().getUserTitleValidTime().entrySet()) { + if (!SPlayerHeadIcon.getHeadIconMap().containsKey(entry.getKey())) { continue; } - combinedAttribute(SPlayerHeadIcon.getHeadIconMap().get(entry.getKey()).getUnlockProperty(),heroAllAttribute); + combinedAttribute(SPlayerHeadIcon.getHeadIconMap().get(entry.getKey()).getUnlockProperty(), heroAllAttribute); } //玩家坐骑加成 - for(Map.Entry entry : user.getPlayerInfoManager().getUserMountValidTime().entrySet()){ - if(!SPlayerHeadIcon.getHeadIconMap().containsKey(entry.getKey())){ + for (Map.Entry entry : user.getPlayerInfoManager().getUserMountValidTime().entrySet()) { + if (!SPlayerHeadIcon.getHeadIconMap().containsKey(entry.getKey())) { continue; } - combinedAttribute(SPlayerHeadIcon.getHeadIconMap().get(entry.getKey()).getUnlockProperty(),heroAllAttribute); + combinedAttribute(SPlayerHeadIcon.getHeadIconMap().get(entry.getKey()).getUnlockProperty(), heroAllAttribute); } //四象心法加成 - for(Map.Entry entry : user.getHeroManager().getSixiangDataMap().entrySet()){ - if (scHero.getProfession()!=entry.getKey()) { + for (Map.Entry entry : user.getHeroManager().getSixiangDataMap().entrySet()) { + if (scHero.getProfession() != entry.getKey()) { continue; } //强化属性 - MappropertyMap=entry.getValue().propertyMap; + Map propertyMap = entry.getValue().propertyMap; int[][] propArr = ItemUtil.mapToArray(propertyMap); - combinedAttribute(propArr,heroAllAttribute); + combinedAttribute(propArr, heroAllAttribute); if (user.getHeroManager().getSixiangPropUpMap().containsKey(entry.getKey())) { //进阶属性 - MapupStarPropertyMap=user.getHeroManager().getSixiangPropUpMap().get(entry.getKey()); - int[][]upStarProp=ItemUtil.mapToArray(upStarPropertyMap); - combinedAttribute(upStarProp,heroAllAttribute); + Map upStarPropertyMap = user.getHeroManager().getSixiangPropUpMap().get(entry.getKey()); + int[][] upStarProp = ItemUtil.mapToArray(upStarPropertyMap); + combinedAttribute(upStarProp, heroAllAttribute); } } ///四象心法共鸣属性加成 - if (user.getHeroManager().GetSiXiangGongMingLv()>0){ - SFourQuadrantConfig fourConfig=SFourQuadrantConfig.configByStrtMap.get(user.getHeroManager().GetSiXiangGongMingLv()); - combinedAttribute(fourConfig.getPropResonance(),heroAllAttribute); + if (user.getHeroManager().GetSiXiangGongMingLv() > 0) { + SFourQuadrantConfig fourConfig = SFourQuadrantConfig.configByStrtMap.get(user.getHeroManager().GetSiXiangGongMingLv()); + combinedAttribute(fourConfig.getPropResonance(), heroAllAttribute); } ///四象心法技能属性加成 - MapskillPropertyMap=new HashMap<>(); - for(Map.Entry entry : user.getHeroManager().getSixiangDataMap().entrySet()){ - if (entry.getValue().level>0) { - SFourQuadrantConfig fourConfig=SFourQuadrantConfig.configByStrtMap.get(entry.getValue().level); - int[]skillAddProp=fourConfig.getSkill()[entry.getKey()-1]; - skillPropertyMap.put(skillAddProp[0],skillAddProp[1]); + Map skillPropertyMap = new HashMap<>(); + for (Map.Entry entry : user.getHeroManager().getSixiangDataMap().entrySet()) { + if (entry.getValue().level > 0) { + SFourQuadrantConfig fourConfig = SFourQuadrantConfig.configByStrtMap.get(entry.getValue().level); + int[] skillAddProp = fourConfig.getSkill()[entry.getKey() - 1]; + skillPropertyMap.put(skillAddProp[0], skillAddProp[1]); } } - int[][]skillProp=ItemUtil.mapToArray(skillPropertyMap); - combinedAttribute(skillProp,heroAllAttribute); + int[][] skillProp = ItemUtil.mapToArray(skillPropertyMap); + combinedAttribute(skillProp, heroAllAttribute); //英雄好感度属性加成 - if (user.getHeroManager().getHeroLikablePropAddMap().containsKey(scHero.getId())){ - int[][]likableProp=ItemUtil.mapToArray(user.getHeroManager().getHeroLikablePropAddMap().get(scHero.getId())); - combinedAttribute(likableProp,heroAllAttribute); + if (user.getHeroManager().getHeroLikablePropAddMap().containsKey(scHero.getId())) { + int[][] likableProp = ItemUtil.mapToArray(user.getHeroManager().getHeroLikablePropAddMap().get(scHero.getId())); + combinedAttribute(likableProp, heroAllAttribute); } //英雄总好感度属性加成 - if (user.getHeroManager().getAllLikablePropAddMap().size()>0){ - int[][]allLikableProp=ItemUtil.mapToArray(user.getHeroManager().getAllLikablePropAddMap()); - combinedAttribute(allLikableProp,heroAllAttribute); + if (user.getHeroManager().getAllLikablePropAddMap().size() > 0) { + int[][] allLikableProp = ItemUtil.mapToArray(user.getHeroManager().getAllLikablePropAddMap()); + combinedAttribute(allLikableProp, heroAllAttribute); } //装备总战力评分 - int equipForce=0; + int equipForce = 0; Iterator> iterator = hero.getEquipByHongmengPositionMap(user.getHeroManager()).entrySet().iterator(); // 套装list初始化 ArrayList suiteNumList = new ArrayList<>(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { Map.Entry next = iterator.next(); SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(next.getValue()); int[][] property = sEquipConfig.getProperty(); - Map propertyValueByIdMap = new HashMap<>(); - for(int[] prop:property){ + Map propertyValueByIdMap = new HashMap<>(); + for (int[] prop : property) { propertyValueByIdMap.put(prop[0], (long) prop[1]); } - combinedAttribute(propertyValueByIdMap,heroAllAttribute); - equipForce+=sEquipConfig.getScore(); + combinedAttribute(propertyValueByIdMap, heroAllAttribute); + equipForce += sEquipConfig.getScore(); // 添加到套装list suiteNumList.add(sEquipConfig); } @@ -2700,35 +2732,35 @@ public class HeroLogic{ Collections.sort(suiteNumList); // 记录当前长度(位置) int num = suiteNumList.size(); - if (!suiteNumList.isEmpty()){ + if (!suiteNumList.isEmpty()) { // 遍历套装list for (SEquipConfig item : suiteNumList) { //根据星级读取配置表,为空表示不是套装 - SEquipSuiteConfig sEquipSuiteConfig =SEquipSuiteConfig.config.get(item.getStar()); - if (null != sEquipSuiteConfig){ + SEquipSuiteConfig sEquipSuiteConfig = SEquipSuiteConfig.config.get(item.getStar()); + if (null != sEquipSuiteConfig) { // 根据套装数量读表,为空标是套装数量不足 Map suitePropertyMap = sEquipSuiteConfig.getSuiteMap().get(num); - if(suitePropertyMap!=null){ + if (suitePropertyMap != null) { // 计算战力 - combinedAttribute(suitePropertyMap,heroAllAttribute); + combinedAttribute(suitePropertyMap, heroAllAttribute); } } // 不管是否是套装,都要-1 - num-=1; + num -= 1; } } //工坊科技树加成 Map techProfressionMap = user.getWorkShopController().getTechnologyMap().get(scHero.getProfession()); - if(techProfressionMap!=null){ - for(Map.Entry item : techProfressionMap.entrySet()){ - SWorkShopTechnology sWorkShopTechnology = STableManager.getFigureConfig(CommonStaticConfig.class).getsWorkTechMapByTechIdAndLevel(item.getKey(), item.getValue()); - if(sWorkShopTechnology == null){ + if (techProfressionMap != null) { + for (Map.Entry item : techProfressionMap.entrySet()) { + SWorkShopTechnology sWorkShopTechnology = STableManager.getFigureConfig(CommonStaticConfig.class).getsWorkTechMapByTechIdAndLevel(item.getKey(), item.getValue()); + if (sWorkShopTechnology == null) { continue; } int[][] attrAdd = sWorkShopTechnology.getValues(); - if(attrAdd!=null&& attrAdd.length>0){ - combinedAttribute(attrAdd,heroAllAttribute); + if (attrAdd != null && attrAdd.length > 0) { + combinedAttribute(attrAdd, heroAllAttribute); } } @@ -2737,39 +2769,39 @@ public class HeroLogic{ //法宝加成 int heroStar = hero.getStar(); //判断是否解锁法宝 - if(scHero.getEquipTalismana()!=null&&scHero.getEquipTalismana().length>0&&heroStar>=scHero.getEquipTalismana()[0]){ + if (scHero.getEquipTalismana() != null && scHero.getEquipTalismana().length > 0 && heroStar >= scHero.getEquipTalismana()[0]) { int equipTempId = scHero.getEquipTalismana()[1]; - int tempStar = hero.getEspecialEquipLevelByHongmeng(user.getHeroManager(),hero.getId()); + int tempStar = hero.getEspecialEquipLevelByHongmeng(user.getHeroManager(), hero.getId()); Map> equipTalismanaMap = SEquipTalismana.equipTalismanaStarMap; SEquipTalismana equipTali = equipTalismanaMap.get(equipTempId).get(tempStar); - combinedAttribute(equipTali.getProperty(),heroAllAttribute); + combinedAttribute(equipTali.getProperty(), heroAllAttribute); } Map equipMap = new HashMap<>(); // 助战英雄 HelpHero helpHero = HelpHeroLogic.getHelpHeroByHeroId(user.getId(), hero.getId()); - if (helpHero!=null){ + if (helpHero != null) { for (Jewel jewel : helpHero.getJewels()) { - equipMap.put(jewel.getId(),jewel); + equipMap.put(jewel.getId(), jewel); } - }else { - equipMap = hero.getCreateType()==1?user.getExpeditionManager().getEquipMap():user.getEquipManager().getEquipMap(); + } else { + equipMap = hero.getCreateType() == 1 ? user.getExpeditionManager().getEquipMap() : user.getEquipManager().getEquipMap(); } //宝器加成 Set jewelInfo = hero.getJewelInfo(); - boolean flashing = jewelInfo.size()==2; + boolean flashing = jewelInfo.size() == 2; int minLevel = -1; int minBuildLevel = -1; - for (String jewel: jewelInfo) { + for (String jewel : jewelInfo) { PropertyItem propertyItem = equipMap.get(jewel); - if (propertyItem==null) { + if (propertyItem == null) { continue; } - Jewel j = (Jewel)propertyItem; + Jewel j = (Jewel) propertyItem; SJewelConfig config = STableManager.getConfig(SJewelConfig.class).get(j.getEquipId()); // 进阶 Map> rankPoolMap = SJewelRankupConfig.rankupMap.get(config.getRankupPool()); @@ -2778,33 +2810,33 @@ public class HeroLogic{ // 神应/神树 Map> godTreePoolMap = SJewelRankupConfig.rankupMap.get(config.getGodHoodPool()); - if(flashing){ - if(minLevel==-1){ - minLevel = j.getLevelByHongMeng(user.getHeroManager(),hero.getId()); - }else{ - minLevel = Math.min(j.getLevelByHongMeng(user.getHeroManager(),hero.getId()),minLevel); + if (flashing) { + if (minLevel == -1) { + minLevel = j.getLevelByHongMeng(user.getHeroManager(), hero.getId()); + } else { + minLevel = Math.min(j.getLevelByHongMeng(user.getHeroManager(), hero.getId()), minLevel); } - if(minBuildLevel==-1){ + if (minBuildLevel == -1) { minBuildLevel = j.getBuildLevel(); - }else{ - minBuildLevel = Math.min(j.getBuildLevel(),minBuildLevel); + } else { + minBuildLevel = Math.min(j.getBuildLevel(), minBuildLevel); } } int[][] property; - if(levelPoolMap!=null){ - property = levelPoolMap.get(1).get(j.getLevelByHongMeng(user.getHeroManager(),hero.getId())).getProperty(); - combinedAttribute(property,heroAllAttribute); + if (levelPoolMap != null) { + property = levelPoolMap.get(1).get(j.getLevelByHongMeng(user.getHeroManager(), hero.getId())).getProperty(); + combinedAttribute(property, heroAllAttribute); } - if(rankPoolMap!=null){ + if (rankPoolMap != null) { property = rankPoolMap.get(2).get(j.getBuildLevel()).getProperty(); - combinedAttribute(property,heroAllAttribute); + combinedAttribute(property, heroAllAttribute); } - if (godTreePoolMap != null){ - if (helpHero != null){ + if (godTreePoolMap != null) { + if (helpHero != null) { // 助战 property = ItemLogic.getInstance().godTreeAddition(godTreePoolMap, helpHero.getTreeLevel(), helpHero.getFourTotalTier()); combinedAttribute(property, heroAllAttribute); - }else { + } else { // 自己 if (ItemLogic.ifOpenGodTree(user)) { // 获取神应等级 @@ -2817,32 +2849,32 @@ public class HeroLogic{ } } //宝器共鸣 - if(flashing){ + if (flashing) { Map config = STableManager.getConfig(SJewelResonanceConfig.class); int levelProperty = 0; int buildLevelProperty = 0; - for (SJewelResonanceConfig value:config.values()){ - if(value.getType()==1){ - levelProperty = value.getLevel()>minLevel?levelProperty:(value.getId()>levelProperty? value.getId():levelProperty); + for (SJewelResonanceConfig value : config.values()) { + if (value.getType() == 1) { + levelProperty = value.getLevel() > minLevel ? levelProperty : (value.getId() > levelProperty ? value.getId() : levelProperty); } - if(value.getType()==2){ - buildLevelProperty = value.getLevel()>minBuildLevel?buildLevelProperty:(value.getId()>buildLevelProperty? value.getId():buildLevelProperty); + if (value.getType() == 2) { + buildLevelProperty = value.getLevel() > minBuildLevel ? buildLevelProperty : (value.getId() > buildLevelProperty ? value.getId() : buildLevelProperty); } } - if(levelProperty!=0){ - combinedAttribute(config.get(levelProperty).getProperty(),heroAllAttribute); + if (levelProperty != 0) { + combinedAttribute(config.get(levelProperty).getProperty(), heroAllAttribute); } - if(buildLevelProperty!=0){ - combinedAttribute(config.get(buildLevelProperty).getProperty(),heroAllAttribute); + if (buildLevelProperty != 0) { + combinedAttribute(config.get(buildLevelProperty).getProperty(), heroAllAttribute); } } //魂印 Map soulEquipByPositionMap = hero.getSoulEquipByPositionMap(); - soulEquipByPositionMap.forEach((k,v)->{ + soulEquipByPositionMap.forEach((k, v) -> { SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(v); int[][] property = sEquipConfig.getProperty(); - if(property!=null&&property.length>0&&property[0].length>0){ - combinedAttribute(property,heroAllAttribute); + if (property != null && property.length > 0 && property[0].length > 0) { + combinedAttribute(property, heroAllAttribute); } }); @@ -2850,8 +2882,8 @@ public class HeroLogic{ Map xiuXianMap = STableManager.getConfig(SXiuXian.class); int practiceLevel = user.getHeroManager().getPracticeLevel(); for (SXiuXian v : xiuXianMap.values()) { - if (practiceLevel >= v.getId() && v.getTotalPros() != null){ - combinedAttribute(v.getTotalPros(),heroAllAttribute); + if (practiceLevel >= v.getId() && v.getTotalPros() != null) { + combinedAttribute(v.getTotalPros(), heroAllAttribute); } } @@ -2890,107 +2922,107 @@ public class HeroLogic{ //公会技能加成 Map guildSkill = user.getGuildMyInfo().getGuildSkill(); - if(guildSkill.containsKey(scHero.getProfession())){ + if (guildSkill.containsKey(scHero.getProfession())) { int size = SGuildTechnology.technologyMap.get(scHero.getProfession()).size(); int level = guildSkill.get(scHero.getProfession()); List skills = new ArrayList<>(); - for(int i = 1;i<=size;i++){ - int baseLevel = level/size; - if(level%size>=i){ - baseLevel+=1; + for (int i = 1; i <= size; i++) { + int baseLevel = level / size; + if (level % size >= i) { + baseLevel += 1; } Map levelMap = SGuildTechnology.technologyMap.get(scHero.getProfession()).get(i); SGuildTechnology sGuildTechnology = levelMap.get(baseLevel); skills.add(sGuildTechnology.getValues()); } int[][] arraySkills = skills.toArray(new int[skills.size()][]); - combinedAttribute(arraySkills,heroAllAttribute); + combinedAttribute(arraySkills, heroAllAttribute); } //阵营光环加成 - if(teamId!=0){ + if (teamId != 0) { try { - int[][] elementEffect = CombatLogic.getInstance().elementEffect(user,teamId); - if (elementEffect!=null&&elementEffect.length>0){ - combinedAttribute(elementEffect,heroAllAttribute); + int[][] elementEffect = CombatLogic.getInstance().elementEffect(user, teamId); + if (elementEffect != null && elementEffect.length > 0) { + combinedAttribute(elementEffect, heroAllAttribute); } - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } } //被动技能加成 - Set heroSkillList = CombatLogic.getInstance().passiveskillEffect(user, hero,teamId); + Set heroSkillList = CombatLogic.getInstance().passiveskillEffect(user, hero, teamId); - if(teamId==GlobalsDef.EXPEDITION_TEAM){ + if (teamId == GlobalsDef.EXPEDITION_TEAM) { ExpeditionManager expeditionManager = user.getExpeditionManager(); - Set expeditionHolyConfigs = ExpeditionLogic.getFirstRankHoly(expeditionManager); - for (SExpeditionHolyConfig config:expeditionHolyConfigs) { - if(config.getPassiveSkillId()>0){ + Set expeditionHolyConfigs = ExpeditionLogic.getFirstRankHoly(expeditionManager); + for (SExpeditionHolyConfig config : expeditionHolyConfigs) { + if (config.getPassiveSkillId() > 0) { heroSkillList.add(config.getPassiveSkillId()); } } } - Map heroSkillAdMap = new HashMap<>(); - heroSkillList.forEach(skill->{ + Map heroSkillAdMap = new HashMap<>(); + heroSkillList.forEach(skill -> { SPassiveSkillLogicConfig config = SPassiveSkillLogicConfig.getConfig(skill); - if(null!=config.getValue()&&config.getValue().length>2&&config.getValue()[2] !=4){ + if (null != config.getValue() && config.getValue().length > 2 && config.getValue()[2] != 4) { PassiveskillCalEnum passiveskillCalEnum = PassiveskillCalEnum.calEnumMap.get(config.getType()); - if(null!= passiveskillCalEnum){ - passiveskillCalEnum.getPassiveSkillProcessor().process(config,hero,heroSkillAdMap); + if (null != passiveskillCalEnum) { + passiveskillCalEnum.getPassiveSkillProcessor().process(config, hero, heroSkillAdMap); } } }); - if(!heroSkillAdMap.isEmpty()){ - combinedAttribute(heroSkillAdMap,heroAllAttribute); + if (!heroSkillAdMap.isEmpty()) { + combinedAttribute(heroSkillAdMap, heroAllAttribute); heroSkillAdMap.clear(); } //特权加成 int vipLevel = user.getPlayerInfoManager().getVipLevel(); SVipLevelConfig sVipLevelConfig = SVipLevelConfig.getsVipLevelConfigMap().get(vipLevel); - if(null!=sVipLevelConfig){ - int[][] elementEffect =sVipLevelConfig.getProperty(); - if (elementEffect!=null&&elementEffect.length>0) { - combinedAttribute(elementEffect,heroAllAttribute); + if (null != sVipLevelConfig) { + int[][] elementEffect = sVipLevelConfig.getProperty(); + if (elementEffect != null && elementEffect.length > 0) { + combinedAttribute(elementEffect, heroAllAttribute); } } - if(teamId==GlobalsDef.EXPEDITION_TEAM){ - if(user.getExpeditionManager().getWorldTreasureReward().getIsBuy()==1){ + if (teamId == GlobalsDef.EXPEDITION_TEAM) { + if (user.getExpeditionManager().getWorldTreasureReward().getIsBuy() == 1) { int[] onceArrayValue = SSpecialConfig.getOnceArrayValue(SSpecialConfig.SKILL_EFFECT_TGMB); - combinedAttribute(new int[][]{onceArrayValue},heroAllAttribute); + combinedAttribute(new int[][]{onceArrayValue}, heroAllAttribute); } } //pvp队伍加成 - if(!isForce && !TeamEnum.isPvpTeam(teamId)){ + if (!isForce && !TeamEnum.isPvpTeam(teamId)) { heroAllAttribute.remove(HeroAttributeEnum.PVPDamageBocusFactor.getPropertyId()); heroAllAttribute.remove(HeroAttributeEnum.PVPDamageReduceFactor.getPropertyId()); } - calInteractAdd(heroAllAttribute,isForce); + calInteractAdd(heroAllAttribute, isForce); - heroSkillList.forEach(skill->{ + heroSkillList.forEach(skill -> { SPassiveSkillLogicConfig configTmp = SPassiveSkillLogicConfig.getConfig(skill); - if(null!=configTmp.getValue()&&configTmp.getValue().length>2&&configTmp.getValue()[2] ==4){ + if (null != configTmp.getValue() && configTmp.getValue().length > 2 && configTmp.getValue()[2] == 4) { PassiveskillCalEnum passiveskillCalEnum = PassiveskillCalEnum.calEnumMap.get(configTmp.getType()); - if(null!= passiveskillCalEnum){ - passiveskillCalEnum.getPassiveSkillProcessor().process(configTmp,hero,heroSkillAdMap); + if (null != passiveskillCalEnum) { + passiveskillCalEnum.getPassiveSkillProcessor().process(configTmp, hero, heroSkillAdMap); } } }); - if(!heroSkillAdMap.isEmpty()){ - combinedAttribute(heroSkillAdMap,heroAllAttribute); - calInteractAdd(heroAllAttribute,isForce); + if (!heroSkillAdMap.isEmpty()) { + combinedAttribute(heroSkillAdMap, heroAllAttribute); + calInteractAdd(heroAllAttribute, isForce); heroSkillAdMap.clear(); } - heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(),heroAllAttribute.get(GlobalsDef.HP_TYPE)); + heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), heroAllAttribute.get(GlobalsDef.HP_TYPE)); //魂印战力保存 heroAllAttribute.put(HeroAttributeEnum.EquipForce.getPropertyId(), (long) equipForce); @@ -2999,48 +3031,49 @@ public class HeroLogic{ /** * 计算机器人英雄熟悉 + * * @param scHero * @param heroLevel - * @param heroBrekId 调用方法calRobotHeroAllAttribute未使用该参数,所以可以传0 + * @param heroBrekId 调用方法calRobotHeroAllAttribute未使用该参数,所以可以传0 * @param pokemonIds * @param pokemonLevel * @param isForce * @return */ - public Map calRobotHeroAttribute(SCHero scHero,int heroLevel,int heroBrekId,int[] pokemonIds,int pokemonLevel,boolean isForce){ - Map heroAllAttribute = calRobotHeroAllAttribute(scHero.getId(),heroLevel,heroBrekId,isForce); - heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(),heroAllAttribute.get(GlobalsDef.HP_TYPE)); - if(pokemonIds!=null){ + public Map calRobotHeroAttribute(SCHero scHero, int heroLevel, int heroBrekId, int[] pokemonIds, int pokemonLevel, boolean isForce) { + Map heroAllAttribute = calRobotHeroAllAttribute(scHero.getId(), heroLevel, heroBrekId, isForce); + heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), heroAllAttribute.get(GlobalsDef.HP_TYPE)); + if (pokemonIds != null) { int profession = scHero.getProfession(); - for(Integer pokemonId : pokemonIds){ + for (Integer pokemonId : pokemonIds) { int[] comonpentList = SDifferDemonsConfig.getsDifferDemonsConfigByPokenID(pokemonId).getComonpentList(); - for(Integer comonpentId : comonpentList){ + for (Integer comonpentId : comonpentList) { Map sDifferDemonsComonpentsConfigMap = SDifferDemonsComonpentsConfig.getsDifferDemonsComonpentsConfigMap(comonpentId); SDifferDemonsComonpentsConfig sDifferDemonsComonpentsConfig = sDifferDemonsComonpentsConfigMap.get(pokemonLevel); Map> extraAddMap = sDifferDemonsComonpentsConfig.getExtraAddMap(); - if(extraAddMap!=null&&(extraAddMap.containsKey(profession)||extraAddMap.containsKey(0))){ + if (extraAddMap != null && (extraAddMap.containsKey(profession) || extraAddMap.containsKey(0))) { int innerId = extraAddMap.containsKey(0) ? 0 : profession; Map professionAddMap = extraAddMap.get(innerId); - combinedAttribute(professionAddMap,heroAllAttribute); + combinedAttribute(professionAddMap, heroAllAttribute); } - combinedAttribute(sDifferDemonsComonpentsConfig.getBaseAttribute(),heroAllAttribute); + combinedAttribute(sDifferDemonsComonpentsConfig.getBaseAttribute(), heroAllAttribute); } } } - heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(),heroAllAttribute.get(GlobalsDef.HP_TYPE)); - calInteractAdd(heroAllAttribute,isForce); + heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), heroAllAttribute.get(GlobalsDef.HP_TYPE)); + calInteractAdd(heroAllAttribute, isForce); return heroAllAttribute; } //策划说这里不会超int - public Map calRobotHeroAttribute(SRobotProperty property){ + public Map calRobotHeroAttribute(SRobotProperty property) { int[][] property1 = property.getProperty(); - if (property1 == null){ + if (property1 == null) { return new HashMap<>(); } Map attribute = new HashMap<>(property1.length); for (int[] anInt : property1) { - attribute.put(anInt[0],anInt[1]); + attribute.put(anInt[0], anInt[1]); } return attribute; } @@ -3048,104 +3081,103 @@ public class HeroLogic{ /** * 属性数值计算 * 先计算一级属性 - *绝对值直接加 百分比统一之后加 + * 绝对值直接加 百分比统一之后加 */ - public void calInteractAdd(Map heroAllAttribute,boolean judge){ - Map propertyPercentMap = new HashMap<>(); + public void calInteractAdd(Map heroAllAttribute, boolean judge) { + Map propertyPercentMap = new HashMap<>(); Iterator> iterator = heroAllAttribute.entrySet().iterator(); Map newAddAttribute = new HashMap<>(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { Map.Entry item = iterator.next(); Integer propertyId = item.getKey(); - if(propertyId == HeroAttributeEnum.EquipForce.getPropertyId()){ + if (propertyId == HeroAttributeEnum.EquipForce.getPropertyId()) { continue; } SPropertyConfig sPropertyConfig = SPropertyConfig.getsPropertyConfigByPID(propertyId); int targetPropertyId = sPropertyConfig.getTargetPropertyId(); - if(targetPropertyId == 0){ + if (targetPropertyId == 0) { continue; } SPropertyConfig stargetPro = SPropertyConfig.getsPropertyConfigByPID(targetPropertyId); - if(stargetPro==null){ + if (stargetPro == null) { continue; } int style = sPropertyConfig.getStyle(); int effectValue = item.getValue().intValue(); //如果目标属性也是万分比 直接加 - if(style == GlobalsDef.ABSOLUTE_TYPE||stargetPro.getStyle()==GlobalsDef.PERCENT_TYPE){ - if(heroAllAttribute.containsKey(targetPropertyId)){ + if (style == GlobalsDef.ABSOLUTE_TYPE || stargetPro.getStyle() == GlobalsDef.PERCENT_TYPE) { + if (heroAllAttribute.containsKey(targetPropertyId)) { long targetValue = heroAllAttribute.getOrDefault(targetPropertyId, 0L); effectValue += targetValue; heroAllAttribute.put(targetPropertyId, (long) effectValue); - }else { - newAddAttribute.merge(targetPropertyId, (long) effectValue,(a, b) -> a+b); + } else { + newAddAttribute.merge(targetPropertyId, (long) effectValue, (a, b) -> a + b); } - }else{ - propertyPercentMap.put(targetPropertyId,effectValue); + } else { + propertyPercentMap.put(targetPropertyId, effectValue); } - if (!judge){ + if (!judge) { iterator.remove(); } } heroAllAttribute.putAll(newAddAttribute); - for(Map.Entry item : propertyPercentMap.entrySet()){ + for (Map.Entry item : propertyPercentMap.entrySet()) { Integer propertyId = item.getKey(); Long propertyValue = heroAllAttribute.getOrDefault(propertyId, 0L); - heroAllAttribute.put(propertyId, (BigDecimal.valueOf(propertyValue).multiply(BigDecimal.valueOf(item.getValue()).divide(BigDecimal.valueOf(10000f))).intValue()+propertyValue)); + heroAllAttribute.put(propertyId, (BigDecimal.valueOf(propertyValue).multiply(BigDecimal.valueOf(item.getValue()).divide(BigDecimal.valueOf(10000f))).intValue() + propertyValue)); } Long maxHp = heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId()); Long curHp = heroAllAttribute.get(HeroAttributeEnum.CurHP.getPropertyId()); - if(maxHp!=null && curHp!=null && curHp > maxHp){ - heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(),maxHp); + if (maxHp != null && curHp != null && curHp > maxHp) { + heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), maxHp); } } - //获取英雄所有属性 - public Map calHeroFinalAttributeWhenInMap(User user, Hero hero,boolean isForce,int teamId){ + public Map calHeroFinalAttributeWhenInMap(User user, Hero hero, boolean isForce, int teamId) { Map heroAllAttribute = user.getMapManager().getHeroAllAttributeByHeroId(hero.getId()); - if(heroAllAttribute == null){ - heroAllAttribute=calHeroNotBufferAttribute(user, hero,isForce,teamId); + if (heroAllAttribute == null) { + heroAllAttribute = calHeroNotBufferAttribute(user, hero, isForce, teamId); return heroAllAttribute; } //食物buffer加成 - Map foodAddMap = CombatLogic.getInstance().attributeByEatFood(user,GlobalsDef.FOOD_ADDITION_BATTLE_TYPE, GlobalsDef.FOOD_EAT_AFFECT_PERSON); - if(foodAddMap.isEmpty()){ + Map foodAddMap = CombatLogic.getInstance().attributeByEatFood(user, GlobalsDef.FOOD_ADDITION_BATTLE_TYPE, GlobalsDef.FOOD_EAT_AFFECT_PERSON); + if (foodAddMap.isEmpty()) { return heroAllAttribute; } Map heroAllAttributeCopy = new HashMap<>(heroAllAttribute); - combinedAttribute(foodAddMap,heroAllAttributeCopy); - calInteractAdd(heroAllAttributeCopy,false); + combinedAttribute(foodAddMap, heroAllAttributeCopy); + calInteractAdd(heroAllAttributeCopy, false); return heroAllAttributeCopy; } - public long calHeoForce(User user, Hero hero,int teamId){ + public long calHeoForce(User user, Hero hero, int teamId) { Map heroAllAttribute; - heroAllAttribute = calHeroNotBufferAttribute(user, hero,true,teamId); + heroAllAttribute = calHeroNotBufferAttribute(user, hero, true, teamId); //战力保存 - int force = calForce(heroAllAttribute); + int force = calForce(heroAllAttribute); Map soulEquipByPositionMap = hero.getSoulEquipByPositionMap(); - for (int sign:soulEquipByPositionMap.values()){ + for (int sign : soulEquipByPositionMap.values()) { SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(sign); - if(sEquipConfig==null) { + if (sEquipConfig == null) { continue; } - force+=sEquipConfig.getScore(); + force += sEquipConfig.getScore(); } long l = force + heroAllAttribute.get(HeroAttributeEnum.EquipForce.getPropertyId()); - LOGGER.info("战力::::::{}",l); + LOGGER.info("战力::::::{}", l); return l; } ///获取最高战斗力 - public long calTeamForce(User user,int teamId){ + public long calTeamForce(User user, int teamId) { return user.getPlayerInfoManager().getMaxForce(); //之前是当前编队战斗力 /*long teamForce = 0; @@ -3163,7 +3195,7 @@ public class HeroLogic{ } - public int calForce( Map heroAllAttribute ){ + public int calForce(Map heroAllAttribute) { double result = 0; // 旧战力计算 // for(Map.Entry item : heroAllAttribute.entrySet()){ @@ -3224,39 +3256,40 @@ public class HeroLogic{ result = (finalHp * hpScore + finalAttack * attackScore + finalPhysicalDefence * pdScore + magicDefence * mdScore) * (1 + (damageBocusFactor + damageReduceFactor + hit + dodge + critFactor + antiCritDamageFactor + critDamageFactor + critDamageReduceFactor + cureFacter + treatFacter) / 2 / xishu); - return (int)result; + return (int) result; } - public void combinedAttribute(Map otherAttriMaop,Map heroAttributeMap){ - for(Map.Entry item : otherAttriMaop.entrySet()){ + public void combinedAttribute(Map otherAttriMaop, Map heroAttributeMap) { + for (Map.Entry item : otherAttriMaop.entrySet()) { Integer propertyId = item.getKey(); Long propertyValue = item.getValue(); - if(heroAttributeMap.containsKey(propertyId)){ + if (heroAttributeMap.containsKey(propertyId)) { propertyValue += heroAttributeMap.get(propertyId); } - heroAttributeMap.put(propertyId,propertyValue); - // LOGGER.info("the propertyId={} the propertyValue is ={},",propertyId,propertyValue); + heroAttributeMap.put(propertyId, propertyValue); + // LOGGER.info("the propertyId={} the propertyValue is ={},",propertyId,propertyValue); } } - public void combinedAttribute(int[][] otherAttriMap,Map heroAttributeMap){ - for(int[] item : otherAttriMap){ + + public void combinedAttribute(int[][] otherAttriMap, Map heroAttributeMap) { + for (int[] item : otherAttriMap) { int propertyId = item[0]; int propertyValue = item[1]; - heroAttributeMap.put(propertyId,heroAttributeMap.getOrDefault(propertyId, 0L)+propertyValue); + heroAttributeMap.put(propertyId, heroAttributeMap.getOrDefault(propertyId, 0L) + propertyValue); } } //新版穿装备 - private boolean checkEquipForWear(Hero hero,User user,List equipIds, Map equipInfos ) throws Exception { + private boolean checkEquipForWear(Hero hero, User user, List equipIds, Map equipInfos) throws Exception { - if(equipIds == null || equipIds.isEmpty()){ + if (equipIds == null || equipIds.isEmpty()) { return false; } - if(hero==null){ + if (hero == null) { return false; } - for(String equipId : equipIds){ + for (String equipId : equipIds) { int equip = Integer.parseInt(equipId); SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(equip); if (sEquipConfig == null) { @@ -3264,53 +3297,52 @@ public class HeroLogic{ } int position = sEquipConfig.getPosition(); boolean itemCost = ItemUtil.itemCost(user, new int[][]{{equip, 1}}, BIReason.EQUIP_WEAR_CONSUME, equip); - if(!itemCost){ + if (!itemCost) { return false; } int professionLimit = sEquipConfig.getProfessionLimit(); SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId()); - if(professionLimit!=0 && scHero.getProfession()!= professionLimit){ + if (professionLimit != 0 && scHero.getProfession() != professionLimit) { return false; } - equipInfos.put(position,equip); + equipInfos.put(position, equip); } return true; } - // equip TODO 装备会导致英雄属性发生变化 - public void wearEquipOpt(ISession session,String heroId,List equipIds,int type) throws Exception { + public void wearEquipOpt(ISession session, String heroId, List equipIds, int type) throws Exception { int uid = session.getUid(); User user = UserManager.getUser(uid); Hero hero = user.getHeroManager().getHeroMap().get(heroId); EquipManager equipManager = user.getEquipManager(); - if(type==1){ - Map equipInfoTmp = new HashMap<>(4); - if(!checkEquipForWear(hero,user,equipIds,equipInfoTmp)){ + if (type == 1) { + Map equipInfoTmp = new HashMap<>(4); + if (!checkEquipForWear(hero, user, equipIds, equipInfoTmp)) { throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR); } List equipUnload = new ArrayList<>(4); - for(Map.Entry entry :hero.getEquipByPositionMap().entrySet()){ - if(!equipInfoTmp.containsKey(entry.getKey()) ) { + for (Map.Entry entry : hero.getEquipByPositionMap().entrySet()) { + if (!equipInfoTmp.containsKey(entry.getKey())) { continue; } equipUnload.add(entry.getValue()); } int[][] unloadArray = new int[equipUnload.size()][]; - for(int i = 0 ; i equipIds,int type) throws Exception { + public void unloadEquipOpt(ISession session, String heroId, List equipIds, int type) throws Exception { int uid = session.getUid(); User user = UserManager.getUser(uid); Hero hero = user.getHeroManager().getHero(heroId); - if( hero == null || equipIds.isEmpty()){ + if (hero == null || equipIds.isEmpty()) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - if(type==1){ + if (type == 1) { List positions = new ArrayList<>(); - for(String equipId : equipIds){ + for (String equipId : equipIds) { // - int equipIdTid =Integer.parseInt(equipId); + int equipIdTid = Integer.parseInt(equipId); SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(equipIdTid); int position = sEquipConfig.getPosition(); Integer currEquip = hero.getEquipByPositionMap().get(position); - if(currEquip == null || currEquip != equipIdTid){ + if (currEquip == null || currEquip != equipIdTid) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } positions.add(position); } - if(positions.size()==0){ + if (positions.size() == 0) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } int[][] dropEquip = new int[positions.size()][]; - for(int i = 0 ; i equipMap = user.getEquipManager().getEquipMap(); - for(String equipId:equipIds){ - if(!hero.getJewelInfo().contains(equipId)){ + for (String equipId : equipIds) { + if (!hero.getJewelInfo().contains(equipId)) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - if(equipMap.get(equipId)!=null){ + if (equipMap.get(equipId) != null) { equipMap.get(equipId).setHeroId(""); } hero.removeJewel(equipId); } } - if(isInTeam(user,heroId,1)){ + if (isInTeam(user, heroId, 1)) { Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(uid)); } // 鸿蒙阵,脱装备 addOrUpdateHongmeng(session); //发送成功消息 - MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.EQUIP_UNLOAD_OPT_RESPONSE_VALUE,null,true); + MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.EQUIP_UNLOAD_OPT_RESPONSE_VALUE, null, true); } /** * 英雄,灵兽合成 + * * @param iSession * @param item */ - public void heroCompose(ISession iSession, CommonProto.Item item) throws Exception { + public void heroCompose(ISession iSession, CommonProto.Item item) throws Exception { int msgId = MessageTypeProto.MessageType.HERO_COMPOSE_RESPONSE_VALUE; int uid = iSession.getUid(); User user = UserManager.getUser(uid); int hasHeroNum = user.getHeroManager().getHeroMap().size(); int itemId = item.getItemId(); - int itemNum = (int)item.getItemNum(); + int itemNum = (int) item.getItemNum(); SItem sItem = SItem.getsItemMap().get(itemId); if (sItem == null || itemNum <= 0 || itemNum >= Integer.MAX_VALUE) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - int composeNum = itemNum/sItem.getUsePerCount(); + int composeNum = itemNum / sItem.getUsePerCount(); SGameSetting gameSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting(); - if (composeNum <= 0 || composeNum > gameSetting.getHeroCompoundLimit()){ + if (composeNum <= 0 || composeNum > gameSetting.getHeroCompoundLimit()) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - if (hasHeroNum + composeNum > gameSetting.getHeroNumlimit()){ + if (hasHeroNum + composeNum > gameSetting.getHeroNumlimit()) { throw new ErrorCodeException(ErrorCode.HERO_HERO_MAX); } - boolean result = ItemUtil.checkCost(user, sItem, itemNum,BIReason.COMPOS_HERO_CONSUME,itemId); - if (!result){ + boolean result = ItemUtil.checkCost(user, sItem, itemNum, BIReason.COMPOS_HERO_CONSUME, itemId); + if (!result) { throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); } - Map randomMap = new ConcurrentHashMap<>(); + Map randomMap = new ConcurrentHashMap<>(); randomMap.put(itemId, composeNum); - CommonProto.Drop.Builder drop = ItemUtil.useRandomItem(user,randomMap, BIReason.COMPOS_HERO_REWARD); - if(drop.getPokemonList().size()>0){ - fiveStarPokemonPushByCombine(user,drop.getPokemonList().get(0).getTempId(),composeNum); + CommonProto.Drop.Builder drop = ItemUtil.useRandomItem(user, randomMap, BIReason.COMPOS_HERO_REWARD); + if (drop.getPokemonList().size() > 0) { + fiveStarPokemonPushByCombine(user, drop.getPokemonList().get(0).getTempId(), composeNum); } HeroInfoProto.HeroComposeResponse heroComposeResponse = HeroInfoProto.HeroComposeResponse .newBuilder() .setDrop(drop) .build(); - if(!drop.getHeroList().isEmpty()){ - user.getUserMissionManager().onGameEvent(user,GameEvent.COMPOS_HERO,drop.getHero(0).getHeroId(),composeNum); + if (!drop.getHeroList().isEmpty()) { + user.getUserMissionManager().onGameEvent(user, GameEvent.COMPOS_HERO, drop.getHero(0).getHeroId(), composeNum); } - MessageUtil.sendMessage(iSession,1,msgId,heroComposeResponse,true); + MessageUtil.sendMessage(iSession, 1, msgId, heroComposeResponse, true); } public String getQuality(int natural) { - String quality = "N"; - switch (natural){ + String quality = "N"; + switch (natural) { case 2: quality = "SR"; break; @@ -3498,114 +3532,115 @@ public class HeroLogic{ /** * 计算队伍战力 + * * @param targetUser * @param teamId * @param isMyself - * @return - * - * // TODO isMyself ??? + * @return // TODO isMyself ??? */ - public int calTeamTotalForce(User targetUser,int teamId,boolean isMyself){ - int totalForce =0; + public int calTeamTotalForce(User targetUser, int teamId, boolean isMyself) { + int totalForce = 0; targetUser.getTeamPosManager().setCurTeamPosId(teamId); Map> teamPosForHero = targetUser.getTeamPosManager().getTeamPosForHero(); - if(teamPosForHero==null||teamPosForHero.size()<=0){ + if (teamPosForHero == null || teamPosForHero.size() <= 0) { return totalForce; } List teamPosHeroInfoList = teamPosForHero.get(teamId); - if(teamPosHeroInfoList == null || teamPosHeroInfoList.isEmpty()){ + if (teamPosHeroInfoList == null || teamPosHeroInfoList.isEmpty()) { return totalForce; } - int maxForceHero =0; - String heroid=""; + int maxForceHero = 0; + String heroid = ""; for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfoList) { Hero hero = targetUser.getHeroManager().getHero(teamPosHeroInfo.getHeroId()); if (hero == null) { // 助战获取,随后最好加上编队验证 - hero = HelpHeroLogic.getHelpHeroByHeroId(targetUser.getId(),teamPosHeroInfo.getHeroId()).getHero(); - if (hero == null){ + hero = HelpHeroLogic.getHelpHeroByHeroId(targetUser.getId(), teamPosHeroInfo.getHeroId()).getHero(); + if (hero == null) { continue; } } long force = calHeoForce(targetUser, hero, teamId); - if(maxForceHero heroList = sArenaRobotConfig.getHeroList(); int[] differDemonsId = sArenaRobotConfig.getDifferDemonsId(); int differDemonsLv = sArenaRobotConfig.getDifferDemonsLv(); int heroLevel = sArenaRobotConfig.getRoleLv(); - for(Integer heroTid :heroList){ + for (Integer heroTid : heroList) { SCHero scHero = SCHero.getsCHero().get(heroTid); - Map robotHeroAttribute = calRobotHeroAttribute(scHero, heroLevel, 0, differDemonsId, differDemonsLv,true); - totalForce+=calForce(robotHeroAttribute); + Map robotHeroAttribute = calRobotHeroAttribute(scHero, heroLevel, 0, differDemonsId, differDemonsLv, true); + totalForce += calForce(robotHeroAttribute); } return totalForce; } - public int calRobotYxldTotalForce( SArenaRobotConfig sArenaRobotConfig){ - int totalForce =0; + + public int calRobotYxldTotalForce(SArenaRobotConfig sArenaRobotConfig) { + int totalForce = 0; List heroList = sArenaRobotConfig.getHeroList(); List heroList2 = sArenaRobotConfig.getHeroList2(); List heroList3 = sArenaRobotConfig.getHeroList3(); int[] differDemonsId = sArenaRobotConfig.getDifferDemonsId(); int differDemonsLv = sArenaRobotConfig.getDifferDemonsLv(); int heroLevel = sArenaRobotConfig.getRoleLv(); - for(Integer heroTid :heroList){ + for (Integer heroTid : heroList) { SCHero scHero = SCHero.getsCHero().get(heroTid); - Map robotHeroAttribute = calRobotHeroAttribute(scHero, heroLevel, 0, differDemonsId, differDemonsLv,true); - int add =calForce(robotHeroAttribute); - sArenaRobotConfig.setYxldTotalForce1(sArenaRobotConfig.getYxldTotalForce1()+add); - totalForce+=add; + Map robotHeroAttribute = calRobotHeroAttribute(scHero, heroLevel, 0, differDemonsId, differDemonsLv, true); + int add = calForce(robotHeroAttribute); + sArenaRobotConfig.setYxldTotalForce1(sArenaRobotConfig.getYxldTotalForce1() + add); + totalForce += add; } - for(Integer heroTid :heroList2){ + for (Integer heroTid : heroList2) { SCHero scHero = SCHero.getsCHero().get(heroTid); - Map robotHeroAttribute = calRobotHeroAttribute(scHero, heroLevel, 0, differDemonsId, differDemonsLv,true); - int add =calForce(robotHeroAttribute); - sArenaRobotConfig.setYxldTotalForce2(sArenaRobotConfig.getYxldTotalForce2()+add); - totalForce+=add; + Map robotHeroAttribute = calRobotHeroAttribute(scHero, heroLevel, 0, differDemonsId, differDemonsLv, true); + int add = calForce(robotHeroAttribute); + sArenaRobotConfig.setYxldTotalForce2(sArenaRobotConfig.getYxldTotalForce2() + add); + totalForce += add; } - for(Integer heroTid :heroList3){ + for (Integer heroTid : heroList3) { SCHero scHero = SCHero.getsCHero().get(heroTid); - Map robotHeroAttribute = calRobotHeroAttribute(scHero, heroLevel, 0, differDemonsId, differDemonsLv,true); - int add =calForce(robotHeroAttribute); - sArenaRobotConfig.setYxldTotalForce3(sArenaRobotConfig.getYxldTotalForce3()+add); - totalForce+=add; + Map robotHeroAttribute = calRobotHeroAttribute(scHero, heroLevel, 0, differDemonsId, differDemonsLv, true); + int add = calForce(robotHeroAttribute); + sArenaRobotConfig.setYxldTotalForce3(sArenaRobotConfig.getYxldTotalForce3() + add); + totalForce += add; } return totalForce; } - public void calPercent(int[][] otherAttriMap,Map heroAttributeMap){ - for(int[] item : otherAttriMap){ + public void calPercent(int[][] otherAttriMap, Map heroAttributeMap) { + for (int[] item : otherAttriMap) { int propertyId = item[0]; int propertyValue = item[1]; - if(!heroAttributeMap.containsKey(propertyId)){ + if (!heroAttributeMap.containsKey(propertyId)) { continue; } long nums = propertyValue * heroAttributeMap.get(propertyId) / 100; - if(nums<=0){ + if (nums <= 0) { return; } - heroAttributeMap.put(propertyId,nums); + heroAttributeMap.put(propertyId, nums); } } //妖灵师是否在阵容中 - public boolean isInTeam(User user,String heroId,int teamId){ + public boolean isInTeam(User user, String heroId, int teamId) { Map> teamPosForHero = user.getTeamPosManager().getTeamPosForHero(); Set collect = teamPosForHero.entrySet().stream().filter(integerListEntry -> { @@ -3622,34 +3657,35 @@ public class HeroLogic{ //妖灵师是否在阵容中 - public boolean isBattleArray (User user,String heroId,int[] teamId){ + public boolean isBattleArray(User user, String heroId, int[] teamId) { Map> teamPosForHero = user.getTeamPosManager().getTeamPosForHero(); //判断是否不可下阵中有该英雄 List list = new ArrayList<>(); - Arrays.stream(teamId).forEach(i->list.add(i)); + Arrays.stream(teamId).forEach(i -> list.add(i)); AtomicBoolean result = isInTeams(user, heroId, teamId); //直接删除英雄 - if(result.get()){ - teamPosForHero.entrySet().stream().filter(entry-> - !list.contains(entry.getKey())).forEach(entry->{ + if (result.get()) { + teamPosForHero.entrySet().stream().filter(entry -> + !list.contains(entry.getKey())).forEach(entry -> { List value = entry.getValue(); Iterator it = value.iterator(); boolean needUpdate = false; - while(it.hasNext()){ + while (it.hasNext()) { TeamPosHeroInfo hero = it.next(); - if(hero.getHeroId().equals(heroId)){ - if(entry.getKey()==GlobalsDef.ENDLESS_TEAM&&user.getMapManager().getEndlessMapInfo().getEndlessHeroInfo().get(heroId)!=null){ + if (hero.getHeroId().equals(heroId)) { + if (entry.getKey() == GlobalsDef.ENDLESS_TEAM && user.getMapManager().getEndlessMapInfo().getEndlessHeroInfo().get(heroId) != null) { user.getMapManager().removeEndlessHero(heroId); } it.remove(); needUpdate = true; - }; - if(needUpdate){ - user.getTeamPosManager().updateTeamPosByTeamId(entry.getKey(),value); + } + ; + if (needUpdate) { + user.getTeamPosManager().updateTeamPosByTeamId(entry.getKey(), value); } } }); @@ -3657,46 +3693,46 @@ public class HeroLogic{ return result.get(); } - public AtomicBoolean isInTeams(User user,String heroId,int[] teamId){ + public AtomicBoolean isInTeams(User user, String heroId, int[] teamId) { Map> teamPosForHero = user.getTeamPosManager().getTeamPosForHero(); //判断是否不可下阵中有该英雄 AtomicBoolean result = new AtomicBoolean(true); List list = new ArrayList<>(); - Arrays.stream(teamId).forEach(i->list.add(i)); + Arrays.stream(teamId).forEach(i -> list.add(i)); - list.stream().filter(tId->teamPosForHero.containsKey(tId)).forEach(tId->teamPosForHero.get(tId).forEach(hero->{ - if(hero.getHeroId().equals(heroId)){ + list.stream().filter(tId -> teamPosForHero.containsKey(tId)).forEach(tId -> teamPosForHero.get(tId).forEach(hero -> { + if (hero.getHeroId().equals(heroId)) { result.set(false); } })); return result; } - private int[][] calPokemonAttribute(PokemonManager pokemonManager){ - Map pokemonAttributeMap = new HashMap<>(); + private int[][] calPokemonAttribute(PokemonManager pokemonManager) { + Map pokemonAttributeMap = new HashMap<>(); Map pokemonTeamMap = pokemonManager.getPokemonTeamMap(); - for(Map.Entry entry:pokemonTeamMap.entrySet()){ + for (Map.Entry entry : pokemonTeamMap.entrySet()) { Pokemon pokemon = pokemonManager.getPokemonMap().get(entry.getValue()); - Map oneAttrMap = new HashMap<>(); + Map oneAttrMap = new HashMap<>(); SSpiritAnimal animal = STableManager.getConfig(SSpiritAnimal.class).get(pokemon.getTmpId()); - oneAttrMap.put(GlobalsDef.HP_TYPE,(int)animal.getHp()); - oneAttrMap.put(GlobalsDef.ATTACK_TYPE,(int)animal.getAttack()); + oneAttrMap.put(GlobalsDef.HP_TYPE, (int) animal.getHp()); + oneAttrMap.put(GlobalsDef.ATTACK_TYPE, (int) animal.getAttack()); - oneAttrMap.put(GlobalsDef.PHYSICAL_DEFENCE_TYPE,(int)animal.getPhysicalDefence()); + oneAttrMap.put(GlobalsDef.PHYSICAL_DEFENCE_TYPE, (int) animal.getPhysicalDefence()); - oneAttrMap.put(GlobalsDef.MAGIC_DEFENCE_TYPE,(int)animal.getMagicDefence()); + oneAttrMap.put(GlobalsDef.MAGIC_DEFENCE_TYPE, (int) animal.getMagicDefence()); //等级增量 SSpiritAnimalLevel levelConfig = SSpiritAnimalLevel.configByQualityAndLevel.get(animal.getQuality()).get(pokemon.getLevel()); int[][] characterLevelPara = levelConfig.getCharacterLevelPara(); - for(int[] para:characterLevelPara){ - oneAttrMap.put(para[0],oneAttrMap.getOrDefault(para[0],0)+para[1]); + for (int[] para : characterLevelPara) { + oneAttrMap.put(para[0], oneAttrMap.getOrDefault(para[0], 0) + para[1]); } //星级增量 SSpiritAnimalStar starConfig = SSpiritAnimalStar.configByQualityAndStar.get(animal.getQuality()).get(pokemon.getStar()); int starPara = starConfig.getStarPara(); - for(int key:oneAttrMap.keySet()){ - pokemonAttributeMap.put(key,pokemonAttributeMap.getOrDefault(key, 0)+(int)(oneAttrMap.getOrDefault(key,0)*(1+starPara/10000d))); + for (int key : oneAttrMap.keySet()) { + pokemonAttributeMap.put(key, pokemonAttributeMap.getOrDefault(key, 0) + (int) (oneAttrMap.getOrDefault(key, 0) * (1 + starPara / 10000d))); } } int[][] resultArray = ItemUtil.mapToArray(pokemonAttributeMap); @@ -3705,63 +3741,66 @@ public class HeroLogic{ /** * 计算一个灵兽的属性 + * * @param pokemonManager * @return */ - private Map calOnePokemonAttribute(PokemonManager pokemonManager,String pokemonId){ + private Map calOnePokemonAttribute(PokemonManager pokemonManager, String pokemonId) { Pokemon pokemon = pokemonManager.getPokemonMap().get(pokemonId); - return calOnePokemonAttribute(pokemon.getTmpId(),pokemon.getStar(),pokemon.getLevel()); + return calOnePokemonAttribute(pokemon.getTmpId(), pokemon.getStar(), pokemon.getLevel()); } - public Map calOnePokemonAttribute(int tmpId,int star,int level){ - Map pokemonAttributeMap = new HashMap<>(); - Map oneAttrMap = new HashMap<>(); + + public Map calOnePokemonAttribute(int tmpId, int star, int level) { + Map pokemonAttributeMap = new HashMap<>(); + Map oneAttrMap = new HashMap<>(); SSpiritAnimal animal = STableManager.getConfig(SSpiritAnimal.class).get(tmpId); - oneAttrMap.put(GlobalsDef.HP_TYPE,(int)animal.getHp()); - oneAttrMap.put(GlobalsDef.ATTACK_TYPE,(int)animal.getAttack()); + oneAttrMap.put(GlobalsDef.HP_TYPE, (int) animal.getHp()); + oneAttrMap.put(GlobalsDef.ATTACK_TYPE, (int) animal.getAttack()); - oneAttrMap.put(GlobalsDef.PHYSICAL_DEFENCE_TYPE,(int)animal.getPhysicalDefence()); + oneAttrMap.put(GlobalsDef.PHYSICAL_DEFENCE_TYPE, (int) animal.getPhysicalDefence()); - oneAttrMap.put(GlobalsDef.MAGIC_DEFENCE_TYPE,(int)animal.getMagicDefence()); + oneAttrMap.put(GlobalsDef.MAGIC_DEFENCE_TYPE, (int) animal.getMagicDefence()); //等级增量 SSpiritAnimalLevel levelConfig = SSpiritAnimalLevel.configByQualityAndLevel.get(animal.getQuality()).get(level); int[][] characterLevelPara = levelConfig.getCharacterLevelPara(); - for(int[] para:characterLevelPara){ - oneAttrMap.put(para[0],oneAttrMap.getOrDefault(para[0],0)+para[1]); + for (int[] para : characterLevelPara) { + oneAttrMap.put(para[0], oneAttrMap.getOrDefault(para[0], 0) + para[1]); } //星级增量 SSpiritAnimalStar starConfig = SSpiritAnimalStar.configByQualityAndStar.get(animal.getQuality()).get(star); int starPara = starConfig.getStarPara(); - for(int key:oneAttrMap.keySet()){ - pokemonAttributeMap.put(key,pokemonAttributeMap.getOrDefault(key,0)+(int)(oneAttrMap.getOrDefault(key,0)*(1+starPara/10000d))); + for (int key : oneAttrMap.keySet()) { + pokemonAttributeMap.put(key, pokemonAttributeMap.getOrDefault(key, 0) + (int) (oneAttrMap.getOrDefault(key, 0) * (1 + starPara / 10000d))); } return pokemonAttributeMap; } /** * 获取一个灵兽的属性字符串 + * * @param propertyMap * @param level * @return */ - public StringBuilder getOnePokemonProperty(Map propertyMap,int level){ + public StringBuilder getOnePokemonProperty(Map propertyMap, int level) { StringBuilder builder = new StringBuilder(); builder.append(level); - for(int propId:pokemonTemplate){ + for (int propId : pokemonTemplate) { builder.append("#"); // Hit(53), // CureFacter(57), // TreatFacter(58), 这三个默认要给前端传1 - if(propId==HeroAttributeEnum.Hit.getPropertyId()||propId==HeroAttributeEnum.CureFacter.getPropertyId()||propId==HeroAttributeEnum.TreatFacter.getPropertyId()){ - builder.append(propertyMap.getOrDefault(propId,1)); - }else{ - builder.append(propertyMap.getOrDefault(propId,0)); + if (propId == HeroAttributeEnum.Hit.getPropertyId() || propId == HeroAttributeEnum.CureFacter.getPropertyId() || propId == HeroAttributeEnum.TreatFacter.getPropertyId()) { + builder.append(propertyMap.getOrDefault(propId, 1)); + } else { + builder.append(propertyMap.getOrDefault(propId, 0)); } } return builder; } //todo 灵兽 - public int calAllPokenmonForce(User user){ + public int calAllPokenmonForce(User user) { // Map pokemonAttributeMap = new HashMap<>(); // Map pokemonMap = user.getPokemonManager().getPokemonMap(); // for(Pokemon pokemon : pokemonMap.values()){ @@ -3773,8 +3812,7 @@ public class HeroLogic{ } - - private void combinePokemonAttribute(Map pokemonAttributeMap, Pokemon pokemon,boolean needExtra) { + private void combinePokemonAttribute(Map pokemonAttributeMap, Pokemon pokemon, boolean needExtra) { //todo 灵兽 // Map comonpentsLevelMap = pokemon.getComonpentsLevelMap(); // for (Map.Entry comonpentsLevelItem : comonpentsLevelMap.entrySet()) { @@ -3793,15 +3831,16 @@ public class HeroLogic{ // } } - public int calEquipForce(Equip equip){ - Map equipAttributeMap = new HashMap<>(); + public int calEquipForce(Equip equip) { + Map equipAttributeMap = new HashMap<>(); SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(equip.getEquipId()); Map propertyValueByIdMap = equip.getPropertyValueByIdMap(); Map secondValueByIdMap = equip.getSecondValueByIdMap(); - combinedAttribute(propertyValueByIdMap,equipAttributeMap); - combinedAttribute(secondValueByIdMap,equipAttributeMap); - return calForce(equipAttributeMap)+sEquipConfig.getScore(); + combinedAttribute(propertyValueByIdMap, equipAttributeMap); + combinedAttribute(secondValueByIdMap, equipAttributeMap); + return calForce(equipAttributeMap) + sEquipConfig.getScore(); } + //获取天赋异妖信息 public void getAllRingFire(ISession session) throws Exception { //todo 灵兽 @@ -3814,41 +3853,38 @@ public class HeroLogic{ // CommonProto.RingFireInfo ringFire = CBean2Proto.getRingFire(pokemon); // builder.addRingFireInfo(ringFire); // } - MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.GET_RINGFIRE_INFO_RESPONSE_VALUE,null,true); + MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.GET_RINGFIRE_INFO_RESPONSE_VALUE, null, true); } - - - - public String getEcoForce11A(User user){ + public String getEcoForce11A(User user) { StringBuilder append = new StringBuilder().append("["); append.append(calAllPokenmonForce(user)); - getTeamForceForUpload(append, user.getTeamPosManager().getTeamPosForHero().get(1),user,1); - getTeamForceForUpload(append, user.getTeamPosManager().getTeamPosForHero().get( GlobalsDef.TEAM_ARENA_DEFENSE),user, GlobalsDef.TEAM_ARENA_DEFENSE); + getTeamForceForUpload(append, user.getTeamPosManager().getTeamPosForHero().get(1), user, 1); + getTeamForceForUpload(append, user.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.TEAM_ARENA_DEFENSE), user, GlobalsDef.TEAM_ARENA_DEFENSE); append.append("]"); return append.toString(); } - public void getTeamForceForUpload( StringBuilder append, List teamPosHeroInfoList,User user,int teamID){ - if(teamPosHeroInfoList != null &&!teamPosHeroInfoList.isEmpty()){ + public void getTeamForceForUpload(StringBuilder append, List teamPosHeroInfoList, User user, int teamID) { + if (teamPosHeroInfoList != null && !teamPosHeroInfoList.isEmpty()) { HeroManager heroManager = user.getHeroManager(); Map heroMap = heroManager.getHeroMap(); - Map heroPosMap = new HashMap<>(5); - for(TeamPosHeroInfo teamPosHeroInfo: teamPosHeroInfoList){ + Map heroPosMap = new HashMap<>(5); + for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfoList) { String heroId = teamPosHeroInfo.getHeroId(); Hero hero = heroMap.get(heroId); - heroPosMap.put(teamPosHeroInfo.getPosition(), (int) calHeoForce(user,hero,teamID)); + heroPosMap.put(teamPosHeroInfo.getPosition(), (int) calHeoForce(user, hero, teamID)); } - for(int i=1;i<6;i++){ + for (int i = 1; i < 6; i++) { Integer force = heroPosMap.get(i); - if(force == null){ - force=0; + if (force == null) { + force = 0; } append.append(",").append(force); } - }else{ - for(int i=1;i<6;i++){ + } else { + for (int i = 1; i < 6; i++) { append.append(",").append(0); } } @@ -3856,11 +3892,12 @@ public class HeroLogic{ /** * 神将归元 + * * @param session * @param heroId * @throws Exception */ - public void heroBack(ISession session,String heroId) throws Exception { + public void heroBack(ISession session, String heroId) throws Exception { int returnPercent = SSpecialConfig.getIntegerValue(SSpecialConfig.HERO_RETURN_PERCENT); int uid = session.getUid(); int responseMsgId = MessageTypeProto.MessageType.HERO_RETURN_RESPONSE_VALUE; @@ -3868,15 +3905,15 @@ public class HeroLogic{ List heroList = new ArrayList<>(1); heroList.add(heroId); boolean teamCheck = false; - ErrorCode err = ItemLogic.getInstance().checkHeroResolve(heroList, user,teamCheck); - if(null!=err){ + ErrorCode err = ItemLogic.getInstance().checkHeroResolve(heroList, user, teamCheck); + if (null != err) { throw new ErrorCodeException(err); } Hero hero = user.getHeroManager().getHero(heroId); int[] growthSwitch = SCHero.getsCHero().get(hero.getTemplateId()).getGrowthSwitch(); - if(growthSwitch!=null&&growthSwitch.length>0){ - Set operateSet= Arrays.stream(growthSwitch).boxed().collect(Collectors.toSet()); - if(operateSet.contains(3)){ + if (growthSwitch != null && growthSwitch.length > 0) { + Set operateSet = Arrays.stream(growthSwitch).boxed().collect(Collectors.toSet()); + if (operateSet.contains(3)) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } } @@ -3884,25 +3921,25 @@ public class HeroLogic{ int templateId = hero.getTemplateId(); int star = hero.getStar(); Map sHeroReturnMap = SHeroReturn.sheroReturnMap.get(templateId); - int breakFloor = breakId==0?0:STableManager.getConfig(SCHeroRankUpConfig.class).get(breakId).getPhase()[1]; - if(sHeroReturnMap == null || !sHeroReturnMap.containsKey(breakFloor)){ + int breakFloor = breakId == 0 ? 0 : STableManager.getConfig(SCHeroRankUpConfig.class).get(breakId).getPhase()[1]; + if (sHeroReturnMap == null || !sHeroReturnMap.containsKey(breakFloor)) { throw new ErrorCodeException(ErrorCode.newDefineCode("not satisfy")); } SHeroReturn sHeroReturn = sHeroReturnMap.get(breakFloor); boolean b = ItemUtil.itemCost(user, sHeroReturn.getReturnConsume(), BIReason.HERO_BACK_CONSUME, templateId * 100 + star); - if(!b){ + if (!b) { throw new ErrorCodeException(ErrorCode.HERO_ITEM_NOT); } //单纯归元神将,不归元法宝 - CommonProto.Drop.Builder drop = heroBackDrop(user, heroList, returnPercent, BIReason.HERO_BACK_REWARD,false); + CommonProto.Drop.Builder drop = heroBackDrop(user, heroList, returnPercent, BIReason.HERO_BACK_REWARD, false); List itemList = drop.getItemlistList(); List itemId = new ArrayList<>(itemList.size()); List itemNum = new ArrayList<>(itemList.size()); - itemList.forEach(item->{ + itemList.forEach(item -> { itemId.add(item.getItemId()); - itemNum.add((int)item.getItemNum()); + itemNum.add((int) item.getItemNum()); }); - ReportUtil.onReportEvent(user,ReportEventEnum.HERO_COMPOSITION.getType(),String.valueOf(hero.getTemplateId()),hero.getLevel(user.getHeroManager()),hero.getStar(),itemId,itemNum); + ReportUtil.onReportEvent(user, ReportEventEnum.HERO_COMPOSITION.getType(), String.valueOf(hero.getTemplateId()), hero.getLevel(user.getHeroManager()), hero.getStar(), itemId, itemNum); hero.setLevel(1); hero.setBreakId(0); @@ -3910,29 +3947,30 @@ public class HeroLogic{ addOrUpdateHongmeng(session); HeroInfoProto.HeroReturnResponse build = HeroInfoProto.HeroReturnResponse.newBuilder().setDrop(drop).build(); - MessageUtil.sendMessage(session,1,responseMsgId,build,true); + MessageUtil.sendMessage(session, 1, responseMsgId, build, true); } /** * 法宝归元 + * * @param session * @param heroIdList * @throws Exception */ - public void especialEquipBack(ISession session,List heroIdList) throws Exception{ + public void especialEquipBack(ISession session, List heroIdList) throws Exception { User user = UserManager.getUser(session.getUid()); - Map dropMap = new HashMap<>(); - for(String heroId:heroIdList){ + Map dropMap = new HashMap<>(); + for (String heroId : heroIdList) { Hero hero = user.getHeroManager().getHero(heroId); - if(hero==null||hero.getEspecialEquipLevel()<=1){ + if (hero == null || hero.getEspecialEquipLevel() <= 1) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } Map dropTempMap = ItemLogic.getInstance().heroEspecialEquipReturnItem(hero); - if(dropTempMap==null){ + if (dropTempMap == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - dropTempMap.forEach((k,v)->dropMap.put(k,dropMap.getOrDefault(k, 0)+v)); - ReportUtil.onReportEvent(user,ReportEventEnum.TREASURE_COMPOSITION.getType(),hero.getTemplateId(),hero.getEspecialEquipLevel(),new ArrayList<>(dropMap.keySet()),new ArrayList<>(dropMap.values())); + dropTempMap.forEach((k, v) -> dropMap.put(k, dropMap.getOrDefault(k, 0) + v)); + ReportUtil.onReportEvent(user, ReportEventEnum.TREASURE_COMPOSITION.getType(), hero.getTemplateId(), hero.getEspecialEquipLevel(), new ArrayList<>(dropMap.keySet()), new ArrayList<>(dropMap.values())); hero.updateEspecial(1); } @@ -3941,36 +3979,37 @@ public class HeroLogic{ CommonProto.Drop.Builder drop = ItemUtil.drop(user, ItemUtil.mapToArray(dropMap), BIReason.ESPECIAL_BACK); HeroInfoProto.EspecialEquipBackResponse response = HeroInfoProto.EspecialEquipBackResponse.newBuilder().setDrop(drop).build(); - MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.ESPECIAL_EQUIP_BACK_RESPONSE_VALUE,response,true); + MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ESPECIAL_EQUIP_BACK_RESPONSE_VALUE, response, true); } /** * 归元掉落 + * * @param user * @param heroIds * @param returnPercent * @return * @throws Exception */ - public CommonProto.Drop.Builder heroBackDrop(User user,List heroIds,int returnPercent,int reason,boolean isAddEspecial)throws Exception{ - Map returnItemMap = new HashMap<>(); + public CommonProto.Drop.Builder heroBackDrop(User user, List heroIds, int returnPercent, int reason, boolean isAddEspecial) throws Exception { + Map returnItemMap = new HashMap<>(); Map equipMap = user.getEquipManager().getEquipMap(); - for(String heroId:heroIds){ - Hero hero = user.getHeroManager().getHero(heroId); + for (String heroId : heroIds) { + Hero hero = user.getHeroManager().getHero(heroId); //如果是进阶把装备、宝物返还 - if(reason==BIReason.UPHERO_DECOMPOS_HERO_REWARD){ + if (reason == BIReason.UPHERO_DECOMPOS_HERO_REWARD) { Map equipByPositionMap = hero.getEquipByPositionMap(); Map soulEquipByPositionMap = hero.getSoulEquipByPositionMap(); - if(equipByPositionMap!=null&&equipByPositionMap.size()>0){ - equipByPositionMap.forEach((k,v)->returnItemMap.put(v,returnItemMap.getOrDefault(v,0)+1)); + if (equipByPositionMap != null && equipByPositionMap.size() > 0) { + equipByPositionMap.forEach((k, v) -> returnItemMap.put(v, returnItemMap.getOrDefault(v, 0) + 1)); } - if(soulEquipByPositionMap!=null&&soulEquipByPositionMap.size()>0){ - soulEquipByPositionMap.forEach((k,v)->returnItemMap.put(v,returnItemMap.getOrDefault(v,0)+1)); + if (soulEquipByPositionMap != null && soulEquipByPositionMap.size() > 0) { + soulEquipByPositionMap.forEach((k, v) -> returnItemMap.put(v, returnItemMap.getOrDefault(v, 0) + 1)); } Set jewelInfo = new HashSet<>(hero.getJewelInfo()); - for(String equipId:jewelInfo){ - if(!equipMap.containsKey(equipId)){ + for (String equipId : jewelInfo) { + if (!equipMap.containsKey(equipId)) { continue; } equipMap.get(equipId).setHeroId(""); @@ -3980,34 +4019,34 @@ public class HeroLogic{ int breakId = hero.getBreakId(); int templateId = hero.getTemplateId(); Map sHeroReturnMap = SHeroReturn.sheroReturnMap.get(templateId); - int breakFloor = breakId==0?0:STableManager.getConfig(SCHeroRankUpConfig.class).get(breakId).getPhase()[1]; + int breakFloor = breakId == 0 ? 0 : STableManager.getConfig(SCHeroRankUpConfig.class).get(breakId).getPhase()[1]; SHeroReturn sHeroReturn = sHeroReturnMap.get(breakFloor); int[][] returnMaterials = sHeroReturn.getRankupReturn(); SHeroLevlConfig sHeroLevlConfig = SHeroLevlConfig.getsHeroLevlConfigMap().get(hero.getOriginalLevel()); int[][] levelReturn = ItemLogic.getInstance().itemReturnPercent(sHeroLevlConfig.getSumConsume(), returnPercent); //进阶材料返还乘万分比 - for(int i = 0 ; i especialEquipReturnItem = ItemLogic.getInstance().heroEspecialEquipReturnItem(hero); - if(especialEquipReturnItem!=null&&especialEquipReturnItem.size()>0){ - for(Map.Entry entry:especialEquipReturnItem.entrySet()){ - returnItemMap.put(entry.getKey(),returnItemMap.getOrDefault(entry.getKey(),0)+entry.getValue()); + Map especialEquipReturnItem = ItemLogic.getInstance().heroEspecialEquipReturnItem(hero); + if (especialEquipReturnItem != null && especialEquipReturnItem.size() > 0) { + for (Map.Entry entry : especialEquipReturnItem.entrySet()) { + returnItemMap.put(entry.getKey(), returnItemMap.getOrDefault(entry.getKey(), 0) + entry.getValue()); } } } int[][] resultDrop = new int[returnItemMap.size()][]; int index = 0; - for(Map.Entry entry:returnItemMap.entrySet()){ - resultDrop[index] = new int[]{entry.getKey(),entry.getValue()}; + for (Map.Entry entry : returnItemMap.entrySet()) { + resultDrop[index] = new int[]{entry.getKey(), entry.getValue()}; index++; } CommonProto.Drop.Builder drop = ItemUtil.drop(user, resultDrop, reason); @@ -4015,67 +4054,66 @@ public class HeroLogic{ } - public void changeHeroLockState(ISession session,String heroId,int lockState) throws Exception { + public void changeHeroLockState(ISession session, String heroId, int lockState) throws Exception { int uid = session.getUid(); int responseMsgId = MessageTypeProto.MessageType.HERO_LOCK_CHANGE_RESPONSE_VALUE; User user = UserManager.getUser(uid); Hero hero = user.getHeroManager().getHero(heroId); - if(hero == null){ + if (hero == null) { throw new ErrorCodeException(ErrorCode.newDefineCode("no hero")); } hero.setIsLock(lockState); - MessageUtil.sendMessage(session,1,responseMsgId,null,true); - LOGGER.info("the force={}",calHeoForce(user,hero,0)); + MessageUtil.sendMessage(session, 1, responseMsgId, null, true); + LOGGER.info("the force={}", calHeoForce(user, hero, 0)); } /** - * * 魂印相关 */ - public void wearSoulEquip(ISession iSession, HeroInfoProto.OptHeroSoul optHeroSoul, HeroInfoProto.OptHeroSoul unload) throws Exception { + public void wearSoulEquip(ISession iSession, HeroInfoProto.OptHeroSoul optHeroSoul, HeroInfoProto.OptHeroSoul unload) throws Exception { int uid = iSession.getUid(); User user = UserManager.getUser(uid); String heroId = optHeroSoul.getHeroId(); Hero hero = user.getHeroManager().getHero(heroId); - checkAllowedOpt(2,user,hero.getStar()); - checkAllowedWear(user,hero,optHeroSoul.getSoulEquipIdsList(),unload); - Map returnItems = new HashMap<>(); + checkAllowedOpt(2, user, hero.getStar()); + checkAllowedWear(user, hero, optHeroSoul.getSoulEquipIdsList(), unload); + Map returnItems = new HashMap<>(); Map soulEquipByPositionMap = hero.getSoulEquipByPositionMap(); - optHeroSoul.getSoulEquipIdsList().forEach(e->{ - if(soulEquipByPositionMap.containsKey(e.getPosition())){ + optHeroSoul.getSoulEquipIdsList().forEach(e -> { + if (soulEquipByPositionMap.containsKey(e.getPosition())) { returnItems.put(soulEquipByPositionMap.get(e.getPosition()), 1); } - hero.updateSoulEquipPositionMap(e.getPosition(),e.getEquipId()); + hero.updateSoulEquipPositionMap(e.getPosition(), e.getEquipId()); }); - ItemUtil.drop(user,ItemUtil.mapToArray(returnItems),BIReason.REPLACE_SOUL_REWARD); - if(isInTeam(user,heroId,1)){ + ItemUtil.drop(user, ItemUtil.mapToArray(returnItems), BIReason.REPLACE_SOUL_REWARD); + if (isInTeam(user, heroId, 1)) { Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(uid)); } - MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.SOUL_EQUIP_WEAR_RESPONSE_VALUE,null,true); + MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.SOUL_EQUIP_WEAR_RESPONSE_VALUE, null, true); } - private void checkAllowedWear(User user,Hero targetHero,List soulEquipIdsList, HeroInfoProto.OptHeroSoul unload) throws Exception { + private void checkAllowedWear(User user, Hero targetHero, List soulEquipIdsList, HeroInfoProto.OptHeroSoul unload) throws Exception { int targetHeroTid = targetHero.getTemplateId(); List equids = new ArrayList<>(); Map soulEquipByPositionMap = targetHero.getSoulEquipByPositionMap(); Collection values = soulEquipByPositionMap.values(); - for(HeroInfoProto.SoulEquipPos item:soulEquipIdsList){ - if(values.contains(item.getEquipId()) && soulEquipByPositionMap.get(item.getPosition()) != item.getEquipId()){ + for (HeroInfoProto.SoulEquipPos item : soulEquipIdsList) { + if (values.contains(item.getEquipId()) && soulEquipByPositionMap.get(item.getPosition()) != item.getEquipId()) { throw new ErrorCodeException(ErrorCode.SERVER_DEFINE); } } - soulEquipIdsList.forEach(e->equids.add(e.getEquipId())); + soulEquipIdsList.forEach(e -> equids.add(e.getEquipId())); List unloadSoulIds = new ArrayList<>(); Map heroMap = user.getHeroManager().getHeroMap(); - if(unload!=null && !StringUtil.isEmpty(unload.getHeroId())){ + if (unload != null && !StringUtil.isEmpty(unload.getHeroId())) { String heroId = unload.getHeroId(); List soulEquipIdsListUnload = unload.getSoulEquipIdsList(); Map unloadSoulEquipByPositionMap = heroMap.get(heroId).getSoulEquipByPositionMap(); - for(HeroInfoProto.SoulEquipPos soulEquipPos:soulEquipIdsListUnload){ + for (HeroInfoProto.SoulEquipPos soulEquipPos : soulEquipIdsListUnload) { unloadSoulIds.add(soulEquipPos.getEquipId()); - if(unloadSoulEquipByPositionMap.get(soulEquipPos.getPosition())!=soulEquipPos.getEquipId()){ + if (unloadSoulEquipByPositionMap.get(soulEquipPos.getPosition()) != soulEquipPos.getEquipId()) { throw new ErrorCodeException(ErrorCode.SERVER_DEFINE); } } @@ -4086,25 +4124,25 @@ public class HeroLogic{ Set cacheIds = new HashSet<>(); int userLevel = user.getPlayerInfoManager().getLevel(); - for(HeroInfoProto.SoulEquipPos item:soulEquipIdsList){ + for (HeroInfoProto.SoulEquipPos item : soulEquipIdsList) { int equipId = item.getEquipId(); int[] sign_locations = SSpecialConfig.getOnceArrayValue(SSpecialConfig.Sign_Location); - int position = item.getPosition()-1; - if(position<0||position>sign_locations.length|| position>sign_locations.length-1 || userLevel < sign_locations[position]){ + int position = item.getPosition() - 1; + if (position < 0 || position > sign_locations.length || position > sign_locations.length - 1 || userLevel < sign_locations[position]) { throw new ErrorCodeException(ErrorCode.SERVER_DEFINE); } SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(equipId); - if(sEquipConfig.getRangeHeroTids()!=null && !sEquipConfig.getRangeHeroTids().contains(targetHeroTid)){ + if (sEquipConfig.getRangeHeroTids() != null && !sEquipConfig.getRangeHeroTids().contains(targetHeroTid)) { throw new ErrorCodeException(ErrorCode.SERVER_DEFINE); } - if(sEquipConfig.getLimit()==1){ - if(cacheIds.isEmpty()){ - heroMap.values().forEach(hero->{ + if (sEquipConfig.getLimit() == 1) { + if (cacheIds.isEmpty()) { + heroMap.values().forEach(hero -> { cacheIds.addAll(hero.getSoulEquipByPositionMap().values()); }); cacheIds.removeAll(unloadSoulIds); } - if(cacheIds.contains(equipId)){ + if (cacheIds.contains(equipId)) { cacheIds.add(equipId); throw new ErrorCodeException(ErrorCode.SERVER_DEFINE); } @@ -4112,20 +4150,20 @@ public class HeroLogic{ } - if(!equids.isEmpty()){ - Map itemCost = new HashMap<>(); - equids.forEach(e->{ + if (!equids.isEmpty()) { + Map itemCost = new HashMap<>(); + equids.forEach(e -> { itemCost.put(e, 1); }); boolean b = ItemUtil.itemCost(user, itemCost, BIReason.SOUL_EQUIP_WEAR_CONSUME, targetHeroTid); - if(!b){ + if (!b) { throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); } } - if(unload!=null&&!StringUtil.isEmpty(unload.getHeroId())){ + if (unload != null && !StringUtil.isEmpty(unload.getHeroId())) { Hero hero = user.getHeroManager().getHero(unload.getHeroId()); List soulEquipIdsListUnload = unload.getSoulEquipIdsList(); - soulEquipIdsListUnload.forEach(e->{ + soulEquipIdsListUnload.forEach(e -> { hero.removeSoulEquip(e.getPosition()); }); } @@ -4138,24 +4176,24 @@ public class HeroLogic{ SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(targetId); int[][] resource = sEquipConfig.getResource(); - Map itemTemplateCost = new HashMap<>(); - Map itemReallyCost = new HashMap<>(); - soulIdList.forEach(e->{ + Map itemTemplateCost = new HashMap<>(); + Map itemReallyCost = new HashMap<>(); + soulIdList.forEach(e -> { - itemTemplateCost.put( STableManager.getConfig(SEquipConfig.class).get(e).getQuality(),itemTemplateCost.getOrDefault( STableManager.getConfig(SEquipConfig.class).get(e).getQuality(),0)+1); - itemReallyCost.put(e,itemReallyCost.getOrDefault(e, 0)+1); + itemTemplateCost.put(STableManager.getConfig(SEquipConfig.class).get(e).getQuality(), itemTemplateCost.getOrDefault(STableManager.getConfig(SEquipConfig.class).get(e).getQuality(), 0) + 1); + itemReallyCost.put(e, itemReallyCost.getOrDefault(e, 0) + 1); }); - Arrays.stream(resource).forEach(item->{ - itemReallyCost.put(item[0],itemReallyCost.getOrDefault(item[0], 0)+item[1]); + Arrays.stream(resource).forEach(item -> { + itemReallyCost.put(item[0], itemReallyCost.getOrDefault(item[0], 0) + item[1]); }); int[][] formula = sEquipConfig.getFormula(); - for(int[] item : formula){ - if(itemTemplateCost.getOrDefault(item[0],0)!=item[1]){ + for (int[] item : formula) { + if (itemTemplateCost.getOrDefault(item[0], 0) != item[1]) { throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); } } boolean b = ItemUtil.itemCost(user, itemReallyCost, BIReason.SOUL_EQUIP_MERGE_CONSUME, targetId); - if(!b){ + if (!b) { throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); } int[][] drop = new int[1][]; @@ -4165,74 +4203,74 @@ public class HeroLogic{ CommonProto.Drop.Builder dropBuilder = ItemUtil.drop(user, drop, 1); HeroInfoProto.MergeSoulResponse build = HeroInfoProto.MergeSoulResponse.newBuilder().setDrop(dropBuilder).build(); - MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.SOUL_MERGE_RESPONSE_VALUE,build,true); - ReportUtil.onReportEvent(user,ReportEventEnum.FATALITY_SYNTHESIS.getType(),targetId,"",soulIdList); + MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.SOUL_MERGE_RESPONSE_VALUE, build, true); + ReportUtil.onReportEvent(user, ReportEventEnum.FATALITY_SYNTHESIS.getType(), targetId, "", soulIdList); } public static void unloadSoulEquipOpt(ISession iSession, String heroId, List equipIdsList) throws Exception { - if(equipIdsList == null || equipIdsList.isEmpty()){ + if (equipIdsList == null || equipIdsList.isEmpty()) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } int uid = iSession.getUid(); User user = UserManager.getUser(uid); Hero hero = user.getHeroManager().getHero(heroId); Map soulEquipByPositionMap = hero.getSoulEquipByPositionMap(); - for(HeroInfoProto.SoulEquipPos e : equipIdsList){ + for (HeroInfoProto.SoulEquipPos e : equipIdsList) { Integer equid = soulEquipByPositionMap.get(e.getPosition()); - if(equid==null || equid!=e.getEquipId()){ + if (equid == null || equid != e.getEquipId()) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } } - Map returnItems = new HashMap<>(); - equipIdsList.forEach(e->{ + Map returnItems = new HashMap<>(); + equipIdsList.forEach(e -> { hero.removeSoulEquip(e.getPosition()); returnItems.put(e.getEquipId(), 1); }); Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(iSession.getUid())); - ItemUtil.drop(user, ItemUtil.mapToArray(returnItems),BIReason.UNLOAD_SOUL_REWARD); - MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.SOUL_EQUIP_UNLOAD_OPT_RESPONSE_VALUE,null,true); + ItemUtil.drop(user, ItemUtil.mapToArray(returnItems), BIReason.UNLOAD_SOUL_REWARD); + MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.SOUL_EQUIP_UNLOAD_OPT_RESPONSE_VALUE, null, true); } - public static void checkAllowedOpt(int type,User user, int heroStar) throws ErrorCodeException { + public static void checkAllowedOpt(int type, User user, int heroStar) throws ErrorCodeException { SGameSetting gameSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting(); - int[][] checkParms = null; - if(type == 1){ + int[][] checkParms = null; + if (type == 1) { checkParms = gameSetting.getEquipTalismanaUnlock(); - }else if(type == 2){ + } else if (type == 2) { checkParms = gameSetting.getEquipSignUnlock(); - }else { + } else { throw new ErrorCodeException(ErrorCode.SERVER_DEFINE); } - for(int[] item : checkParms){ - if(item[0] == 1 && user.getPlayerInfoManager().getLevel() equipHandBook = equipManager.getEquipHandBook(); HeroInfoProto.GetAllPropertyInfoResponse.Builder builder = HeroInfoProto.GetAllPropertyInfoResponse.newBuilder(); //添加灵兽羁绊 - for(int enabled:user.getPokemonManager().getPokemonBookEnabled()){ + for (int enabled : user.getPokemonManager().getPokemonBookEnabled()) { builder.addAllBookEnabled(enabled); } //添加英雄羁绊 - for (int enabled:user.getHeroManager().getHeroHandBookEnabled()){ + for (int enabled : user.getHeroManager().getHeroHandBookEnabled()) { builder.addAllBookEnabled(enabled); } //添加魂印羁绊 - for (int enabled:user.getEquipManager().getEquipBookEnabled()){ + for (int enabled : user.getEquipManager().getEquipBookEnabled()) { builder.addAllBookEnabled(enabled); } //添加白金装备羁绊 @@ -4240,33 +4278,35 @@ public class HeroLogic{ builder.addAllBookEnabled(enabled); } - for (Integer equip:equipManager.getEquipList()) { + for (Integer equip : equipManager.getEquipList()) { builder.addEquipGot(equip); } if (!user.getItemManager().getIsAbsEquip()) { for (Map.Entry equipEntry : user.getItemManager().getItemMap().entrySet()) { - if (SItem.getsItemMap().get(equipEntry.getKey()).getItemType()==3) { - user.getItemManager().setEquipBookMap(equipEntry.getValue().getItemId(),equipEntry.getValue().getItemNum()); + if (SItem.getsItemMap().get(equipEntry.getKey()).getItemType() == 3) { + user.getItemManager().setEquipBookMap(equipEntry.getValue().getItemId(), equipEntry.getValue().getItemNum()); } } for (Map.Entry stringHeroEntry : user.getHeroManager().getHeroMap().entrySet()) { for (Map.Entry entry : stringHeroEntry.getValue().getEquipByPositionMap().entrySet()) { - user.getItemManager().setEquipBookMap(entry.getValue(),1); + user.getItemManager().setEquipBookMap(entry.getValue(), 1); } } user.getItemManager().setAbsEquip(true); } for (Map.Entry entry : user.getItemManager().getEquipBookMap().entrySet()) { - CommonProto.EquipBookInfo equipBook=CommonProto.EquipBookInfo.newBuilder() + 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); + MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.GET_ALL_PROPERTY_INFO_RESPONSE_VALUE, builder.build(), true); } + /** * 激活所有图鉴 + * * @param session * @param bookId * @param messageType @@ -4275,113 +4315,115 @@ public class HeroLogic{ int uid = session.getUid(); User user = UserManager.getUser(uid); SSpiritAnimalBook bookConfig = STableManager.getConfig(SSpiritAnimalBook.class).get(bookId); - if(bookConfig==null){ + if (bookConfig == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - System.out.println(user.getPlayerInfoManager().getLevel()+":"+bookConfig.getOpenLevel()); - if(user.getPlayerInfoManager().getLevel() heroHandBook = heroManager.getHeroHandBook(); - Set hero=new HashSet<>(); + Set hero = new HashSet<>(); //将拥有的神将放到set集和中 - for(Map.Entry entry:heroHandBook.entrySet()){ - if (entry.getValue()!=0){ + for (Map.Entry entry : heroHandBook.entrySet()) { + if (entry.getValue() != 0) { hero.add(entry.getKey()); } } //判断羁绊神将是否在集合 - for(int[]tmp:teamers){ - if(!hero.contains(tmp[0])){ + for (int[] tmp : teamers) { + if (!hero.contains(tmp[0])) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } } //将羁绊加入神将羁绊集合 heroManager.addHeroHandBookEnabled(bookId); - drop = ItemUtil.drop(user,reward , BIReason.ACTIVATION_HERO_FETTER); + drop = ItemUtil.drop(user, reward, BIReason.ACTIVATION_HERO_FETTER); } //魂印激活 - if(bookConfig.getFetterType()==2){ + if (bookConfig.getFetterType() == 2) { EquipManager equipManager = user.getEquipManager(); - if(equipManager.getEquipBookEnabled().contains(bookId)){ + if (equipManager.getEquipBookEnabled().contains(bookId)) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - for (int[]equip:teamers){ - if (!equipManager.getEquipList().contains(equip[0])){ + for (int[] equip : teamers) { + if (!equipManager.getEquipList().contains(equip[0])) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } } equipManager.addEquipBookEnabled(bookId); - drop = ItemUtil.drop(user,reward , BIReason.ACTIVATION_HERO_FETTER); + drop = ItemUtil.drop(user, reward, BIReason.ACTIVATION_HERO_FETTER); } //灵兽激活 - if(bookConfig.getFetterType()==3){ + if (bookConfig.getFetterType() == 3) { PokemonManager pokemonManager = user.getPokemonManager(); - if(pokemonManager.getPokemonBookEnabled().contains(bookId)){ + if (pokemonManager.getPokemonBookEnabled().contains(bookId)) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - for(int[]pokemon:teamers){ - if(!pokemonManager.getPokemonGot().contains(pokemon[0])){ + 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); + drop = ItemUtil.drop(user, reward, BIReason.ACTIVATION_HERO_FETTER); } //白金装备激活 - if(bookConfig.getFetterType()==4){ + if (bookConfig.getFetterType() == 4) { ItemManager itemManager = user.getItemManager(); - if(itemManager.getEquipBookEnabled().contains(bookId)){ + 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]) pokemonMap = pokemonManager.getPokemonMap(); - Set removeKey = new HashSet<>(); - for(String key:pokemonMap.keySet()){ - if(key.length()<=2){ + Set removeKey = new HashSet<>(); + for (String key : pokemonMap.keySet()) { + if (key.length() <= 2) { removeKey.add(key); } } - for(String key:removeKey){ + for (String key : removeKey) { pokemonManager.removePokemon(key); } @@ -4389,14 +4431,14 @@ public class HeroLogic{ int pageSize = Global.SEND_CARD_COUNT; int index = 0; - for(Pokemon pokemon : pokemonMap.values()){ - if(index>=start&&index= start && index < start + pageSize) { pokemonInfoList.add(CBean2Proto.getPokemon(pokemon)); } index++; } HeroInfoProto.GetAllPokemonResponse.Builder builder = HeroInfoProto.GetAllPokemonResponse.newBuilder().addAllPokemonInfo(pokemonInfoList); - if(pokemonInfoList.size() teamPokemonInfos = new ArrayList<>(); for (Map.Entry entry : pokemonManager.getPokemonTeamMap().entrySet()) { CommonProto.TeamPokemonInfo teamPokemonInfo = CommonProto.TeamPokemonInfo.newBuilder() @@ -4408,11 +4450,12 @@ public class HeroLogic{ builder.addAllTeamPokemonInfos(teamPokemonInfos) .addAllPokemonGot(pokemonManager.getPokemonGot()); } - MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.GET_ALL_POKEMON_RESPONSE_VALUE,builder.build(),true); + MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_ALL_POKEMON_RESPONSE_VALUE, builder.build(), true); } /** * 保存异妖阵容 + * * @param session * @param teamPokemonInfos */ @@ -4457,6 +4500,7 @@ public class HeroLogic{ /** * 灵兽放生 + * * @param session * @param pokemonIds * @param pieceId @@ -4464,112 +4508,114 @@ public class HeroLogic{ * @param messageType * @throws Exception */ - public void pokemonFree(ISession session, List pokemonIds,int pieceId,int pieceAmount, MessageTypeProto.MessageType messageType) throws Exception { + public void pokemonFree(ISession session, List pokemonIds, int pieceId, int pieceAmount, MessageTypeProto.MessageType messageType) throws Exception { int uid = session.getUid(); User user = UserManager.getUser(uid); List config = SGlobalSystemConfig.idsByType.get(FunctionIdEnum.Pokemon.getFunctionType()); SGlobalSystemConfig sGlobalSystemConfig = STableManager.getConfig(SGlobalSystemConfig.class).get(config.iterator().next()); - if(user.getPlayerInfoManager().getLevel() returnMap = new HashMap<>(); + Map returnMap = new HashMap<>(); - if(!pokemonIds.isEmpty()){ + if (!pokemonIds.isEmpty()) { - for(String pokemonId:pokemonIds){ + for (String pokemonId : pokemonIds) { Pokemon pokemon = pokemonManager.getPokemonMap().get(pokemonId); - if(pokemon == null){ + if (pokemon == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - if(pokemonManager.getPokemonTeamMap().containsValue(pokemonId)){ + if (pokemonManager.getPokemonTeamMap().containsValue(pokemonId)) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - getPokemonReturnReward(pokemon,returnMap); + getPokemonReturnReward(pokemon, returnMap); SSpiritAnimal animalConfig = STableManager.getConfig(SSpiritAnimal.class).get(pokemon.getTmpId()); SSpiritAnimalStar starConfig = SSpiritAnimalStar.configByQualityAndStar.get(animalConfig.getQuality()).get(pokemon.getStar()); - int sumItemNum = starConfig.getSumItemNum()+1; + int sumItemNum = starConfig.getSumItemNum() + 1; int[] coinReturn = animalConfig.getCoinReturn(); - returnMap.put(coinReturn[0],returnMap.getOrDefault(coinReturn[0], 0)+coinReturn[1]*sumItemNum); + returnMap.put(coinReturn[0], returnMap.getOrDefault(coinReturn[0], 0) + coinReturn[1] * sumItemNum); } - for(String pokemonId:pokemonIds){ + for (String pokemonId : pokemonIds) { pokemonManager.removePokemon(pokemonId); } - }else{ + } else { SSpiritAnimal animal = SSpiritAnimal.pieceConfig.get(pieceId); - Map costMap = new HashMap<>(); - if(animal==null){ + Map costMap = new HashMap<>(); + if (animal == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } costMap.put(pieceId, pieceAmount); boolean checkCost = ItemUtil.checkCost(user, costMap); int[] piecesCoinReturn = animal.getPiecesCoinReturn(); - if(!checkCost){ + if (!checkCost) { throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); } - returnMap.put(piecesCoinReturn[0],returnMap.getOrDefault(piecesCoinReturn[0], 0)+piecesCoinReturn[1]*pieceAmount); - ItemUtil.itemCost(user,costMap,BIReason.SPECIAL_FREE_PIECE_CONSUME,1); + returnMap.put(piecesCoinReturn[0], returnMap.getOrDefault(piecesCoinReturn[0], 0) + piecesCoinReturn[1] * pieceAmount); + ItemUtil.itemCost(user, costMap, BIReason.SPECIAL_FREE_PIECE_CONSUME, 1); } CommonProto.Drop.Builder drop = ItemUtil.drop(user, ItemUtil.mapToArray(returnMap), BIReason.SPECIAL_FREE_PIECE_REWARD); HeroInfoProto.PokemonFreeResponse response = HeroInfoProto.PokemonFreeResponse.newBuilder().setDrop(drop).build(); - MessageUtil.sendMessage(session,1, messageType.getNumber(),response,true); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), response, true); } /** * 等级和星级返还 不包括本体返还 + * * @param pokemon * @param returnMap * @throws ErrorCodeException */ - private void getPokemonReturnReward(Pokemon pokemon,Map returnMap) throws ErrorCodeException { + private void getPokemonReturnReward(Pokemon pokemon, Map returnMap) throws ErrorCodeException { SSpiritAnimal animalConfig = STableManager.getConfig(SSpiritAnimal.class).get(pokemon.getTmpId()); SSpiritAnimalLevel levelConfig = SSpiritAnimalLevel.configByQualityAndLevel.get(animalConfig.getQuality()).get(pokemon.getLevel()); - if(levelConfig==null){ + if (levelConfig == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } SSpiritAnimalStar starConfig = SSpiritAnimalStar.configByQualityAndStar.get(animalConfig.getQuality()).get(pokemon.getStar()); - if(starConfig==null){ + if (starConfig == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } int[][] sumConsumeLevel = levelConfig.getSumConsume(); - if(pokemon.getLevel()!=1&&sumConsumeLevel!=null&&sumConsumeLevel.length>0&&sumConsumeLevel[0].length>0){ - for(int[] consume:sumConsumeLevel){ - returnMap.put(consume[0],returnMap.getOrDefault(consume[0], 0)+consume[1]); + if (pokemon.getLevel() != 1 && sumConsumeLevel != null && sumConsumeLevel.length > 0 && sumConsumeLevel[0].length > 0) { + for (int[] consume : sumConsumeLevel) { + returnMap.put(consume[0], returnMap.getOrDefault(consume[0], 0) + consume[1]); } } int[][] sumConsumeStar = starConfig.getSumConsume(); - if(pokemon.getStar()!=0&&sumConsumeStar!=null&&sumConsumeStar.length>0&&sumConsumeStar[0].length>0){ - for(int[] consume:sumConsumeStar){ - returnMap.put(consume[0],returnMap.getOrDefault(consume[0], 0)+consume[1]); + if (pokemon.getStar() != 0 && sumConsumeStar != null && sumConsumeStar.length > 0 && sumConsumeStar[0].length > 0) { + for (int[] consume : sumConsumeStar) { + returnMap.put(consume[0], returnMap.getOrDefault(consume[0], 0) + consume[1]); } } } /** * 灵兽升级 + * * @param session * @param pokemonId * @param level @@ -4581,76 +4627,76 @@ public class HeroLogic{ int uid = session.getUid(); User user = UserManager.getUser(uid); PokemonManager pokemonManager = user.getPokemonManager(); - if(!pokemonManager.getPokemonMap().containsKey(pokemonId)){ + if (!pokemonManager.getPokemonMap().containsKey(pokemonId)) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } Pokemon pokemon = pokemonManager.getPokemonMap().get(pokemonId); int oldLevel = pokemon.getLevel(); - if(level<=pokemon.getLevel()){ + if (level <= pokemon.getLevel()) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } SSpiritAnimal animal = STableManager.getConfig(SSpiritAnimal.class).get(pokemon.getTmpId()); - if(animal==null){ + if (animal == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - if(pokemon.getLevel()>=animal.getMaxLevel()||level>animal.getMaxLevel()){ + if (pokemon.getLevel() >= animal.getMaxLevel() || level > animal.getMaxLevel()) { throw new ErrorCodeException(ErrorCode.HERO_LEVE_MAX); } Map levelMap = SSpiritAnimalLevel.configByQualityAndLevel.get(animal.getQuality()); - Map costMap = new HashMap<>(); + Map costMap = new HashMap<>(); int finalLevel = pokemon.getLevel(); - for(int i = pokemon.getLevel();i0){ - for(int[] consumeOne:consume){ - costMap.put(consumeOne[0],costMap.getOrDefault(consumeOne[0],0)+consumeOne[1]); + if (consume != null && consume.length > 0) { + for (int[] consumeOne : consume) { + costMap.put(consumeOne[0], costMap.getOrDefault(consumeOne[0], 0) + consumeOne[1]); } } boolean b = ItemUtil.checkCost(user, costMap); - if(!b){ + if (!b) { //把多的这一次减下去 - if(consume!=null&&consume.length>0) { - for(int[] consumeOne:consume){ - costMap.put(consumeOne[0],costMap.getOrDefault(consumeOne[0], 0)-consumeOne[1]); + if (consume != null && consume.length > 0) { + for (int[] consumeOne : consume) { + costMap.put(consumeOne[0], costMap.getOrDefault(consumeOne[0], 0) - consumeOne[1]); } } finalLevel = i; break; } - finalLevel = i+1; + finalLevel = i + 1; } boolean itemCost = ItemUtil.itemCost(user, costMap, BIReason.SPECIAL_LEVEL_UP_CONSUME, 1); - if(!itemCost){ + if (!itemCost) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - pokemonManager.updatePokemonLevel(pokemonId,finalLevel); + pokemonManager.updatePokemonLevel(pokemonId, finalLevel); - if(pokemonManager.getPokemonTeamMap().containsValue(pokemonId)){ + if (pokemonManager.getPokemonTeamMap().containsValue(pokemonId)) { Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(session.getUid())); } HeroInfoProto.PokenmonUpLevelResponse response = HeroInfoProto.PokenmonUpLevelResponse.newBuilder().setLevel(finalLevel).build(); //发送成功消息 - MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), response, true); StringBuilder builder = new StringBuilder(); - for(Map.Entry entry:costMap.entrySet()){ - if(builder.length()>0){ + for (Map.Entry entry : costMap.entrySet()) { + if (builder.length() > 0) { builder.append("|"); } builder.append(entry.getKey()).append("#").append(entry.getValue()); } - ReportUtil.onReportEvent(user,ReportEventEnum.BEAST_LEVEL.getType(),pokemon.getTmpId(),oldLevel,finalLevel,builder.toString()); + ReportUtil.onReportEvent(user, ReportEventEnum.BEAST_LEVEL.getType(), pokemon.getTmpId(), oldLevel, finalLevel, builder.toString()); // user.getUserMissionManager().onGameEvent(user,GameEvent.POKEMON_UPLEVEL,pokemonId); @@ -4658,53 +4704,54 @@ public class HeroLogic{ /** * 灵兽升星 + * * @param session * @param pokemonId * @param consumePokemonIdsList * @throws Exception */ - public void pokemonAdvanced(ISession session,String pokemonId,List consumePokemonIdsList) throws Exception { + public void pokemonAdvanced(ISession session, String pokemonId, List consumePokemonIdsList) throws Exception { int uid = session.getUid(); User user = UserManager.getUser(uid); PokemonManager pokemonManager = user.getPokemonManager(); Pokemon pokemon = pokemonManager.getPokemonMap().get(pokemonId); - if(pokemon == null){ + if (pokemon == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } int oldStar = pokemon.getStar(); SSpiritAnimal animal = STableManager.getConfig(SSpiritAnimal.class).get(pokemon.getTmpId()); - if(animal==null){ + if (animal == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - if(pokemon.getStar()>=animal.getMaxStar()){ + if (pokemon.getStar() >= animal.getMaxStar()) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } Map configMap = SSpiritAnimalStar.configByQualityAndStar.get(animal.getQuality()); - if(!configMap.containsKey(pokemon.getStar())){ + if (!configMap.containsKey(pokemon.getStar())) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } SSpiritAnimalStar config = configMap.get(pokemon.getStar()); - if(config.getConsumeItemNum()!=consumePokemonIdsList.size()){ + if (config.getConsumeItemNum() != consumePokemonIdsList.size()) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } StringBuilder consumeBuilder = new StringBuilder(); - for(String consume:consumePokemonIdsList){ + for (String consume : consumePokemonIdsList) { Pokemon consumePokemon = pokemonManager.getPokemonMap().get(consume); - if(consumePokemon==null){ + if (consumePokemon == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - if(consumePokemon.getTmpId()!=pokemon.getTmpId()){ + if (consumePokemon.getTmpId() != pokemon.getTmpId()) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - if(consumePokemon.getLevel()!=1||consumePokemon.getStar()!=0){ + if (consumePokemon.getLevel() != 1 || consumePokemon.getStar() != 0) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - if(pokemonManager.getPokemonTeamMap().containsValue(consume)){ + if (pokemonManager.getPokemonTeamMap().containsValue(consume)) { throw new ErrorCodeException(ErrorCode.ITEM_DECOMPOSE_HERO_TEAM); } - if(consumeBuilder.length()>0){ + if (consumeBuilder.length() > 0) { consumeBuilder.append("|"); } consumeBuilder.append(consumePokemon.getTmpId()).append("-").append(1); @@ -4712,39 +4759,40 @@ public class HeroLogic{ } int[][] consumeRes = config.getConsumeRes(); boolean itemCost = ItemUtil.itemCost(user, consumeRes, BIReason.SPECIAL_STAR_UP_CONSUME, 1); - if(!itemCost){ + if (!itemCost) { throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); } - for(String consume:consumePokemonIdsList) { + for (String consume : consumePokemonIdsList) { pokemonManager.removePokemon(consume); } - pokemonManager.updatePokemonStar(pokemonId,pokemon.getStar()+1); - if(pokemonManager.getPokemonTeamMap().containsValue(pokemonId)){ + pokemonManager.updatePokemonStar(pokemonId, pokemon.getStar() + 1); + if (pokemonManager.getPokemonTeamMap().containsValue(pokemonId)) { Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(session.getUid())); } - if(animal.getQuality() >= SSpecialConfig.getIntegerValue(SSpecialConfig.ANIMAL_BROADCAST_QUALITY)) { //策划资质改成星级 + if (animal.getQuality() >= SSpecialConfig.getIntegerValue(SSpecialConfig.ANIMAL_BROADCAST_QUALITY)) { //策划资质改成星级 String nameColor = user.getPlayerInfoManager().getNameColor(); String message = SErrorCodeEerverConfig.getI18NMessageNeedConvert("animal_starup_broadcast_content", - new Object[]{nameColor, user.getPlayerInfoManager().getNickName(),animal.getName(),pokemon.getStar()}, - new int[]{0,0,1,0}); - if (!message.isEmpty()){ - ChatLogic.getInstance().sendSysChatMessage(message,Global.LUCKY_LUCK,"0",0,0,0,0,0); + new Object[]{nameColor, user.getPlayerInfoManager().getNickName(), animal.getName(), pokemon.getStar()}, + new int[]{0, 0, 1, 0}); + if (!message.isEmpty()) { + ChatLogic.getInstance().sendSysChatMessage(message, Global.LUCKY_LUCK, "0", 0, 0, 0, 0, 0); } } - MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.POKEMON_ADVANCED_RESPONSE_VALUE,null,true); - for(int[] consume:consumeRes){ - if(consumeBuilder.length()>0){ + MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.POKEMON_ADVANCED_RESPONSE_VALUE, null, true); + for (int[] consume : consumeRes) { + if (consumeBuilder.length() > 0) { consumeBuilder.append("|"); } consumeBuilder.append(consume[0]).append("#").append(consume[1]); } - ReportUtil.onReportEvent(user,ReportEventEnum.BEAST_STAR.getType(),pokemon.getTmpId(),oldStar,pokemon.getStar(),consumeBuilder.toString()); - BuyGoodsNewLogic.openPush(session,user, PushRechargeType.pokemon_star.getType(),pokemon.getStar(),1); + ReportUtil.onReportEvent(user, ReportEventEnum.BEAST_STAR.getType(), pokemon.getTmpId(), oldStar, pokemon.getStar(), consumeBuilder.toString()); + BuyGoodsNewLogic.openPush(session, user, PushRechargeType.pokemon_star.getType(), pokemon.getStar(), 1); } /** * 灵兽涅槃 + * * @param session * @param pokemonId * @param messageType @@ -4780,8 +4828,8 @@ public class HeroLogic{ returnMap.put(tmpId, returnMap.getOrDefault(tmpId, 0) + sumItemNum); } ItemUtil.itemCost(user, costMap, BIReason.SPECIAL_BACK_CONSUME, 1); - pokemonManager.updatePokemonLevel(pokemonId,1); - pokemonManager.updatePokemonStar(pokemonId,0); + pokemonManager.updatePokemonLevel(pokemonId, 1); + pokemonManager.updatePokemonStar(pokemonId, 0); CommonProto.Drop.Builder drop = ItemUtil.drop(user, ItemUtil.mapToArray(returnMap), BIReason.SPECIAL_MONSTER_REWARD); @@ -4791,9 +4839,9 @@ public class HeroLogic{ } - /** * 获取所有皮肤信息 + * * @param session * @param messageType */ @@ -4801,68 +4849,71 @@ public class HeroLogic{ User user = UserManager.getUser(session.getUid()); Map skinInfo = user.getHeroManager().getSkinInfo(); HeroInfoProto.GetAllSkinResponse.Builder response = HeroInfoProto.GetAllSkinResponse.newBuilder(); - Set removeId = new HashSet<>(skinInfo.size()+1); + Set removeId = new HashSet<>(skinInfo.size() + 1); - if(!skinInfo.isEmpty()){ - for(Map.Entry entry:skinInfo.entrySet()){ - if(entry.getValue()!=-1&&entry.getValue() entry : skinInfo.entrySet()) { + if (entry.getValue() != -1 && entry.getValue() < TimeUtils.nowInt()) { removeId.add(entry.getKey()); } } - if(!removeId.isEmpty()){ - for(int remove :removeId){ + if (!removeId.isEmpty()) { + for (int remove : removeId) { user.getHeroManager().removeSkin(remove); } } - skinInfo.forEach((k,v)->response.addSkinInfo(CommonProto.SkinInfo.newBuilder().setSkinId(k).setOverTime(v).build())); + skinInfo.forEach((k, v) -> response.addSkinInfo(CommonProto.SkinInfo.newBuilder().setSkinId(k).setOverTime(v).build())); } - MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), response.build(), true); } /** * 更换皮肤 + * * @param session * @param messageType */ - public void changeSkin(ISession session,String heroId,int skinId, MessageTypeProto.MessageType messageType) throws Exception { + public void changeSkin(ISession session, String heroId, int skinId, MessageTypeProto.MessageType messageType) throws Exception { User user = UserManager.getUser(session.getUid()); Map skinInfo = user.getHeroManager().getSkinInfo(); Hero hero = user.getHeroManager().getHero(heroId); - if(skinId!=0){ - if(!skinInfo.containsKey(skinId)||(skinInfo.get(skinId)!=-1&&skinInfo.get(skinId) 0){ + if (heroManager.getHongmengTablet() > 0) { // 等级 resonanceLevel.value = heroManager.getHongmengTablet(); tabletMax = heroManager.getHongmengMaxLevelByInt(); - }else { + } else { // 玩家英雄背包按等级排序 Collections.sort(heroes); for (int i = 0; i < heroes.size(); i++) { Hero hero = heroes.get(i); - resonances.forEach((k,v)->{ - if (v.equals(hero.getId())){ + resonances.forEach((k, v) -> { + if (v.equals(hero.getId())) { try { // 共鸣格子更新 unLoadResonance(session, MessageTypeProto.MessageType.HONGMENG_RESONANCE_RESPONSE, k, 0); @@ -4935,7 +4986,7 @@ public class HeroLogic{ } // 等级 hongmengLevel(resonanceLevel, hero); - hongmengs.put(i+1, hero.getId()); + hongmengs.put(i + 1, hero.getId()); if (hongmengs.size() >= Integer.parseInt(openLevel[0])) { break; } @@ -4957,7 +5008,7 @@ public class HeroLogic{ hero.setBreakId(0); } // 初始化鸿蒙碑等级上限 - for (Hero hero:heroes){ + for (Hero hero : heroes) { if (hero.getStar() >= SSpecialConfig.getIntegerValue(SSpecialConfig.lamp_awaken_hero_content_parm)) { heroManager.addHongmengMaxLevel(hero.getTemplateId()); } @@ -4968,7 +5019,7 @@ public class HeroLogic{ // 鸿蒙碑新手引导推送 HeroInfoProto.HongmengSteleNewHandIndication.Builder builder = HeroInfoProto.HongmengSteleNewHandIndication.newBuilder().setState(1); - MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.HONGMENG_STELE_NEW_HAND_INDICATION.getNumber(),builder.build(),true); + MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.HONGMENG_STELE_NEW_HAND_INDICATION.getNumber(), builder.build(), true); } } @@ -4982,10 +5033,10 @@ public class HeroLogic{ // 英雄装备 Map equipMap = user.getEquipManager().getEquipMap(); - if (guards.size() >= Integer.parseInt(openLevel[0])){ + if (guards.size() >= Integer.parseInt(openLevel[0])) { for (int i = 0; i < guards.size(); i++) { - Hero hero = user.getHeroManager().getHero(guards.get(i+1)); - if (hero == null){ + Hero hero = user.getHeroManager().getHero(guards.get(i + 1)); + if (hero == null) { // 找不到英雄,不存在这些共鸣属性 hongMengAddAttributeEquip = new HongMengAddAttribute(0, defaultValue); soulEquip = new HongMengAddAttribute(0, defaultValue); @@ -5030,7 +5081,7 @@ public class HeroLogic{ /*** ============================= 开始组装鸿蒙阵信息 ==================================== **/ // 当前时间,秒 - long now = TimeUtils.now()/1000; + long now = TimeUtils.now() / 1000; // 鸿蒙守卫 List hongmengGuardsProto = new ArrayList<>(); Map hongmengGuards = heroManager.getHongmengGuards(); @@ -5070,15 +5121,16 @@ public class HeroLogic{ .addAllHongmengResonacnes(hongmengResonancesProto).setHongmengTabletMax(tabletMax).build(); } // 返回协议 - if (judge){ + if (judge) { MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.HONGMENG_GET_INFO_RESPONSE_VALUE, hongmengInfoIndication.build(), true); - }else { - MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.HONGMENG_INFO_INDICATION_VALUE,hongmengInfoIndication.build(),true); + } else { + MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.HONGMENG_INFO_INDICATION_VALUE, hongmengInfoIndication.build(), true); } } /** * 鸿蒙阵对神将等级加成 + * * @param resonanceLevel * @param hero */ @@ -5091,6 +5143,7 @@ public class HeroLogic{ /** * 鸿蒙阵对法宝加成 + * * @param especialEquipLevel * @param hero */ @@ -5099,13 +5152,13 @@ public class HeroLogic{ SCHero hero1 = SCHero.getsCHero().get(hero.getTemplateId()); int[] equipTalismana = hero1.getEquipTalismana(); // 没有法宝 - if (equipTalismana == null || equipTalismana.length <= 0){ + if (equipTalismana == null || equipTalismana.length <= 0) { especialEquipLevel.value = -1; especialEquipLevel.heroTid = 0; return; } // 等级不足 - if (hero.getStar() < equipTalismana[0]){ + if (hero.getStar() < equipTalismana[0]) { especialEquipLevel.value = -1; especialEquipLevel.heroTid = 0; return; @@ -5118,8 +5171,9 @@ public class HeroLogic{ /** * 鸿蒙阵对魂宝灵宝加成 + * * @param jewelEquip - * @param type 1魂宝 2灵宝 + * @param type 1魂宝 2灵宝 * @param equipMap * @param hero */ @@ -5130,28 +5184,29 @@ public class HeroLogic{ for (String jewel : hero.getJewelInfo()) { // 玩家装备表里是否存在 PropertyItem propertyItem = equipMap.get(jewel); - if (propertyItem != null){ + if (propertyItem != null) { SJewelConfig config = STableManager.getConfig(SJewelConfig.class).get(propertyItem.getEquipId()); // location 1魂宝 2灵宝 if (config != null && config.getLocation() == type) { result = false; - if (propertyItem.getLevel() < jewelEquip.value){ + if (propertyItem.getLevel() < jewelEquip.value) { jewelEquip.value = propertyItem.getLevel(); jewelEquip.heroTid = hero.getTemplateId(); } } } } - if (result){ + if (result) { notJewelInit(jewelEquip); } } /** * 没有宝物时初始化 + * * @param jewels */ - private void notJewelInit(HongMengAddAttribute... jewels){ + private void notJewelInit(HongMengAddAttribute... jewels) { for (int i = 0; i < jewels.length; i++) { jewels[i].value = -1; jewels[i].heroTid = 0; @@ -5160,6 +5215,7 @@ public class HeroLogic{ /** * 鸿蒙阵对装备加成 + * * @param hongMengAddAttributeEquip * @param hero */ @@ -5168,7 +5224,7 @@ public class HeroLogic{ if (hero.getEquipByPositionMap().size() < 4) { hongMengAddAttributeEquip.value = -1; hongMengAddAttributeEquip.heroTid = 0; - }else if (hongMengAddAttributeEquip.value > 0) { + } else if (hongMengAddAttributeEquip.value > 0) { for (Integer value : hero.getEquipByPositionMap().values()) { SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(value); if (sEquipConfig == null) { @@ -5180,12 +5236,13 @@ public class HeroLogic{ hongMengAddAttributeEquip.value = sEquipConfig.getStar(); hongMengAddAttributeEquip.heroTid = hero.getTemplateId(); } - } + } } } /** * 开启共鸣区域格子 + * * @param session * @param messageType * @throws Exception @@ -5204,7 +5261,7 @@ public class HeroLogic{ throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } Map cost1 = new HashMap<>(1); - cost1.put(hongmeng.getPropPrice()[0], hongmeng.getPropPrice()[1]); + cost1.put(hongmeng.getPropPrice()[0], hongmeng.getPropPrice()[1]); boolean checkCost1 = ItemUtil.checkCost(user, cost1); if (checkCost1) { ItemUtil.itemCost(user, cost1, BIReason.OPEN_HONGMENG_GRAID, graidId); @@ -5222,7 +5279,7 @@ public class HeroLogic{ heroManager.setResonances(resonances); // 成就任务 - user.getUserMissionManager().onGameEvent(user,GameEvent.HONGMENG_RESONANCE_LATTICE,resonances.size()); + user.getUserMissionManager().onGameEvent(user, GameEvent.HONGMENG_RESONANCE_LATTICE, resonances.size()); MessageUtil.sendMessage(session, 1, messageType.getNumber(), null); } @@ -5230,10 +5287,11 @@ public class HeroLogic{ /** * 共鸣 + * * @param session * @param messageType - * @param heroId 需要共鸣的神将id - * @param index 需要放的共鸣区位置 + * @param heroId 需要共鸣的神将id + * @param index 需要放的共鸣区位置 */ public void resonance(ISession session, MessageTypeProto.MessageType messageType, String heroId, int index) throws Exception { User user = UserManager.getUser(session.getUid()); @@ -5254,7 +5312,7 @@ public class HeroLogic{ throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } Map resonancesTime = heroManager.getResonancesTime(); - if (resonancesTime.get(index) != null && resonancesTime.get(index) > TimeUtils.now()/1000) { + if (resonancesTime.get(index) != null && resonancesTime.get(index) > TimeUtils.now() / 1000) { LOGGER.info("resonance uid=>{} time =>{}", user.getId(), resonancesTime.get(index)); throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } @@ -5264,13 +5322,13 @@ public class HeroLogic{ if (hongMengAddAttribute.value != -1) { Map equipByPositionMap = hero.getEquipByPositionMap(); - if (equipByPositionMap.size() > 0){ + if (equipByPositionMap.size() > 0) { ArrayList strings = new ArrayList<>(); - equipByPositionMap.forEach((k,v)->{ + equipByPositionMap.forEach((k, v) -> { strings.add(String.valueOf(v)); }); // 卸下装备 - getInstance().unloadEquipOpt(session,heroId,strings,1); + getInstance().unloadEquipOpt(session, heroId, strings, 1); } equipByPositionMap.clear(); @@ -5278,7 +5336,7 @@ public class HeroLogic{ } // 战力改变 - if(isInTeam(user,heroId,1)){ + if (isInTeam(user, heroId, 1)) { Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(user.getId())); } @@ -5288,13 +5346,14 @@ public class HeroLogic{ /** * 卸下共鸣英雄 + * * @param session * @param messageType * @param index - * @param time 秒 + * @param time 秒 * @throws Exception */ - public void unLoadResonance(ISession session, MessageTypeProto.MessageType messageType, int index, int time) throws Exception{ + public void unLoadResonance(ISession session, MessageTypeProto.MessageType messageType, int index, int time) throws Exception { User user = UserManager.getUser(session.getUid()); HeroManager heroManager = user.getHeroManager(); Map resonances = heroManager.getResonances(); @@ -5310,10 +5369,10 @@ public class HeroLogic{ } heroManager.updateResonances(index, ""); - heroManager.updateResonancesTime(index, TimeUtils.now()/1000 + time); + heroManager.updateResonancesTime(index, TimeUtils.now() / 1000 + time); // 战力改变 - if(isInTeam(user,heroId,1)){ + if (isInTeam(user, heroId, 1)) { Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(user.getId())); } @@ -5323,6 +5382,7 @@ public class HeroLogic{ /** * 花费妖晶清除共鸣冷却时间 + * * @param session * @param messageType * @param index @@ -5331,7 +5391,7 @@ public class HeroLogic{ public void cleanTime(ISession session, MessageTypeProto.MessageType messageType, int index, int type) throws Exception { User user = UserManager.getUser(session.getUid()); HeroManager heroManager = user.getHeroManager(); - long now = TimeUtils.now()/1000; + long now = TimeUtils.now() / 1000; if (type == 1) { Map resonances = heroManager.getResonances(); String resonanceInfo = resonances.get(index); @@ -5347,10 +5407,10 @@ public class HeroLogic{ } String[] stringValue = SSpecialConfig.getStringValue(SSpecialConfig.HONGMENG_LATTICE_PRICE).split("#"); double time = (unloadTime - now); - double money = Integer.parseInt(stringValue[0]) *Integer.parseInt(stringValue[2]); - double count = Math.ceil (time / money); + double money = Integer.parseInt(stringValue[0]) * Integer.parseInt(stringValue[2]); + double count = Math.ceil(time / money); Map cost = new HashMap<>(1); - cost.put(Integer.parseInt(stringValue[1]), (int)count); + cost.put(Integer.parseInt(stringValue[1]), (int) count); boolean checkCost = ItemUtil.checkCost(user, cost); if (!checkCost) { LOGGER.info("cleanTime uid=>{} item not enough =>{}", user.getId(), unloadTime); @@ -5377,10 +5437,10 @@ public class HeroLogic{ } String[] stringValue = SSpecialConfig.getStringValue(SSpecialConfig.HONGMENG_LATTICE_PRICE).split("#"); double time = unloadTime - now; - double money = Integer.parseInt(stringValue[0]) *Integer.parseInt(stringValue[2]); - double count = Math.ceil (time / money); + double money = Integer.parseInt(stringValue[0]) * Integer.parseInt(stringValue[2]); + double count = Math.ceil(time / money); Map cost = new HashMap<>(1); - cost.put(Integer.parseInt(stringValue[1]), (int)count); + cost.put(Integer.parseInt(stringValue[1]), (int) count); boolean checkCost = ItemUtil.checkCost(user, cost); if (!checkCost) { LOGGER.info("cleanTime uid=>{} item not enough =>{}", user.getId(), unloadTime); @@ -5394,6 +5454,7 @@ public class HeroLogic{ /** * 升级鸿蒙碑 + * * @param session * @param messageType * @throws Exception @@ -5427,7 +5488,7 @@ public class HeroLogic{ // 战力改变 Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(user.getId())); // 成就任务 - user.getUserMissionManager().onGameEvent(user,GameEvent.HONGMENG_TABLET_LEVEL,heroManager.getHongmengTablet()); + user.getUserMissionManager().onGameEvent(user, GameEvent.HONGMENG_TABLET_LEVEL, heroManager.getHongmengTablet()); MessageUtil.sendMessage(session, 1, messageType.getNumber(), null); } @@ -5435,10 +5496,11 @@ public class HeroLogic{ /** * 添加鸿蒙碑神将 + * * @param session * @param messageType - * @param heroId 需要鸿蒙碑的神将id - * @param index 需要放的鸿蒙碑位置 + * @param heroId 需要鸿蒙碑的神将id + * @param index 需要放的鸿蒙碑位置 */ public void addHongmengTableHero(ISession session, MessageTypeProto.MessageType messageType, String heroId, int index) throws Exception { User user = UserManager.getUser(session.getUid()); @@ -5467,7 +5529,7 @@ public class HeroLogic{ throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } Map guardsTime = heroManager.getHongmengGuardTime(); - if (guardsTime.get(index) != null && guardsTime.get(index) > TimeUtils.now()/1000) { + if (guardsTime.get(index) != null && guardsTime.get(index) > TimeUtils.now() / 1000) { LOGGER.info("addHongmengTableHero uid=>{} time =>{}", user.getId(), guardsTime.get(index)); throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } @@ -5475,7 +5537,7 @@ public class HeroLogic{ heroManager.updateHongmengGuards(index, heroId); // 战力改变 - if(isInTeam(user,heroId,1)){ + if (isInTeam(user, heroId, 1)) { Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(user.getId())); } @@ -5487,12 +5549,13 @@ public class HeroLogic{ /** * 卸下鸿蒙碑英雄 + * * @param session * @param messageType * @param index * @throws Exception */ - public void unLoadHongmengTableHero(ISession session, MessageTypeProto.MessageType messageType, int index) throws Exception{ + public void unLoadHongmengTableHero(ISession session, MessageTypeProto.MessageType messageType, int index) throws Exception { User user = UserManager.getUser(session.getUid()); HeroManager heroManager = user.getHeroManager(); if (heroManager.getHongmengTablet() == 0) { @@ -5511,14 +5574,14 @@ public class HeroLogic{ throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } heroManager.updateHongmengGuards(index, ""); - heroManager.updateHongmengGuardTime(index, TimeUtils.now()/1000 + SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_LATTICE_WAIT_TIME)); + heroManager.updateHongmengGuardTime(index, TimeUtils.now() / 1000 + SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_LATTICE_WAIT_TIME)); HeroInfoProto.ResonanceResponse resonanceResponse = HeroInfoProto.ResonanceResponse .newBuilder() .setLeftTime(SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_LATTICE_WAIT_TIME)) .build(); // 战力改变 - if(isInTeam(user,heroId,1)){ + if (isInTeam(user, heroId, 1)) { Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(user.getId())); } @@ -5531,47 +5594,48 @@ public class HeroLogic{ * 判断功能是否允许使用 * 1|2|3|4|5|6|7|8|9 * 升级突破|升星觉醒|神将归元|恭送神将|被吞噬|法宝强化|法宝归元|强化宝物|神将置换 + * * @param uid * @param heroId * @param functionId * @return * @throws Exception */ - public boolean isUseFunction(int uid,int functionId,String... heroId) throws Exception { + public boolean isUseFunction(int uid, int functionId, String... heroId) throws Exception { User user = UserManager.getUser(uid); HeroManager heroManager = user.getHeroManager(); // 记录每个英雄 - Map heroMap = new HashMap<>(heroId.length); + Map heroMap = new HashMap<>(heroId.length); for (int i = 0; i < heroId.length; i++) { // 属性初始化 int[] value = null; - heroMap.put(heroId[i],false); + heroMap.put(heroId[i], false); - if ("".equals(heroId[i]) || heroId[i] == null){ - heroMap.put(heroId[i],true); + if ("".equals(heroId[i]) || heroId[i] == null) { + heroMap.put(heroId[i], true); continue; } // 鸿蒙守卫 - if (heroManager.getHongmengTablet() <= 0 && heroManager.getHongmengGuards().values().contains(heroId[i])){ + if (heroManager.getHongmengTablet() <= 0 && heroManager.getHongmengGuards().values().contains(heroId[i])) { value = SSpecialConfig.getOnceArrayValue(SSpecialConfig.HONGMENG_GUARD_LIMIT); } // 鸿蒙使者 - if (heroManager.getHongmengTablet() > 0 && heroManager.getHongmengGuards().values().contains(heroId[i])){ + if (heroManager.getHongmengTablet() > 0 && heroManager.getHongmengGuards().values().contains(heroId[i])) { value = SSpecialConfig.getOnceArrayValue(SSpecialConfig.HONGMENG_MESSENGER_LIMIT); } // 共鸣神将 - if (heroManager.getResonances().values().contains(heroId[i])){ + if (heroManager.getResonances().values().contains(heroId[i])) { value = SSpecialConfig.getOnceArrayValue(SSpecialConfig.HONGMENG_TAKE_LIMIT); } - if (value == null){ - heroMap.put(heroId[i],true); + if (value == null) { + heroMap.put(heroId[i], true); continue; } // 包含类型,返回false for (int j = 0; j < value.length; j++) { - if (value[j] == functionId){ - heroMap.put(heroId[i],true); + if (value[j] == functionId) { + heroMap.put(heroId[i], true); break; } } @@ -5582,6 +5646,7 @@ public class HeroLogic{ /** * 获取指定英雄数量的平均等级 + * * @param user * @param averageNum * @return @@ -5589,7 +5654,7 @@ public class HeroLogic{ public int getAverageLevel(User user, int averageNum) throws ErrorCodeException { HeroManager heroManager = user.getHeroManager(); - int num = heroManager.getHeroMap().size() > averageNum?averageNum:heroManager.getHeroMap().size(); + int num = heroManager.getHeroMap().size() > averageNum ? averageNum : heroManager.getHeroMap().size(); // 获取玩家全部英雄 Collection values = heroManager.getHeroMap().values(); @@ -5603,18 +5668,19 @@ public class HeroLogic{ count += heroes.get(i).getLevel(heroManager); } // 避免zero异常 - if (count == 0){ + if (count == 0) { throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE); } - return count/averageNum; + return count / averageNum; } /** * 获取玩家最大等级的英雄 + * * @param user * @return */ - public static Hero getHeroByMaxLevel(User user){ + public static Hero getHeroByMaxLevel(User user) { // 获取玩家全部英雄 Collection values = user.getHeroManager().getHeroMap().values(); List heroes = new ArrayList<>(values); @@ -5624,51 +5690,52 @@ public class HeroLogic{ } /** - *五星推送 + * 五星推送 */ - public static void fiveStarPushByRandom(User user,int[][] getHeros){ + public static void fiveStarPushByRandom(User user, int[][] getHeros) { int fiveStarNum = 0; - for(int[] i : getHeros){ + for (int[] i : getHeros) { SCHero scHero = SCHero.getsCHero().get(i[0]); - if(scHero != null && scHero.getStar()==5){ + if (scHero != null && scHero.getStar() == 5) { fiveStarNum++; } } - if(fiveStarNum > 0){ - Poster.getPoster().dispatchEvent(new HeroFiveStarGetEvent(user.getId(),5,fiveStarNum)); + if (fiveStarNum > 0) { + Poster.getPoster().dispatchEvent(new HeroFiveStarGetEvent(user.getId(), 5, fiveStarNum)); } } /** - *五星灵兽推送 + * 五星灵兽推送 */ - public static void fiveStarPokemonPushByRandom(User user,int[][] getHeros) throws Exception{ + public static void fiveStarPokemonPushByRandom(User user, int[][] getHeros) throws Exception { int fiveStarNum = 0; - for(int[] i : getHeros){ + for (int[] i : getHeros) { SSpiritAnimal ssa = SSpiritAnimal.mapConfig.get(i[0]); - if(ssa != null && ssa.getQuality()==5){ + if (ssa != null && ssa.getQuality() == 5) { fiveStarNum++; - Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.random_pokemon.getType(),1)); + Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.random_pokemon.getType(), 1)); } } - if(fiveStarNum > 0){ - Poster.getPoster().dispatchEvent(new PokemonFiveStarGetEvent(user.getId(),5,fiveStarNum)); + if (fiveStarNum > 0) { + Poster.getPoster().dispatchEvent(new PokemonFiveStarGetEvent(user.getId(), 5, fiveStarNum)); } } /** - *五星灵兽合成推送 + * 五星灵兽合成推送 */ - public static void fiveStarPokemonPushByCombine(User user,int itemId,int num) throws Exception{ + public static void fiveStarPokemonPushByCombine(User user, int itemId, int num) throws Exception { SSpiritAnimal ssa = SSpiritAnimal.mapConfig.get(itemId); - if(ssa != null && ssa.getQuality()==5){ - Poster.getPoster().dispatchEvent(new PokemonFiveStarGetEvent(user.getId(),5,num)); + if (ssa != null && ssa.getQuality() == 5) { + Poster.getPoster().dispatchEvent(new PokemonFiveStarGetEvent(user.getId(), 5, num)); } } /** * 推送紫府神印消息 + * * @param uid * @throws Exception */ @@ -5679,13 +5746,14 @@ public class HeroLogic{ HeroInfoProto.PurpleMansionSealIndication build2 = HeroInfoProto.PurpleMansionSealIndication.newBuilder().addAllSealList(sealInfo).build(); ISession session = OnlineUserManager.getSessionByUid(user.getId()); - MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.PurpleMansionSealIndication_VALUE,build2,true); + MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.PurpleMansionSealIndication_VALUE, build2, true); } + ///0点重置好感度赠送次数 - public void ResetLikableSendTime(User user,PlayerInfoProto.FivePlayerUpdateIndication.Builder fBuilder){ + public void ResetLikableSendTime(User user, PlayerInfoProto.FivePlayerUpdateIndication.Builder fBuilder) { user.getHeroManager().UpdateLikableSendTime(0); - int remainTime=SSpecialConfig.getIntegerValue(SSpecialConfig.LIKE_ABILITY)-user.getHeroManager().getLikableSendTime(); + int remainTime = SSpecialConfig.getIntegerValue(SSpecialConfig.LIKE_ABILITY) - user.getHeroManager().getLikableSendTime(); fBuilder.setLikableRemainTime(remainTime); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java index 31ddbaeea..4fdabae7b 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java @@ -261,46 +261,83 @@ public class FightDataUtil { return teamSkill; } for (int i = 0; i < pokemonUnitList.size(); i++) { - String skillId = pokemonUnitList.get(i).getUnitSkillIds(); - if(skillId.equals("0")){ + CommonProto.FightUnitInfo unitInfo=pokemonUnitList.get(i); + String skillId = unitInfo.getUnitSkillIds(); + if(skillId.equals("0")||skillId==""){ continue; } - SSpiritAnimalSkill sSpiritAnimalSkill = STableManager.getConfig(SSpiritAnimalSkill.class).get(Integer.valueOf(skillId)); - LuaValue monster = new LuaTable(); - monster.set("id",sSpiritAnimalSkill.getSpiritAnimalMatch()); - monster.set("star",sSpiritAnimalSkill.getStarMatch()); - monster.set("camp",camp); - monster.set("position",pokemonUnitList.get(i).getPosition()); - LuaValue skill= new LuaTable(); - int[] skillIDList = sSpiritAnimalSkill.getSkillIDList(); - for(int j = 0 ; j 0&&releaseLimit[0].length>0){ - for(int l = 0 ; l0&&releaseLimit[0].length>0){ + for(int l = 0 ; l0&&releaseLimit[0].length>0){ + for(int l = 0 ; l0){ // teamSkill.rawset(i + 1, getSkill(skillAndPosItem[1],skillAndPosItem[0])); // } - teamSkill.rawset(i+1,monster); + teamSkill.rawset(i+1,monster); + } } return teamSkill; } diff --git a/tablemanager/src/main/java/config/SPlayerSkill.java b/tablemanager/src/main/java/config/SPlayerSkill.java index b1b2b17c6..2cd094dbe 100644 --- a/tablemanager/src/main/java/config/SPlayerSkill.java +++ b/tablemanager/src/main/java/config/SPlayerSkill.java @@ -29,6 +29,10 @@ public class SPlayerSkill implements BaseConfig { private int sort; + private int[] warEffectCount; + + private int[] turnEffectCount; + private static Map>mapData; public static Map sPrivilegeTypeConfigMap; @@ -87,7 +91,15 @@ public class SPlayerSkill implements BaseConfig { return sort; } - public static SPlayerSkill GetSPlayerSkill(int skillId,int skillLv){ + public int[] getWarEffectCount() { + return warEffectCount; + } + + public int[] getTurnEffectCount() { + return turnEffectCount; + } + + public static SPlayerSkill GetSPlayerSkill(int skillId, int skillLv){ if (!mapData.containsKey(skillId)||!mapData.get(skillId).containsKey(skillLv))return null; return mapData.get(skillId).get(skillLv); }