From 639a6e92f68abac7d522bf2f066b8f20ec628b83 Mon Sep 17 00:00:00 2001 From: duhui Date: Fri, 17 Feb 2023 13:24:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=95=E7=9B=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ljsd/jieling/logic/equip/EquipLogic.java | 14 ++++-- .../ljsd/jieling/logic/hero/HeroLogic.java | 48 ++++++++----------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/equip/EquipLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/equip/EquipLogic.java index 8dece5940..d905a0a09 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/equip/EquipLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/equip/EquipLogic.java @@ -54,13 +54,14 @@ public class EquipLogic { throw new ErrorCodeException(ErrorCode.CFG_NULL,"法相配置表不存在,或未进入版本:"+faxiang.getItemId()); } // 穿戴 - if (action == 1){ + if (action == 1 || action == 3){ Set faxiangList = hero.getFaxiangList(); if (faxiangList.contains(faxiangID)){ LOGGER.error("法相已装备,hero:{}, faxiang:{}",heroID,faxiangID); throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"法相已装备"); } // 检测是否装备同类型的法相 + String removeId = null; for (String faxiangId : faxiangList) { Faxiang faxiang1 = equipManager.getFaxiang(faxiangId); if (faxiang1 == null){ @@ -71,11 +72,15 @@ public class EquipLogic { SFaxiangConfig faxiangConfig1 = faxiangMap.get(faxiang1.getItemId()); if (faxiangConfig1 == null){ hero.uninstallFaxiang(faxiangId); - LOGGER.error("法相不存在装备库中,已卸载,uid:{}, hero:{}, faxiang:{}",user.getId(),heroID,faxiangID); + LOGGER.error("法相不存在配置表中,已卸载,uid:{}, hero:{}, faxiang:{}",user.getId(),heroID,faxiangID); continue; } if (faxiangConfig.getType() == faxiangConfig1.getType()){ - throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"法相已装备同类型的法相"); + if (action == 3 && removeId == null){ + removeId = faxiang1.getId(); + }else { + throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"法相已装备同类型的法相"); + } } } SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId()); @@ -91,6 +96,9 @@ public class EquipLogic { } hero.addFaxiang(faxiangID); + if (removeId != null){ + hero.uninstallFaxiang(removeId); + } } // 脱下 if (action == 2){ 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 618e06239..9a5d17a9c 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 @@ -80,9 +80,9 @@ public class HeroLogic { public static List transTemplate = new ArrayList<>(); public static List equipSkillPositionTemaplge = new ArrayList<>(6); - private static Map> transTemplateByHeroPropertyName = new HashMap<>(); + private static final Map> transTemplateByHeroPropertyName = new HashMap<>(); - private static List pokemonTemplate = new ArrayList<>(); + private static final List pokemonTemplate = new ArrayList<>(); static { transTemplate.add(HeroAttributeEnum.CurHP.getPropertyId()); // 生命 @@ -294,9 +294,7 @@ public class HeroLogic { boolean enoughCost = false; for (int[] cost : sLotterySetting.getCostItem()) { int[] costItem = new int[cost.length]; - for (int i = 0; i < cost.length; i++) { - costItem[i] = cost[i]; - } + System.arraycopy(cost, 0, costItem, 0, cost.length); int[][] costItems = new int[][]{costItem}; if (costItems[0][0] == Global.GEM) { //每日妖精抽取次数 @@ -444,9 +442,7 @@ public class HeroLogic { //记录卡池抽奖次数 heroManager.putRandomType(type, num + result[1]); int[]rewardArr=new int[result.length]; - for (int i = 0; i < result.length; i++) { - rewardArr[i]=result[i]; - } + System.arraycopy(result, 0, rewardArr, 0, result.length); return rewardArr; } @@ -463,7 +459,7 @@ public class HeroLogic { return sLotteryRewardConfig.getReward(); } - if (user.getHeroManager().getBeautyBagCardInfoMap().containsKey(index + 1) == false) { + if (!user.getHeroManager().getBeautyBagCardInfoMap().containsKey(index + 1)) { return sLotteryRewardConfig.getReward(); } int[] result = new int[2]; @@ -588,7 +584,7 @@ public class HeroLogic { return item; } int randomInt = MathUtils.randomInt(weight); - LOGGER.error("*************************************心愿抽奖权重,总权重:{},随机值:{},map:{}", weight, randomInt, map.toString()); + LOGGER.error("*************************************心愿抽奖权重,总权重:{},随机值:{},map:{}", weight, randomInt, map); // 遍历权重 for (Map.Entry entry : map.entrySet()) { if (randomInt <= entry.getValue()) { @@ -1708,10 +1704,7 @@ public class HeroLogic { hongmengLevel = heroList.get(heroList.size()-1).getOriginalLevel(); } // 验证等级 - if (hongmengLevel >= rankUp.getLimitHongmengLevel()){ - return true; - } - return false; + return hongmengLevel >= rankUp.getLimitHongmengLevel(); } /** @@ -3118,7 +3111,7 @@ public class HeroLogic { 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][]; + int[][] property = new int[levelPara.length][2]; for (int i = 0; i < levelPara.length; i++) { int[] alone = levelPara[i]; property[i][0] = alone[0]; @@ -3973,7 +3966,6 @@ public class HeroLogic { it.remove(); needUpdate = true; } - ; if (needUpdate) { user.getTeamPosManager().updateTeamPosByTeamId(entry.getKey(), value); } @@ -5064,7 +5056,7 @@ public class HeroLogic { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } int[][] consume = sSpiritAnimalLevel.getConsume(); - if (consume != null && consume.length > 0) { + if (consume != null) { for (int[] consumeOne : consume) { costMap.put(consumeOne[0], costMap.getOrDefault(consumeOne[0], 0) + consumeOne[1]); } @@ -5072,7 +5064,7 @@ public class HeroLogic { boolean b = ItemUtil.checkCost(user, costMap); if (!b) { //把多的这一次减下去 - if (consume != null && consume.length > 0) { + if (consume != null) { for (int[] consumeOne : consume) { costMap.put(consumeOne[0], costMap.getOrDefault(consumeOne[0], 0) - consumeOne[1]); } @@ -5936,11 +5928,11 @@ public class HeroLogic { LOGGER.info("addHongmengTableHero uid=>{} no the heroId=>{}", user.getId(), heroId); throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } - if (heroManager.getHongmengGuards().values().contains(heroId)) { + if (heroManager.getHongmengGuards().containsValue(heroId)) { LOGGER.info("addHongmengTableHero uid=>{} the heroId=>{} is HongmengGuard", user.getId(), heroId); throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } - if (heroManager.getResonances().values().contains(heroId)) { + if (heroManager.getResonances().containsValue(heroId)) { LOGGER.info("addHongmengTableHero uid=>{} the heroId=>{} is Resonances", user.getId(), heroId); throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } @@ -6035,15 +6027,15 @@ public class HeroLogic { continue; } // 鸿蒙守卫 - if (heroManager.getHongmengTablet() <= 0 && heroManager.getHongmengGuards().values().contains(heroId[i])) { + if (heroManager.getHongmengTablet() <= 0 && heroManager.getHongmengGuards().containsValue(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().containsValue(heroId[i])) { value = SSpecialConfig.getOnceArrayValue(SSpecialConfig.HONGMENG_MESSENGER_LIMIT); } // 共鸣神将 - if (heroManager.getResonances().values().contains(heroId[i])) { + if (heroManager.getResonances().containsValue(heroId[i])) { value = SSpecialConfig.getOnceArrayValue(SSpecialConfig.HONGMENG_TAKE_LIMIT); } if (value == null) { @@ -6058,7 +6050,7 @@ public class HeroLogic { } } } - boolean contains = heroMap.values().contains(false); + boolean contains = heroMap.containsValue(false); return !contains; } @@ -6523,7 +6515,7 @@ public class HeroLogic { // 角色初始被动 int[] skillLogicConfig = tempHero.getInitialPassiveSkillLogicConfig(); - if (skillLogicConfig != null && skillLogicConfig.length > 0){ + if (skillLogicConfig != null){ for (int skill : skillLogicConfig) { skillList.add(skill); } @@ -6585,7 +6577,7 @@ public class HeroLogic { // 角色初始被动 int[] skillLogicConfig = tempHero.getInitialPassiveSkillLogicConfig(); - if (skillLogicConfig != null && skillLogicConfig.length > 0){ + if (skillLogicConfig != null){ for (int skill : skillLogicConfig) { skillList.add(skill); } @@ -6829,9 +6821,7 @@ public class HeroLogic { int[][] result = new int[tier][2]; // 两层循环,根据解锁的条数重新赋值到新的二维数组 for (int i = 0; i < tier; i++) { - for (int j = 0; j < property[i].length; j++) { - result[i][j] = property[i][j]; - } + System.arraycopy(property[i], 0, result[i], 0, property[i].length); } // 返回 return result;