diff --git a/netty/src/main/java/com/ljsd/jieling/tools/Utils.java b/netty/src/main/java/com/ljsd/jieling/tools/Utils.java index 7b1e2cfb4..2a4ba7844 100644 --- a/netty/src/main/java/com/ljsd/jieling/tools/Utils.java +++ b/netty/src/main/java/com/ljsd/jieling/tools/Utils.java @@ -165,6 +165,27 @@ public class Utils { return map; } + // map做减法 + public static Map subtractMaps(Map map1, Map map2) { + Map result = new HashMap<>(map1); + + for (Map.Entry entry : map2.entrySet()) { + int key = entry.getKey(); + long value = entry.getValue(); + + if (result.containsKey(key)) { + long remainingValue = result.get(key) - value; + if (remainingValue > 0) { + result.put(key, remainingValue); + } else { + result.remove(key); + } + } + } + + return result; + } + /** * map转二维数组 */ diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java index d78b5be4c..c77529d72 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java @@ -373,56 +373,56 @@ public class MapLogic { * @return * @throws Exception */ - public String initTeamInfo(int teamId, int uid, User user, MapManager mapManager, int initType) throws Exception { - List teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId); - if (teamPosHeroInfos == null || teamPosHeroInfos.isEmpty()) { - return "阵容不存在"; - } - List heroes = new ArrayList<>(teamPosHeroInfos.size()); - Map> heroAllAttributeMap = new HashMap<>(teamPosHeroInfos.size()); - for (TeamPosHeroInfo heroInfo : teamPosHeroInfos) { - Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId()); - if (hero == null) { - break; - } - Map heroAllAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, teamId); - TimeControllerOfFunction timeControllerOfFunction = GlobalDataManaager.getInstance().getTimeControllerOfFunctionByFunctinoType(FunctionIdEnum.Endless); - if (teamId == TeamEnum.ENDLESS_TEAM.getTeamId() && user.getMapManager().getEndlessMapInfo().getSeason() == timeControllerOfFunction.getTimes()) { - Map endlessHeroInfo = user.getMapManager().getEndlessMapInfo().getEndlessHeroInfo(); - if (endlessHeroInfo != null && endlessHeroInfo.size() > 0) { - if (initType != 2) { - Integer heroPercent = endlessHeroInfo.get(heroInfo.getHeroId()); - if (heroPercent != null) { - int curHp = (int) ((double) heroPercent / 10000 * heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())); - heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), (long) curHp); - } - } else { - mapManager.updateEndlessHeroHp(hero.getId(), 10000); - } - } - } - - heroAllAttributeMap.put(hero.getId(), heroAllAttribute); - heroes.add(heroInfo.getHeroId()); - } - if (heroes.size() != teamPosHeroInfos.size()) { - LOGGER.info("enterMap() uid=>{} team pos is wrong ", uid, teamId); - return "阵容有误"; - } - if (2 == initType && teamId != TeamEnum.ENDLESS_TEAM.getTeamId()) { - Map foodBufferMap = mapManager.getFoodBufferMap(); - for (Map.Entry item : foodBufferMap.entrySet()) { - Integer value = item.getValue(); - if (value <= -1) { - SFoodsConfig sFoodsConfig = STableManager.getConfig(SFoodsConfig.class).get(item.getKey()); - CombatLogic.getInstance().updateHeroAttributJustOne(user, teamPosHeroInfos, sFoodsConfig, heroAllAttributeMap, true); - } - } - } - - mapManager.setTeamId(teamId); - mapManager.setHeroAllAttributeMap(heroAllAttributeMap); - return ""; + public void initTeamInfo(int teamId, int uid, User user, MapManager mapManager, int initType) throws Exception { +// List teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId); +// if (teamPosHeroInfos == null || teamPosHeroInfos.isEmpty()) { +// return "阵容不存在"; +// } +// List heroes = new ArrayList<>(teamPosHeroInfos.size()); +// Map> heroAllAttributeMap = new HashMap<>(teamPosHeroInfos.size()); +// for (TeamPosHeroInfo heroInfo : teamPosHeroInfos) { +// Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId()); +// if (hero == null) { +// break; +// } +// Map heroAllAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, teamId); +// TimeControllerOfFunction timeControllerOfFunction = GlobalDataManaager.getInstance().getTimeControllerOfFunctionByFunctinoType(FunctionIdEnum.Endless); +// if (teamId == TeamEnum.ENDLESS_TEAM.getTeamId() && user.getMapManager().getEndlessMapInfo().getSeason() == timeControllerOfFunction.getTimes()) { +// Map endlessHeroInfo = user.getMapManager().getEndlessMapInfo().getEndlessHeroInfo(); +// if (endlessHeroInfo != null && endlessHeroInfo.size() > 0) { +// if (initType != 2) { +// Integer heroPercent = endlessHeroInfo.get(heroInfo.getHeroId()); +// if (heroPercent != null) { +// int curHp = (int) ((double) heroPercent / 10000 * heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())); +// heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), (long) curHp); +// } +// } else { +// mapManager.updateEndlessHeroHp(hero.getId(), 10000); +// } +// } +// } +// +// heroAllAttributeMap.put(hero.getId(), heroAllAttribute); +// heroes.add(heroInfo.getHeroId()); +// } +// if (heroes.size() != teamPosHeroInfos.size()) { +// LOGGER.info("enterMap() uid=>{} team pos is wrong ", uid, teamId); +// return "阵容有误"; +// } +// if (2 == initType && teamId != TeamEnum.ENDLESS_TEAM.getTeamId()) { +// Map foodBufferMap = mapManager.getFoodBufferMap(); +// for (Map.Entry item : foodBufferMap.entrySet()) { +// Integer value = item.getValue(); +// if (value <= -1) { +// SFoodsConfig sFoodsConfig = STableManager.getConfig(SFoodsConfig.class).get(item.getKey()); +// CombatLogic.getInstance().updateHeroAttributJustOne(user, teamPosHeroInfos, sFoodsConfig, heroAllAttributeMap, true); +// } +// } +// } +// +// mapManager.setTeamId(teamId); +// mapManager.setHeroAllAttributeMap(heroAllAttributeMap); +// return ""; } // public void cellToProto(List cells, Map.Entry entry) { diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/mapType/AbstractMap.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/mapType/AbstractMap.java index e44265251..75c92b489 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/mapType/AbstractMap.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/mapType/AbstractMap.java @@ -1,46 +1,31 @@ package com.ljsd.jieling.handler.map.mapType; -import com.googlecode.protobuf.format.JsonFormat; -import com.ljsd.fight.CheckFight; -import com.ljsd.fight.FightType; import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig; -import com.ljsd.jieling.core.GlobalsDef; -import com.ljsd.jieling.db.redis.RedisKey; -import com.ljsd.jieling.db.redis.RedisUtil; import com.ljsd.jieling.exception.ErrorCode; import com.ljsd.jieling.exception.ErrorCodeException; - -import com.ljsd.jieling.globals.BIReason; -import com.ljsd.jieling.handler.map.*; - +import com.ljsd.jieling.handler.map.Cell; +import com.ljsd.jieling.handler.map.EventType; +import com.ljsd.jieling.handler.map.MapLogic; +import com.ljsd.jieling.handler.map.MapManager; import com.ljsd.jieling.handler.map.behavior.BaseBehavior; -import com.ljsd.jieling.handler.map.behavior.BehaviorUtil; import com.ljsd.jieling.handler.mission.Mission; import com.ljsd.jieling.logic.activity.event.Poster; import com.ljsd.jieling.logic.activity.event.StoryEvent; -import com.ljsd.jieling.logic.dao.Hero; -import com.ljsd.jieling.logic.dao.TeamPosHeroInfo; import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.root.User; - -import com.ljsd.jieling.logic.hero.HeroAttributeEnum; -import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.logic.store.StoreLogic; import com.ljsd.jieling.logic.store.StoreType; -import rpc.protocols.CommonProto; -import rpc.protocols.FightInfoProto; -import rpc.protocols.MapInfoProto; -import com.ljsd.jieling.util.*; +import com.ljsd.jieling.util.CBean2Proto; import config.*; import manager.STableManager; -import org.luaj.vm2.LuaValue; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ConfigurableApplicationContext; +import rpc.protocols.CommonProto; +import rpc.protocols.FightInfoProto; +import rpc.protocols.MapInfoProto; import util.CellUtil; -import util.MathUtils; -import util.TimeUtils; import java.util.*; @@ -221,32 +206,31 @@ public abstract class AbstractMap implements IMap { } public void revive(User user,SChallengeConfig sChallengeConfig,List remainHp,int teamId) throws Exception { - // 失败需要等待n秒后复活所有英雄 - MapManager mapManager = user.getMapManager(); - int dieCount = user.getMapManager().getDieCount(); - - dieCount++; - user.getMapManager().setDieCount(dieCount); - int[] reviveTime = sChallengeConfig.getReviveTime(); - long time = (long) (MathUtils.calABX(dieCount, reviveTime) * 1000); - user.getMapManager().setCanMoveTime(TimeUtils.now() + time); - int leftTime = MapLogic.getLeftTime(user, true); - remainHp.clear(); - if (leftTime <= (int) (time / 1000)) { - MapLogic.resetMapInfo(user, false); - } else { - MapLogic.getInstance().initTeamInfo(mapManager.getTeamId(), user.getId(), user, mapManager, 2); - List teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(mapManager.getTeamId()); - for (TeamPosHeroInfo heroInfo : teamPosHeroInfos) { - Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId()); - if (hero == null) { - continue; - } - Map heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, teamId); - remainHp.add(heroAttributeMap.get(HeroAttributeEnum.CurHP.getPropertyId())); - } - } +// MapManager mapManager = user.getMapManager(); +// int dieCount = user.getMapManager().getDieCount(); +// +// dieCount++; +// user.getMapManager().setDieCount(dieCount); +// int[] reviveTime = sChallengeConfig.getReviveTime(); +// long time = (long) (MathUtils.calABX(dieCount, reviveTime) * 1000); +// user.getMapManager().setCanMoveTime(TimeUtils.now() + time); +// int leftTime = MapLogic.getLeftTime(user, true); +// remainHp.clear(); +// if (leftTime <= (int) (time / 1000)) { +// MapLogic.resetMapInfo(user, false); +// } else { +// MapLogic.getInstance().initTeamInfo(mapManager.getTeamId(), user.getId(), user, mapManager, 2); +// List teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(mapManager.getTeamId()); +// for (TeamPosHeroInfo heroInfo : teamPosHeroInfos) { +// Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId()); +// if (hero == null) { +// continue; +// } +// Map heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, teamId); +// remainHp.add(heroAttributeMap.get(HeroAttributeEnum.CurHP.getPropertyId())); +// } +// } } // public void refreshHp(User user,int teamId,int[] checkResult){ // List team = user.getTeamPosManager().getTeamPosForHero().get(teamId); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java index 8d27080b6..72f575cc7 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java @@ -190,7 +190,7 @@ public class HeroManager extends MongoBase { return faBaoSoulMap; } - private MapfaBaoGongMingSkillMap= new HashMap<>();//法宝之魂共鸣数据<法宝组合id:技能id> + private Map faBaoGongMingSkillMap = new HashMap<>();//法宝之魂共鸣数据<法宝组合id:技能id> public Map getFaBaoGongMingSkillMap() { return faBaoGongMingSkillMap; diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/MailManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/MailManager.java index d218c008a..28a6b48cc 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/MailManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/MailManager.java @@ -1,7 +1,6 @@ package com.ljsd.jieling.logic.dao; import com.ljsd.common.mogodb.MongoBase; -import com.ljsd.jieling.db.mongo.MongoKey; import com.ljsd.jieling.logic.dao.root.User; import java.util.Map; @@ -19,7 +18,7 @@ public class MailManager extends MongoBase { return mailMap; } - public void addMail(Mail mail){ + public void addMail(Mail mail){ mail.init(mail.getRoleUid(), getMongoKey() + ".mailMap." + mail.getId()); updateString("mailMap." + mail.getId(), mail); mailMap.put(mail.getId(), mail); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java index ff1952e16..7d3c44576 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java @@ -151,28 +151,28 @@ public class CombatLogic { mapManager.eatFood(foodIdOrEventId,contiue); } - public void updateHeroAttributJustOne(User user,List teamPosHeroInfoList,SFoodsConfig sFoodsConfig, Map> heroAllAttributeMap,boolean isRecory){ - Map foodAddMap = new HashMap<>(); - getFoodAttributeAdd(GlobalsDef.FOOD_ADDITION_BATTLE_TYPE, GlobalsDef.FOOD_EAT_AFFECT_PERSON, foodAddMap, sFoodsConfig); - for (TeamPosHeroInfo heroInfo : teamPosHeroInfoList) { - Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId()); - if (hero == null) { - continue; - } - Map heroAllAttribute = new HashMap<>(); - if(isRecory){ - heroAllAttribute =heroAllAttributeMap.get(hero.getId()); - }else { - heroAllAttribute = user.getMapManager().getHeroAllAttributeByHeroId(hero.getId()); - if(heroAllAttribute == null || heroAllAttribute.get(HeroAttributeEnum.CurHP.getPropertyId()) <= 0){ - continue; - } - } - HeroLogic.getInstance().combinedAttribute(foodAddMap,heroAllAttribute); - HeroLogic.getInstance().calInteractAdd(heroAllAttribute,false); - heroAllAttributeMap.put(hero.getId(), heroAllAttribute); - } - user.getMapManager().setHeroAllAttributeMap(heroAllAttributeMap); + public void updateHeroAttributeJustOne(User user,List teamPosHeroInfoList,SFoodsConfig sFoodsConfig, Map> heroAllAttributeMap,boolean isRecory){ +// Map foodAddMap = new HashMap<>(); +// getFoodAttributeAdd(GlobalsDef.FOOD_ADDITION_BATTLE_TYPE, GlobalsDef.FOOD_EAT_AFFECT_PERSON, foodAddMap, sFoodsConfig); +// for (TeamPosHeroInfo heroInfo : teamPosHeroInfoList) { +// Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId()); +// if (hero == null) { +// continue; +// } +// Map heroAllAttribute = new HashMap<>(); +// if(isRecory){ +// heroAllAttribute =heroAllAttributeMap.get(hero.getId()); +// }else { +// heroAllAttribute = user.getMapManager().getHeroAllAttributeByHeroId(hero.getId()); +// if(heroAllAttribute == null || heroAllAttribute.get(HeroAttributeEnum.CurHP.getPropertyId()) <= 0){ +// continue; +// } +// } +// HeroLogic.getInstance().combinedAttribute(foodAddMap,heroAllAttribute); +// HeroLogic.getInstance().calInteractAdd(heroAllAttribute,false); +// heroAllAttributeMap.put(hero.getId(), heroAllAttribute); +// } +// user.getMapManager().setHeroAllAttributeMap(heroAllAttributeMap); } public Map attributeByEatFood( User user,int type,int target){ diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/passiveSkillCal/PassiveskillCalEnum.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/passiveSkillCal/PassiveskillCalEnum.java index b49ea97a5..9696ae565 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/passiveSkillCal/PassiveskillCalEnum.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/passiveSkillCal/PassiveskillCalEnum.java @@ -3,9 +3,6 @@ package com.ljsd.jieling.logic.fight.passiveSkillCal; import com.ljsd.jieling.core.GlobalsDef; import com.ljsd.jieling.logic.dao.Hero; import com.ljsd.jieling.logic.dao.TeamPosHeroInfo; -import com.ljsd.jieling.logic.dao.UserManager; -import com.ljsd.jieling.logic.dao.root.User; -import config.SCHero; import config.SPropertyConfig; import java.util.Arrays; @@ -33,7 +30,7 @@ public enum PassiveskillCalEnum { } int extraValue = (int) cal(optCode, parm); - heroSkillAdMap.put(sPropertyConfig.getPropertyId(),heroSkillAdMap.getOrDefault(sPropertyConfig.getPropertyId(), Long.valueOf(0))+extraValue); + heroSkillAdMap.put(sPropertyConfig.getPropertyId(),heroSkillAdMap.getOrDefault(sPropertyConfig.getPropertyId(), 0L)+extraValue); }), AllAdd(94,(config,hero,heroSkillAdMap,user,teamId)->{ float[] value = config.getValue(); @@ -49,12 +46,12 @@ public enum PassiveskillCalEnum { parm = value[0]*10000; } - if( sPropertyConfig.getStyle()== GlobalsDef.PERCENT_TYPE){ + if(sPropertyConfig.getStyle()== GlobalsDef.PERCENT_TYPE){ parm = value[0]*10000; } int extraValue = (int) cal(optCode, parm); - heroSkillAdMap.put(sPropertyConfig.getPropertyId(),heroSkillAdMap.getOrDefault(sPropertyConfig.getPropertyId(), Long.valueOf(0))+extraValue); + heroSkillAdMap.put(sPropertyConfig.getPropertyId(),heroSkillAdMap.getOrDefault(sPropertyConfig.getPropertyId(), 0L)+extraValue); }), HEROAFTER100ADD(171,(config,hero,heroSkillAdMap,user,teamId)->{ float[] value = config.getValue(); @@ -66,7 +63,7 @@ public enum PassiveskillCalEnum { return; } int parm = (int) value[1]*times; - heroSkillAdMap.put(sPropertyConfig.getPropertyId(),heroSkillAdMap.getOrDefault(sPropertyConfig.getPropertyId(), Long.valueOf(0))+parm); + heroSkillAdMap.put(sPropertyConfig.getPropertyId(),heroSkillAdMap.getOrDefault(sPropertyConfig.getPropertyId(), 0L)+parm); }),//武将100级后每升一级[c]额外增加[d] HERO_PROFESSION_ADD(129,(config,hero,heroSkillAdMap,user,teamId)->{ float[] value = config.getValue(); @@ -89,7 +86,7 @@ public enum PassiveskillCalEnum { parm = value[1]*10000; } int extraValue = (int) cal(optCode, parm); - heroSkillAdMap.put(sPropertyConfig.getPropertyId(),heroSkillAdMap.getOrDefault(sPropertyConfig.getPropertyId(), Long.valueOf(0))+extraValue); + heroSkillAdMap.put(sPropertyConfig.getPropertyId(),heroSkillAdMap.getOrDefault(sPropertyConfig.getPropertyId(), 0L)+extraValue); }), HERO_HAVE_PROFESSION_ADD(413,(config,hero,heroSkillAdMap,user,teamId)->{ //被动技能,编队每增加一个同属性英雄属性额外增加一定数值 @@ -129,7 +126,7 @@ public enum PassiveskillCalEnum { parm = value[1]*10000*haveNum; } int extraValue = (int) cal(optCode, parm); - heroSkillAdMap.put(sPropertyConfig.getPropertyId(),heroSkillAdMap.getOrDefault(sPropertyConfig.getPropertyId(), Long.valueOf(0))+extraValue); + heroSkillAdMap.put(sPropertyConfig.getPropertyId(),heroSkillAdMap.getOrDefault(sPropertyConfig.getPropertyId(), 0L)+extraValue); }), ; private int type; 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 371b301e2..985b04fa9 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 @@ -64,7 +64,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; -@SuppressWarnings({"DanglingJavadoc", "JavadocDeclaration", "CommentedOutCode", "unused"}) +@SuppressWarnings({"DanglingJavadoc", "JavadocDeclaration", "CommentedOutCode", "unused", "CollectionAddAllCanBeReplacedWithConstructor"}) public class HeroLogic { private static final Logger LOGGER = LoggerFactory.getLogger(HeroLogic.class); @@ -2665,109 +2665,162 @@ public class HeroLogic { return pokenSkillPassiveResult.toString(); } - //图鉴属性加成 - public void bonuses(Set bookEnabled, Map heroAllAttribute) { - if (!bookEnabled.isEmpty()) { - Map config = STableManager.getConfig(SSpiritAnimalBook.class); - for (int bootId : bookEnabled) { - int[][] activePara = Optional.ofNullable(config.get(bootId)).map(SSpiritAnimalBook::getActivePara).orElse(new int[0][]); - combinedAttribute(activePara, heroAllAttribute); - } - } - } - /** * 计算队伍战力 */ 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(); - MagicSoldierManager soldierManager = user.getMagicSoldierManager(); - ItemManager itemManager = user.getItemManager(); + // 灵兽和神兵 + applyPokemonAndMagicSoldierAttribute(heroAllAttribute, teamId, user); + // 图鉴,皮肤,称号,坐骑等。。。 + applyBonusesAttribute(heroAllAttribute, hero.getSkin(), user); + // 四象心法增加总属性 + applyFourQuadrantAttribute(heroAllAttribute, hero.getTemplateId(), user); + // 英雄好感度增加属性 + applyHeroLikableAttribute(heroAllAttribute, hero.getTemplateId(), user); + // 法宝聚灵和命格属性加成 + applyTrumpAndGemAttribute(heroAllAttribute, user); + // 主角和主角技 + applyPlayerAndSkill(heroAllAttribute, user); + // 工坊科技树加成(疑似废弃) + applyWorkShopTechnologyAttribute(heroAllAttribute, hero.getTemplateId(), user); + // 装备和套装属性 + applyEquipSuiteAttribute(heroAllAttribute, hero); + // 魂灵宝加成 + applyJewelAttribute(heroAllAttribute, hero, user); + // 法宝,法相加成 + applyEquipTalismanaAndFaxiangAttribute(heroAllAttribute, hero, user); + // 魂印和神印属性加成 + applySoulEquipAndGodSealAttribute(heroAllAttribute, hero, user); + // 主角修为和修行等级属性加成 + applyXiuxingAndXiuxianAttribute(heroAllAttribute, user); + // 公会技能和特权加成 + applyGuildSkillAndVipAttribute(heroAllAttribute, hero.getTemplateId(), user); + // 阵营光环,大闹天宫特殊加成 + applyTeamAttribute(heroAllAttribute, isForce, teamId, user); + // 被动技能 + applyPassiveSkillAttribute(heroAllAttribute, hero, teamId, user); - SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId()); - if (teamId != 0) { - int heroNum = user.getTeamPosManager().getTeamPosForHero().get(teamId).size(); - if (teamId == TeamEnum.TRIAL_TEAM.getTeamId()) { - //森罗环境固定为5 - heroNum = 5; + // 总计算 + calInteractAdd(heroAllAttribute, isForce); + heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), heroAllAttribute.get(GlobalsDef.HP_TYPE)); + return heroAllAttribute; + } + + private void applyPokemonAndMagicSoldierAttribute(Map heroAllAttribute, int teamId, User user) { + // ... 灵兽和神兵属性加成逻辑 ... + int num = Optional.ofNullable(user.getTeamPosManager().getTeamPosForHero().get(teamId)).map(List::size).orElse(0); + if (num == 0){ + return; + } + //森罗环境固定为5 + int heroNum = teamId == TeamEnum.TRIAL_TEAM.getTeamId()?5:num; + // 灵兽战力 + int[][] pokemonAttr = calPokemonAttribute(user.getPokemonManager()); + for (int i = 0; i < pokemonAttr.length; i++) { + pokemonAttr[i][1] = pokemonAttr[i][1] / heroNum; + } + combinedAttribute(pokemonAttr, heroAllAttribute); + // 神兵战力 + int[][] magicSoldierAttribute = calMagicSoldierAttribute(user.getMagicSoldierManager()); + combinedAttribute(magicSoldierAttribute, heroAllAttribute); + } + + private void applyBonusesAttribute(Map heroAllAttribute, int heroSkin, User user) { + PlayerManager playerInfoManager = user.getPlayerInfoManager(); + + // ... 图鉴、皮肤、称号、坐骑等属性加成逻辑 ... + HashSet bookSet = new HashSet<>(); + bookSet.addAll(user.getPokemonManager().getPokemonBookEnabled());//灵兽图鉴加成 + bookSet.addAll(user.getHeroManager().getHeroHandBookEnabled());//神将羁绊加成 + bookSet.addAll(user.getEquipManager().getEquipBookEnabled());//魂印图鉴加成 + bookSet.addAll(user.getItemManager().getEquipBookEnabled());//白金装备加成 + bookSet.addAll(user.getMagicSoldierManager().getMagicSoldierBook());//神兵图鉴加成 + if (!bookSet.isEmpty()) { + //计算图鉴加成 + Map config = STableManager.getConfig(SSpiritAnimalBook.class); + for (int bootId : bookSet) { + int[][] activePara = Optional.ofNullable(config.get(bootId)).map(SSpiritAnimalBook::getActivePara).orElse(new int[0][]); + combinedAttribute(activePara, heroAllAttribute); } - // 灵兽战力 - int[][] pokemonAttr = calPokemonAttribute(pokemonManager); - for (int i = 0; i < pokemonAttr.length; i++) { - pokemonAttr[i][1] = pokemonAttr[i][1] / heroNum; - } - combinedAttribute(pokemonAttr, heroAllAttribute); - // 神兵战力 - int[][] magicSoldierAttribute = calMagicSoldierAttribute(soldierManager); - combinedAttribute(magicSoldierAttribute, heroAllAttribute); } - //全部图鉴 - HashSet bookSet = new HashSet<>(); - //灵兽图鉴加成 - bookSet.addAll(pokemonManager.getPokemonBookEnabled()); - //神将羁绊加成 - bookSet.addAll(heroManager.getHeroHandBookEnabled()); - //魂印图鉴加成 - bookSet.addAll(equipManager.getEquipBookEnabled()); - //白金装备加成 - bookSet.addAll(itemManager.getEquipBookEnabled()); - //神兵图鉴加成 - bookSet.addAll(soldierManager.getMagicSoldierBook()); - //计算图鉴加成 - bonuses(bookSet, heroAllAttribute); - //英雄皮肤加成 记得判断皮肤过期 - int skin = hero.getSkin(); - if (skin != 0) { - Map skinInfo = heroManager.getSkinInfo(); - SHeroSkin sHeroSkin = SHeroSkin.skinMapByType.get(skin); + if (heroSkin != 0) { + Map skinInfo = user.getHeroManager().getSkinInfo(); + SHeroSkin sHeroSkin = SHeroSkin.skinMapByType.get(heroSkin); if (sHeroSkin != null && sHeroSkin.getMonomerProperty() != null && sHeroSkin.getMonomerProperty().length > 0) { - if (skinInfo.containsKey(skin) && (skinInfo.get(skin) == -1 || skinInfo.get(skin) > TimeUtils.nowInt())) { + if (skinInfo.containsKey(heroSkin) && (skinInfo.get(heroSkin) == -1 || skinInfo.get(heroSkin) > TimeUtils.nowInt())) { combinedAttribute(sHeroSkin.getMonomerProperty(), heroAllAttribute); } } } - // 法宝聚灵总星级增加属性 + + // 玩家皮肤,称号,坐骑 + List list = new ArrayList<>(); + list.addAll(playerInfoManager.getUserSkinValidTime().keySet());// 皮肤 + list.addAll(playerInfoManager.getUserTitleValidTime().keySet());// 称号 + list.addAll(playerInfoManager.getUserMountValidTime().keySet());// 坐骑 + for (Integer id : list) { + SPlayerHeadIcon headIcon = SPlayerHeadIcon.getHeadIconMap().get(id); + if (headIcon == null){ + continue; + } + combinedAttribute(headIcon.getUnlockProperty(), heroAllAttribute); + } + } + + private void applyTrumpAndGemAttribute(Map heroAllAttribute, User user) { + // ... 法宝聚灵和命格增加属性逻辑 ... + HeroManager heroManager = user.getHeroManager(); + + // 法宝聚灵 + Map faBaoSoulMap = heroManager.getFaBaoSoulMap(); + for (Map.Entry faBaoSoulEntry : faBaoSoulMap.entrySet()) { + // 等级处理 + STrump trumpConfig = STrump.sTrumpMap.get(faBaoSoulEntry.getKey()); + STrumpLevelupPool lvUpProps = STrumpLevelupPool.levelPoolMap.get(trumpConfig.getLvupPool()).get(faBaoSoulEntry.getValue()); + combinedAttribute(lvUpProps.getLvupProps(), heroAllAttribute); + } Map trumpStarMap = STableManager.getConfig(STrumpStar.class); - // 按照累计星数倒叙排列 - List trumpStars = trumpStarMap.values().stream().sorted(Comparator.comparing(STrumpStar::getStarNum).reversed()).collect(Collectors.toList()); // 玩家全部的总星级 - int sumStar = heroManager.getFaBaoSoulMap().values().stream().mapToInt(v -> v).sum(); - for (STrumpStar star : trumpStars) { - if (sumStar >= star.getStarNum()){ - combinedAttribute(star.getPropList(), heroAllAttribute); - break; - } - } - //玩家皮肤加成 - for (Map.Entry entry : user.getPlayerInfoManager().getUserSkinValidTime().entrySet()) { - if (!SPlayerHeadIcon.getHeadIconMap().containsKey(entry.getKey())) { + int sumStar = faBaoSoulMap.values().stream().mapToInt(v -> v).sum(); + STrumpStar trumpStar = null; + for (STrumpStar value : trumpStarMap.values()) { + // 星级处理 + if (trumpStar == null){ + trumpStar = value; continue; } - combinedAttribute(SPlayerHeadIcon.getHeadIconMap().get(entry.getKey()).getUnlockProperty(), heroAllAttribute); - } - //玩家称号加成 - for (Map.Entry entry : user.getPlayerInfoManager().getUserTitleValidTime().entrySet()) { - if (!SPlayerHeadIcon.getHeadIconMap().containsKey(entry.getKey())) { - continue; + if (trumpStar.getStarNum() < value.getStarNum()){ + trumpStar = value; } - combinedAttribute(SPlayerHeadIcon.getHeadIconMap().get(entry.getKey()).getUnlockProperty(), heroAllAttribute); } - //玩家坐骑加成 - for (Map.Entry entry : user.getPlayerInfoManager().getUserMountValidTime().entrySet()) { - if (!SPlayerHeadIcon.getHeadIconMap().containsKey(entry.getKey())) { - continue; + if (trumpStar != null) { + combinedAttribute(trumpStar.getPropList(), heroAllAttribute); + } + + // 命格 + for (Map.Entry> lifeGridMapEntry : heroManager.getLifeGridMap().entrySet()) { + for (Map.Entry entry : lifeGridMapEntry.getValue().entrySet()) { + int lifeStoneId = entry.getValue(); + if (lifeStoneId <= 0){ + continue; + } + SGemConfig sGemConfig=STableManager.getConfig(SGemConfig.class).get(lifeStoneId); + combinedAttribute(sGemConfig.getProperty(), heroAllAttribute); } - combinedAttribute(SPlayerHeadIcon.getHeadIconMap().get(entry.getKey()).getUnlockProperty(), heroAllAttribute); } - //四象心法加成 + } + + private void applyFourQuadrantAttribute(Map heroAllAttribute, int heroTempId, User user){ + HeroManager heroManager = user.getHeroManager(); + // ... 四象心法总属性加成 ... for (Map.Entry entry :heroManager.getSixiangDataMap().entrySet()) { + SCHero scHero = SCHero.getsCHero().get(heroTempId); if (scHero.getProfession() != entry.getKey()) { continue; } @@ -2782,6 +2835,7 @@ public class HeroLogic { combinedAttribute(upStarProp, heroAllAttribute); } } + ///四象心法共鸣属性加成 if (heroManager.GetSiXiangGongMingLv() > 0) { SFourQuadrantConfig fourConfig = SFourQuadrantConfig.configByStrtMap.get(heroManager.GetSiXiangGongMingLv()); @@ -2799,10 +2853,13 @@ public class HeroLogic { } int[][] skillProp = ItemUtil.mapToArray(skillPropertyMap); combinedAttribute(skillProp, heroAllAttribute); + } - //英雄好感度属性加成 - if (heroManager.getHeroLikableMap().containsKey(scHero.getId())) { - int[][] likableProp = ItemUtil.mapToArray(heroManager.getHeroLikablePropAddMap(scHero.getId())); + private void applyHeroLikableAttribute(Map heroAllAttribute, int heroTempId, User user){ + HeroManager heroManager = user.getHeroManager(); + // ... 英雄好感度属性增加 ... + if (heroManager.getHeroLikableMap().containsKey(heroTempId)) { + int[][] likableProp = ItemUtil.mapToArray(heroManager.getHeroLikablePropAddMap(heroTempId)); combinedAttribute(likableProp, heroAllAttribute); } //英雄总好感度属性加成 @@ -2811,26 +2868,10 @@ public class HeroLogic { int[][] allLikableProp = ItemUtil.mapToArray(allLikablePropAddMap); combinedAttribute(allLikableProp, heroAllAttribute); } + } - ///法宝之魂属性加成 - for (Map.Entry faBaoSoulEntry :heroManager.getFaBaoSoulMap().entrySet()) { - STrump trumpConfig = STrump.sTrumpMap.get(faBaoSoulEntry.getKey()); - STrumpLevelupPool lvUpProps = STrumpLevelupPool.levelPoolMap.get(trumpConfig.getLvupPool()).get(faBaoSoulEntry.getValue()); - combinedAttribute(lvUpProps.getLvupProps(), heroAllAttribute); - } - - ///命格属性加成 - for (Map.Entry> lifeGridMapEntry : heroManager.getLifeGridMap().entrySet()) { - for (Map.Entry entry : lifeGridMapEntry.getValue().entrySet()) { - int lifeStoneId=entry.getValue(); - if (lifeStoneId>0){ - SGemConfig sGemConfig=STableManager.getConfig(SGemConfig.class).get(lifeStoneId); - combinedAttribute(sGemConfig.getProperty(), heroAllAttribute); - } - } - } - - // 主角本身给英雄的加成 + private void applyPlayerAndSkill(Map heroAllAttribute, User user){ + // ... 主角和主角技能 ... SPlayerLevelConfig playerLevelConfig = SPlayerLevelConfig.sPlayerLevelConfigMap.get(user.getPlayerInfoManager().getLevel()); if (playerLevelConfig != null){ combinedAttribute(playerLevelConfig.getPropList(), heroAllAttribute); @@ -2838,7 +2879,7 @@ public class HeroLogic { } // 变身卡加成 / 主角技能 - for (TransformationInfo info : heroManager.getTransformationList().values()) { + for (TransformationInfo info : user.getHeroManager().getTransformationList().values()) { // 主角属性 calPlayerAttribute(heroAllAttribute, info.getCardId(), info.getStar(), info.getLevel()); // 英雄属性 @@ -2850,29 +2891,93 @@ public class HeroLogic { // if(SChangingForce.get(user.getHeroManager().getTransformationForce()) != null){ // combinedAttribute(SChangingForce.get(user.getHeroManager().getTransformationForce()).getPropList(), heroAllAttribute); // } + } - // 装备套装属性 - getEquipSuiteAttr(hero, heroAllAttribute); + private void applyEquipSuiteAttribute(Map heroAllAttribute, Hero hero){ - //工坊科技树加成 - 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) { - continue; - } - int[][] attrAdd = sWorkShopTechnology.getValues(); - if (attrAdd != null && attrAdd.length > 0) { - combinedAttribute(attrAdd, heroAllAttribute); + // ... 获取装备套装属性 ... + Iterator> iterator = hero.getEquipByPositionMap().entrySet().iterator(); + + Map strengthenMap = SEquipStrengthen.lvMap; + Map rankUpMap = SEquipRankUp.lvMap; + Map strongMap = hero.getEquipStrongMap(); + int advanceLv = hero.getEquipAdvanceLv(); + + // 套装list初始化 + ArrayList suiteNumList = new ArrayList<>(); + Map equipConfigMap = STableManager.getConfig(SEquipConfig.class); + while (iterator.hasNext()) { + Map.Entry next = iterator.next(); + SEquipConfig sEquipConfig = equipConfigMap.get(next.getValue()); + int[][] property = sEquipConfig.getProperty(); + Map propertyValueByIdMap = new HashMap<>(); + for (int[] prop : property) { + long value = prop[1]; + SPropertyConfig config = SPropertyConfig.getsPropertyConfigByPID(prop[0]); + // 家园装备强化属性,只增加基础属性 + if (config != null && config.getStyle() == 1){ + double buff = 0; + int strongLv = strongMap.getOrDefault(sEquipConfig.getPosition(),new HeroEquipStrong(sEquipConfig.getPosition())).getStrongLv(); + buff += Optional.ofNullable(strengthenMap.get(strongLv)).map(SEquipStrengthen::getRate).orElse(0); + // 突破 + buff += Optional.ofNullable(rankUpMap.get(advanceLv)).map(v -> v.getRate()[sEquipConfig.getPosition() - 1]).orElse(0); + value = value + (long) Math.ceil(buff/10000*value); } + propertyValueByIdMap.put(prop[0], value); } - + combinedAttribute(propertyValueByIdMap, heroAllAttribute); + // 添加到套装list + suiteNumList.add(sEquipConfig); } - //法宝加成 + /*========== 开始处理套装 ============*/ + // 根据升序顺序排列list + Collections.sort(suiteNumList); + // 记录当前长度(位置) + int num = suiteNumList.size(); + if (!suiteNumList.isEmpty()) { + // 遍历套装list + for (SEquipConfig item : suiteNumList) { + //根据星级读取配置表,为空表示不是套装 + SEquipSuiteConfig sEquipSuiteConfig = SEquipSuiteConfig.config.get(item.getStar()); + if (null != sEquipSuiteConfig) { + // 根据套装数量读表,为空标是套装数量不足 + Map suitePropertyMap = sEquipSuiteConfig.getSuiteMap().get(num); + if (suitePropertyMap != null) { + // 计算战力 + combinedAttribute(suitePropertyMap, heroAllAttribute); + } + } + // 不管是否是套装,都要-1 + num -= 1; + } + } + } + + private void applyWorkShopTechnologyAttribute(Map heroAllAttribute, int heroTempId, User user){ + // ... 工坊和科技树 ... + SCHero scHero = SCHero.getsCHero().get(heroTempId); + Map techProfressionMap = user.getWorkShopController().getTechnologyMap().get(scHero.getProfession()); + if (techProfressionMap == null) { + return; + } + 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); + } + } + } + + private void applyEquipTalismanaAndFaxiangAttribute(Map heroAllAttribute, Hero hero, User user){ + // ... 法宝 ... int heroStar = hero.getStar(); //判断是否解锁法宝 + SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId()); 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()); @@ -2881,6 +2986,30 @@ public class HeroLogic { combinedAttribute(equipTali.getProperty(), heroAllAttribute); } + // ... 法相 ... + Set faxiangList = hero.getFaxiangList(); + if (faxiangList != null && !faxiangList.isEmpty()){ + for (String id : faxiangList) { + Faxiang faxiang = user.getEquipManager().getFaxiang(id); + SFaxiangConfig config = SFaxiangConfig.faxiangMap.get(faxiang.getItemId()); + SFaxiangLevelConfig levelConfig = SFaxiangLevelConfig.poolMap.get(config.getLevelUpPool()).get(faxiang.getStrongLv()); + SFaxiangStarConfig starConfig = SFaxiangStarConfig.poolMap.get(config.getStar()).get(faxiang.getStar()); + int[][] levelPara = levelConfig.getLevelPara(); + int[][] property = new int[levelPara.length][2]; + for (int i = 0; i < levelPara.length; i++) { + int[] alone = levelPara[i]; + property[i][0] = alone[0]; + int value = (int)(alone[1] * (starConfig.getStarPara()/10000d+1)); + property[i][1] = value; + } + combinedAttribute(property, heroAllAttribute); + } + } + } + + private void applyJewelAttribute(Map heroAllAttribute, Hero hero, User user){ + // ... 魂灵宝属性 ... + EquipManager equipManager = user.getEquipManager(); Map equipMap = new HashMap<>(); // 助战英雄 HelpHero helpHero = HelpHeroLogic.getHelpHeroByHeroId(user.getId(), hero.getId()); @@ -2889,10 +3018,9 @@ public class HeroLogic { equipMap.put(jewel.getId(), jewel); } } else { - equipMap = hero.getCreateType() == 1 ? user.getExpeditionManager().getEquipMap() : user.getEquipManager().getEquipMap(); + equipMap = hero.getCreateType() == 1 ? user.getExpeditionManager().getEquipMap() : equipManager.getEquipMap(); } - //宝器加成 魂灵宝 Set jewelInfo = hero.getJewelInfo(); boolean flashing = jewelInfo.size() == 2; int minLevel = -1; @@ -2981,32 +3109,13 @@ public class HeroLogic { combinedAttribute(config.get(buildLevelProperty).getProperty(), heroAllAttribute); } } + } - // 法相加成 - Set faxiangList = hero.getFaxiangList(); - if (faxiangList != null && !faxiangList.isEmpty()){ - for (String id : faxiangList) { - Faxiang faxiang = equipManager.getFaxiang(id); - SFaxiangConfig config = SFaxiangConfig.faxiangMap.get(faxiang.getItemId()); - SFaxiangLevelConfig levelConfig = SFaxiangLevelConfig.poolMap.get(config.getLevelUpPool()).get(faxiang.getStrongLv()); - SFaxiangStarConfig starConfig = SFaxiangStarConfig.poolMap.get(config.getStar()).get(faxiang.getStar()); - int[][] levelPara = levelConfig.getLevelPara(); - int[][] property = new int[levelPara.length][2]; - for (int i = 0; i < levelPara.length; i++) { - int[] alone = levelPara[i]; - property[i][0] = alone[0]; - int value = (int)(alone[1] * (starConfig.getStarPara()/10000d+1)); - property[i][1] = value; - } - combinedAttribute(property, heroAllAttribute); - } - } - + private void applySoulEquipAndGodSealAttribute(Map heroAllAttribute, Hero hero, User user){ + // ... 魂印和神印等属性加成 ... Map equipConfigMap = STableManager.getConfig(SEquipConfig.class); - - //魂印 - ArrayList list = new ArrayList<>(hero.getSoulEquipByPositionMap().values()); - //神印 + ArrayList list = new ArrayList<>(); + list.addAll(hero.getSoulEquipByPositionMap().values()); list.addAll(hero.getGodSealByPositionMap().values()); for (Integer id : list) { SEquipConfig sEquipConfig = equipConfigMap.get(id); @@ -3015,6 +3124,10 @@ public class HeroLogic { combinedAttribute(property, heroAllAttribute); } } + } + + private void applyXiuxingAndXiuxianAttribute(Map heroAllAttribute, User user){ + // ... 修行和修仙 ... // 修行等级属性加成 Map xiuXianMap = STableManager.getConfig(SXiuXian.class); @@ -3041,24 +3154,11 @@ public class HeroLogic { combinedAttribute(otherAttriMaop, heroAllAttribute); } } + } -// //皮肤、称号加成 -- 前端未实现,暂时注释 -// int decoration = user.getPlayerInfoManager().getDecoration(); -// int designation = user.getPlayerInfoManager().getDesignation(); -// if(decoration!=0&&SPlayerAppearance.sPlayerAppearanceMap.get(decoration)!=null){ -// combinedAttribute(SPlayerAppearance.sPlayerAppearanceMap.get(decoration).getProperty(),heroAllAttribute); -// }if(designation!=0&&SPlayerAppearance.sPlayerAppearanceMap.get(designation)!=null){ -// combinedAttribute(SPlayerAppearance.sPlayerAppearanceMap.get(designation).getProperty(),heroAllAttribute); -// } -// -// //坐骑加成 -- 前端未实现,暂时注释 -// if(user.getPlayerInfoManager().getRide()!=0){ -// int rideLevel = user.getPlayerInfoManager().getRideLevel(); -// int[][] property = SPlayerMountLevelUp.sPlayerMountLevelUpMap.get(rideLevel).getProperty(); -// combinedAttribute(property,heroAllAttribute); -// } - - //公会技能加成 + private void applyGuildSkillAndVipAttribute(Map heroAllAttribute, int heroTempId, User user){ + // ... 工会技能 .... + SCHero scHero = SCHero.getsCHero().get(heroTempId); Map guildSkill = user.getGuildMyInfo().getGuildSkill(); if (guildSkill.containsKey(scHero.getProfession())) { int size = SGuildTechnology.technologyMap.get(scHero.getProfession()).size(); @@ -3077,49 +3177,7 @@ public class HeroLogic { combinedAttribute(arraySkills, heroAllAttribute); } - //阵营光环加成 - if (teamId != 0) { - try { - int[][] elementEffect = CombatLogic.getInstance().elementEffect(user, teamId); - if (elementEffect != null && elementEffect.length > 0) { - combinedAttribute(elementEffect, heroAllAttribute); - } - } catch (Exception e) { - e.printStackTrace(); - } - - } - - //被动技能加成 - Set heroSkillList = CombatLogic.getInstance().passiveskillEffect(user, hero, teamId); - - if (teamId == TeamEnum.EXPEDITION_TEAM.getTeamId()) { - ExpeditionManager expeditionManager = user.getExpeditionManager(); - Set expeditionHolyConfigs = ExpeditionLogic.getFirstRankHoly(expeditionManager); - for (SExpeditionHolyConfig config : expeditionHolyConfigs) { - if (config.getPassiveSkillId() > 0) { - heroSkillList.add(config.getPassiveSkillId()); - } - } - } - - Map heroSkillAdMap = new HashMap<>(); - for (Integer skill : heroSkillList) { - SPassiveSkillLogicConfig config = SPassiveSkillLogicConfig.getConfig(skill); - 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,user,teamId); - } - } - } - - if (!heroSkillAdMap.isEmpty()) { - combinedAttribute(heroSkillAdMap, heroAllAttribute); - heroSkillAdMap.clear(); - } - - //特权加成 + // ... 特权属性 ... int vipLevel = user.getPlayerInfoManager().getVipLevel(); SVipLevelConfig sVipLevelConfig = SVipLevelConfig.getsVipLevelConfigMap().get(vipLevel); if (null != sVipLevelConfig) { @@ -3128,104 +3186,62 @@ public class HeroLogic { combinedAttribute(elementEffect, heroAllAttribute); } } + } - if (teamId == TeamEnum.EXPEDITION_TEAM.getTeamId()) { - if (user.getExpeditionManager().getWorldTreasureReward().getIsBuy() == 1) { - int[] onceArrayValue = SSpecialConfig.getOnceArrayValue(SSpecialConfig.SKILL_EFFECT_TGMB); - combinedAttribute(new int[][]{onceArrayValue}, heroAllAttribute); + private void applyTeamAttribute(Map heroAllAttribute, boolean isForce, int teamId, User user){ + // ... 阵营光环,大闹天宫,pvp属性 ... + if (teamId != 0) { + // 阵营光环加成 + int[][] elementEffect = CombatLogic.getInstance().elementEffect(user, teamId); + if (elementEffect != null && elementEffect.length > 0) { + combinedAttribute(elementEffect, heroAllAttribute); } } + // 大闹天宫特殊加成 + if (teamId == TeamEnum.EXPEDITION_TEAM.getTeamId() && user.getExpeditionManager().getWorldTreasureReward().getIsBuy() == 1) { + int[] onceArrayValue = SSpecialConfig.getOnceArrayValue(SSpecialConfig.SKILL_EFFECT_TGMB); + combinedAttribute(new int[][]{onceArrayValue}, heroAllAttribute); + } + //pvp队伍加成 if (!isForce && !TeamEnum.isPvpTeam(teamId)) { heroAllAttribute.remove(HeroAttributeEnum.PVPDamageBocusFactor.getPropertyId()); heroAllAttribute.remove(HeroAttributeEnum.PVPDamageReduceFactor.getPropertyId()); } - - calInteractAdd(heroAllAttribute, isForce); - - heroSkillList.forEach(skill -> { - SPassiveSkillLogicConfig configTmp = SPassiveSkillLogicConfig.getConfig(skill); - 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,user,teamId); - } - } - }); - - if (!heroSkillAdMap.isEmpty()) { - combinedAttribute(heroSkillAdMap, heroAllAttribute); - calInteractAdd(heroAllAttribute, isForce); - heroSkillAdMap.clear(); - } - - heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), heroAllAttribute.get(GlobalsDef.HP_TYPE)); - return heroAllAttribute; } - /** - * 获取装备套装属性 - * @param hero 英雄信息 - * @param heroAllAttribute 总属性 - */ - private void getEquipSuiteAttr(Hero hero, Map heroAllAttribute){ - Iterator> iterator = hero.getEquipByPositionMap().entrySet().iterator(); + private void applyPassiveSkillAttribute(Map heroAllAttribute, Hero hero, int teamId, User user){ + // ...被动技能处理... + Set heroSkillList = CombatLogic.getInstance().passiveskillEffect(user, hero, teamId); - Map strengthenMap = SEquipStrengthen.lvMap; - Map rankUpMap = SEquipRankUp.lvMap; - Map strongMap = hero.getEquipStrongMap(); - int advanceLv = hero.getEquipAdvanceLv(); - - // 套装list初始化 - ArrayList suiteNumList = new ArrayList<>(); - Map equipConfigMap = STableManager.getConfig(SEquipConfig.class); - while (iterator.hasNext()) { - Map.Entry next = iterator.next(); - SEquipConfig sEquipConfig = equipConfigMap.get(next.getValue()); - int[][] property = sEquipConfig.getProperty(); - Map propertyValueByIdMap = new HashMap<>(); - for (int[] prop : property) { - long value = prop[1]; - SPropertyConfig config = SPropertyConfig.getsPropertyConfigByPID(prop[0]); - // 家园装备强化属性,只增加基础属性 - if (config != null && config.getStyle() == 1){ - double buff = 0; - int strongLv = strongMap.getOrDefault(sEquipConfig.getPosition(),new HeroEquipStrong(sEquipConfig.getPosition())).getStrongLv(); - buff += Optional.ofNullable(strengthenMap.get(strongLv)).map(SEquipStrengthen::getRate).orElse(0); - // 突破 - buff += Optional.ofNullable(rankUpMap.get(advanceLv)).map(v -> v.getRate()[sEquipConfig.getPosition() - 1]).orElse(0); - value = value + (long) Math.ceil(buff/10000*value); - } - propertyValueByIdMap.put(prop[0], value); - } - combinedAttribute(propertyValueByIdMap, heroAllAttribute); - // 添加到套装list - suiteNumList.add(sEquipConfig); + // 大闹天宫队伍特殊处理 + if (teamId == TeamEnum.EXPEDITION_TEAM.getTeamId()) { + ExpeditionManager expeditionManager = user.getExpeditionManager(); + Set expeditionHolyConfigs = ExpeditionLogic.getFirstRankHoly(expeditionManager); + expeditionHolyConfigs.stream().filter(v->v.getPassiveSkillId() > 0).forEach(e -> heroSkillList.add(e.getPassiveSkillId())); } - /*========== 开始处理套装 ============*/ - // 根据升序顺序排列list - Collections.sort(suiteNumList); - // 记录当前长度(位置) - int num = suiteNumList.size(); - if (!suiteNumList.isEmpty()) { - // 遍历套装list - for (SEquipConfig item : suiteNumList) { - //根据星级读取配置表,为空表示不是套装 - SEquipSuiteConfig sEquipSuiteConfig = SEquipSuiteConfig.config.get(item.getStar()); - if (null != sEquipSuiteConfig) { - // 根据套装数量读表,为空标是套装数量不足 - Map suitePropertyMap = sEquipSuiteConfig.getSuiteMap().get(num); - if (suitePropertyMap != null) { - // 计算战力 - combinedAttribute(suitePropertyMap, heroAllAttribute); - } - } - // 不管是否是套装,都要-1 - num -= 1; + Map heroSkillAdMap = new HashMap<>(); + Map heroSkillAdMap2 = new HashMap<>(); + for (Integer skill : heroSkillList) { + SPassiveSkillLogicConfig config = SPassiveSkillLogicConfig.getConfig(skill); + float[] value = config.getValue(); + if (value == null || value.length <= 2){ + continue; + } + PassiveskillCalEnum passiveskillCalEnum = PassiveskillCalEnum.calEnumMap.get(config.getType()); + if (passiveskillCalEnum == null){ + continue; + } + if (value[2] == 4){ + passiveskillCalEnum.getPassiveSkillProcessor().process(config, hero, heroSkillAdMap, user, teamId); + }else { + passiveskillCalEnum.getPassiveSkillProcessor().process(config, hero, heroSkillAdMap2, user, teamId); } } + combinedAttribute(heroSkillAdMap, heroAllAttribute); + combinedAttribute(heroSkillAdMap2, heroAllAttribute); } /** @@ -3383,9 +3399,8 @@ public class HeroLogic { public int calForce(Map heroAllAttribute) { - double result; - float forceNum=0;//基础值 - float forceAdd=0;//加成值 + float forceNum = 0;//基础值 + float forceAdd = 0;//加成值 //战力计算 for(Map.Entry item : heroAllAttribute.entrySet()){ Integer propertyId = item.getKey(); @@ -3395,20 +3410,17 @@ public class HeroLogic { continue; } SPropertyConfig sPropertyConfig = SPropertyConfig.getsPropertyConfigByPID(propertyId); - if (sPropertyConfig==null){ - continue; - } - if (sPropertyConfig.getScore()==0){ + if (sPropertyConfig==null || sPropertyConfig.getScore()==0){ continue; } if(sPropertyConfig.getStyle() == GlobalsDef.PERCENT_TYPE){ + LOGGER.info("result1 ================> {},{}" , item, sPropertyConfig.getScore()); forceAdd += propertyValue * sPropertyConfig.getScore() / 10000; }else{ forceNum += propertyValue * sPropertyConfig.getScore(); } } - result=forceNum+(forceNum*forceAdd); - + float result = (forceAdd + 1) * forceNum; return (int)result; } @@ -3430,6 +3442,10 @@ public class HeroLogic { int propertyValue = item[1]; heroAttributeMap.put(propertyId, heroAttributeMap.getOrDefault(propertyId, 0L) + propertyValue); } +// ArrayList list = new ArrayList<>(); +// list.add(otherAttriMap); +// Map mapObject = Utils.getItemMapObject(list); +// LOGGER.info("加成属性==>{}, ==>{}",mapObject,heroAttributeMap); } //新版穿装备 @@ -5266,9 +5282,8 @@ public class HeroLogic { * 推送鸿蒙阵信息 * * @param session - * @throws Exception */ - public void addOrUpdateHongmeng(ISession session) throws Exception { + public void addOrUpdateHongmeng(ISession session) { addOrUpdateHongmeng(session, false); } @@ -5502,7 +5517,7 @@ public class HeroLogic { } } } catch (Exception e) { - LOGGER.error("鸿蒙阵报错,{}",e); + LOGGER.error("鸿蒙阵报错,{}",e.getMessage()); } }