From b6c502c1993c41c0c291a64f1db9a87698f59e64 Mon Sep 17 00:00:00 2001 From: grimm <1769111741@qq.com> Date: Wed, 22 May 2024 14:33:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=9E=E6=8A=80=E5=9C=BA=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E6=B6=88=E8=80=97=E6=AC=A1=E6=95=B0=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ljsd/jieling/logic/arena/ArenaLogic.java | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java index 7fb1d1573..f375164c4 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java @@ -196,22 +196,31 @@ public class ArenaLogic { /** * 竞技场挑战消耗校验 + * @param ifUpdate true 消耗 */ - public void checkChallenge(User user) throws Exception { + public void checkChallenge(User user, boolean ifUpdate) throws Exception { if (!user.getTeamPosManager().getTeamPosForHero().containsKey(TeamEnum.TEAM_ARENA_DEFENSE.getTeamId())) { throw new ErrorTableException(161);//编队未配置 } SArenaSetting sArenaSetting = SArenaSetting.getSArenaSetting(); - // 免费特权 int battleFree = sArenaSetting.getBattleFree(); - boolean vipUpdate = PlayerLogic.getInstance().checkAndUpdate(user, battleFree, 1); - if (vipUpdate){ - return; - } - // 道具校验 - boolean enough = ItemUtil.itemCost(user, new int[][]{sArenaSetting.getCost()}, BIReason.ARENA_CHALLENGE_CONSUME, 0); - if (!enough) { - throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); + + if (ifUpdate){ + // 免费特权 + PlayerLogic.getInstance().checkAndUpdate(user, battleFree, 1); + // 道具校验 + ItemUtil.itemCost(user, new int[][]{sArenaSetting.getCost()}, BIReason.ARENA_CHALLENGE_CONSUME, 0); + }else { + // 免费特权 + boolean vipUpdate = PlayerLogic.getInstance().check(user, battleFree, 1); + if (vipUpdate){ + return; + } + // 道具校验 + boolean enough = ItemUtil.checkCost(user, new int[][]{sArenaSetting.getCost()}); + if (!enough) { + throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); + } } } @@ -800,7 +809,7 @@ public class ArenaLogic { int challengeTeamId = TeamEnum.MIAN_LINE_TEAM.getTeamId(); // 校验是否可以战斗 - checkChallenge(user); + checkChallenge(user, false); // 初始化战斗结果和防御方原始分数 FightResult result; @@ -824,6 +833,9 @@ public class ArenaLogic { if(fightResult == -1){ throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION, "战斗异常"); } +// if (true){ +// throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION, "战斗异常"); +// } // 获取我的原始分数 ArenaInfo arenaInfo = getArenaInfo(user.getId()); int roomId = arenaInfo.getRoomId(); @@ -853,6 +865,8 @@ public class ArenaLogic { refreshArenaOpponentList(user); // 任务 user.getUserMissionManager().onGameEvent(user, GameEvent.ARENA_CHALLENGE, fightResult, myScore); + // 校验并消耗 + checkChallenge(user, true); // 返回包装 CommonProto.Drop.Builder arenaReward = getArenaReward(user, fightResult); ArenaInfoProto.NewArenaChallengeResponse.Builder builder = ArenaInfoProto.NewArenaChallengeResponse.newBuilder()