From a0de4fd484085f3b6cd65762d75cf12a06cb9d91 Mon Sep 17 00:00:00 2001 From: duhui Date: Wed, 5 Jan 2022 15:03:28 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=AE=B6=E5=9B=AD=E5=8A=9F=E8=83=BD1.?= =?UTF-8?q?1.14=E3=80=91=201=E3=80=81=E5=A4=84=E7=90=86=E8=A3=85=E5=A4=87?= =?UTF-8?q?=E5=BC=BA=E5=8C=96=E9=80=BB=E8=BE=91bug2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ljsd/jieling/logic/home/HomeLogic.java | 56 ++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/home/HomeLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/home/HomeLogic.java index 21703f1d9..76bee4974 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/home/HomeLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/home/HomeLogic.java @@ -14,6 +14,7 @@ import com.ljsd.jieling.logic.home.event.HomeEvent; import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.player.PlayerLogic; import com.ljsd.jieling.network.session.ISession; +import com.ljsd.jieling.tools.Utils; import com.ljsd.jieling.util.CBean2Proto; import com.ljsd.jieling.util.ItemUtil; import com.ljsd.jieling.util.MessageUtil; @@ -87,35 +88,40 @@ public class HomeLogic { } // 1:普通升级, 2:立即完成 3:取消升级 4:特权加速 int type = proto.getType(); - if (type == 1 || type == 2){ - // 消耗道具 + if (type == 1 && info.getUpLvEndTime() == 0){ + boolean cost = ItemUtil.itemCost(user, landLevel.getCost(), BIReason.ARCHITECTURE_UP_LEVEL, 0); + if (!cost) { + throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH, "浮生门建筑普通升级,建筑levelId:"+info.getId()+",道具:"+Arrays.toString(landLevel.getCost())); + } + info.setUpLvEndTime(now + landLevel.getTime()); + } + if (type == 2){ + ArrayList costList = new ArrayList<>(); + // 验证消耗道具是否满足 if (info.getUpLvEndTime() == 0){ - boolean ifType = false; - boolean cost = ItemUtil.checkCostLong(user, landLevel.getCost(), 1); - if (!cost) { - throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH, "浮生门建筑升级,建筑升级要求道具不足,建筑levelId:"+info.getId()); - } - ifType = true; info.setUpLvEndTime(now + landLevel.getTime()); + costList.addAll(Arrays.asList(landLevel.getCost())); } - // 立即升级消耗妖晶 - if (type == 2){ - // 条件: 单位/s 道具id 道具数量 - int[] intValues = SSpecialConfig.getIntegerArrayValue(SSpecialConfig.HONGMENG_LATTICE_PRICE); - // 立即升级消耗的道具 - int time = Math.max(info.getUpLvEndTime() - now, 0); - if (time > 0){ - // 每一个单位的消耗 - int oneCost = intValues[0] * intValues[2]; - // 总消耗数量,向上取整 - int count = (int) Math.ceil((double) time/oneCost); - boolean itemCost = ItemUtil.itemCost(user, new int[][]{{intValues[1], count}}, BIReason.ARCHITECTURE_IMMEDIATELY_UP_LEVEL, 0); - if (!itemCost) { - throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH, "浮生门建筑升级,立刻升级失败道具不足,建筑levelId:"+info.getId()); - } - } + // 条件: 单位/s 道具id 道具数量 + int[] intValues = SSpecialConfig.getIntegerArrayValue(SSpecialConfig.HONGMENG_LATTICE_PRICE); + // 立即升级消耗的道具 + double time = info.getUpLvEndTime() - now; + // 每一个单位的消耗 + int oneCost = intValues[0] * intValues[2]; + // 总消耗数量,向上取整 + int count = (int) Math.ceil(time / oneCost); + if (count <= 0){ + LOGGER.error("浮生门建筑立即升级,消耗道具数量小于0,请检查配置表数据"); + count = 0; } - ItemUtil.itemCost(user, landLevel.getCost(), BIReason.ARCHITECTURE_UP_LEVEL, 0); + costList.add(new int[]{intValues[1], count}); + // 类型转换 + int[][] arrayObject = Utils.getTwoArrayObject(costList); + boolean itemCost = ItemUtil.itemCost(user, arrayObject, BIReason.ARCHITECTURE_UP_LEVEL, 0); + if (!itemCost){ + throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH, "浮生门建筑立即升级,建筑levelId:"+info.getId()+",道具:"+Arrays.toString(arrayObject)); + } + // 升级 architectureUpLvEnd(user, landLevel.getPoolID(), info); } if (type == 3){