回退bug

back_recharge
jiahuiwen 2021-12-16 16:29:55 +08:00
parent 4ae13de871
commit 701d32c31f
1 changed files with 21 additions and 13 deletions

View File

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