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 405e515b0..0d2712881 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 @@ -3733,7 +3733,8 @@ public class HeroLogic{ // 装备 hongmengEquip(hongMengAddAttributeEquip, hero); // 魂宝 灵宝 - soulOrSpirit(soulEquip, spiritEquip, equipMap, hero); + soulOrSpirit(soulEquip, 1, equipMap, hero); + soulOrSpirit(spiritEquip, 2, equipMap, hero); // 法宝 especialAdd(especialEquipLevel, hero); } @@ -3853,46 +3854,44 @@ public class HeroLogic{ /** * 鸿蒙阵对魂宝灵宝加成 - * @param soulEquip - * @param spiritEquip + * @param jewelEquip + * @param type 1魂宝 2灵宝 * @param equipMap * @param hero */ - public void soulOrSpirit(HongMengAddAttribute soulEquip, HongMengAddAttribute spiritEquip, Map equipMap, Hero hero) { - if (hero.getJewelInfo().isEmpty()) { - soulEquip.value = -1; - spiritEquip.value = -1; - soulEquip.heroTid = 0; - spiritEquip.heroTid = 0; - } else { - for (String jewel : hero.getJewelInfo()) { - PropertyItem propertyItem = equipMap.get(jewel); - if (propertyItem == null) { - soulEquip.value = -1; - soulEquip.heroTid = 0; - spiritEquip.value = -1; - spiritEquip.heroTid = 0; - break; - } else { - SJewelConfig config = STableManager.getConfig(SJewelConfig.class).get(propertyItem.getEquipId()); - if (config == null) { - continue; - } - // getLocation 1魂宝 2灵宝 - if (config.getLocation() == 1) { - if (propertyItem.getLevel() < soulEquip.value){ - soulEquip.value = propertyItem.getLevel(); - soulEquip.heroTid = hero.getTemplateId(); - } - } else { - if (propertyItem.getLevel() < spiritEquip.value){ - spiritEquip.value = propertyItem.getLevel(); - spiritEquip.heroTid = hero.getTemplateId(); - } + private void soulOrSpirit(HongMengAddAttribute jewelEquip, int type, Map equipMap, Hero hero) { + // 记录器,玩家是否拥有这件装备 + boolean result = true; + // 遍历英雄身上的魂宝和灵宝 + for (String jewel : hero.getJewelInfo()) { + // 玩家装备表里是否存在 + PropertyItem propertyItem = equipMap.get(jewel); + 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){ + jewelEquip.value = propertyItem.getLevel(); + jewelEquip.heroTid = hero.getTemplateId(); } } } } + if (result){ + notJewelInit(jewelEquip); + } + } + + /** + * 没有宝物时初始化 + * @param jewels + */ + private void notJewelInit(HongMengAddAttribute... jewels){ + for (int i = 0; i < jewels.length; i++) { + jewels[i].value = -1; + jewels[i].heroTid = 0; + } } /**