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 39f9c7cf7..0091ee1eb 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 @@ -1547,8 +1547,11 @@ public class HeroLogic { throw new ErrorCodeException(ErrorCode.HERO_ITEM_NOT); } } - - if (needTotalHeroNums != (removeHeroIds.size() + removeItemMap.size())) { + int itemNum = 0; + for (Integer value : removeItemMap.values()) { + itemNum += value; + } + if (needTotalHeroNums != (removeHeroIds.size() + itemNum)) { LOGGER.error("hero num not enough"); throw new ErrorCodeException(ErrorCode.HERO_UN_MATCH); } @@ -4059,11 +4062,10 @@ public class HeroLogic { // 法宝归元 if (hero.getEspecialEquipLevel() > 0) { Map dropTempMap = ItemLogic.getInstance().heroEspecialEquipReturnItem(hero); - if (dropTempMap == null) { - throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + if (dropTempMap != null) { + dropTempMap.forEach((k, v) -> dropMap.put(k, dropMap.getOrDefault(k, 0) + v)); + hero.updateEspecial(1); } - dropTempMap.forEach((k, v) -> dropMap.put(k, dropMap.getOrDefault(k, 0) + v)); - hero.updateEspecial(1); } // 卸下魂印 Map soulEquipByPositionMap = hero.getSoulEquipByPositionMap(); @@ -4092,13 +4094,19 @@ public class HeroLogic { } ItemUtil.itemCost(user, cost, BIReason.HERO_RETURN, hero.getTemplateId()); CommonProto.Drop.Builder drop = ItemUtil.drop(user, ItemUtil.mapToArray(dropMap), BIReason.HERO_RETURN); - List itemList = drop.getItemlistList(); - List itemId = new ArrayList<>(itemList.size()); - List itemNum = new ArrayList<>(itemList.size()); - itemList.forEach(item -> { - itemId.add(item.getItemId()); - itemNum.add((int) item.getItemNum()); - }); + if (!soulEquipByPositionMap.isEmpty()) { + List itemlistList = drop.getItemlistList(); + Set needRemove = new HashSet<>(soulEquipByPositionMap.size()); + for (int i = 0; i < itemlistList.size(); i++) { + CommonProto.Item item = itemlistList.get(i); + if (soulEquipByPositionMap.values().contains(item.getItemId())) { + needRemove.add(i); + } + } + for (Integer index : needRemove) { + drop.removeItemlist(index); + } + } hero.setLevel(1); hero.setBreakId(0); hero.setStar(5);