From 7a670ffdbfa237c7062d009f7adf9993ab82a413 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 14 Jan 2023 13:35:37 -0500 Subject: [PATCH] Appropriate error messages for BOW limits. --- .../client/handlers/PlaceAssetMsgHandler.java | 34 +++++-------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 4e65d5b6..f983bfeb 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -415,7 +415,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (building.getGuild().isErrant()) continue; - if (!building.getGuild().equals(serverCity.getGuild()) && !building.getGuild().equals(serverCity.getBane().getOwner().getGuild())) continue; @@ -428,28 +427,22 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { else if (building.getGuild().equals(serverCity.getBane().getOwner().getGuild())) numAttackerBuildings++; -// Validate bane limits on siege assets - //if (serverCity.getBane() != null) - // if ((player.getGuild().equals(serverCity.getBane().getOwner().getGuild())) && - // (numAttackerBuildings >= serverCity.getBane().getStone().getRank() * 2)) { - // return true; - // } - - //if ((player.getGuild().equals(serverCity.getGuild())) && - // (numDefenderBuildings >= serverCity.getTOL().getRank())) { - // return true; - //} + // Validate bane limits on siege assets + int maxAttackerAssets = serverCity.getBane().getStone().getRank() * 2; int maxDefenderAssets = serverCity.getRank(); - if(player.getGuild() == serverCity.getGuild()){ + + if(player.getGuild().equals(serverCity.getGuild())){ //defender attempting to place asset - if(numDefenderBuildings == maxDefenderAssets){ + if(numDefenderBuildings >= maxDefenderAssets){ + PlaceAssetMsg.sendPlaceAssetError(origin,62, ""); return true; } } - else if(player.getGuild() == serverCity.getBane().getStone().getGuild()){ + else if(player.getGuild().equals(serverCity.getBane().getStone().getGuild())){ //attacker attempting to place asset - if(numAttackerBuildings == maxAttackerAssets){ + if(numAttackerBuildings >= maxAttackerAssets){ + PlaceAssetMsg.sendPlaceAssetError(origin,61, ""); return true; } } @@ -459,10 +452,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { } } - - - - // passes validation: can assign auto-protection to war asset if (serverCity.getBane() != null) @@ -470,11 +459,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (player.getGuild().equals(serverCity.getBane().getOwner().getGuild())) return true; - - - - - siegeBuilding.setProtectionState(ProtectionState.PROTECTED); // No bane placed. We're done!