|
|
@ -308,8 +308,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { |
|
|
|
Building siegeBuilding; |
|
|
|
Building siegeBuilding; |
|
|
|
PlacementInfo buildingList; |
|
|
|
PlacementInfo buildingList; |
|
|
|
City serverCity; |
|
|
|
City serverCity; |
|
|
|
int numAttackerBuildings = 0; |
|
|
|
|
|
|
|
int numDefenderBuildings = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Retrieve the building details we're placing
|
|
|
|
// Retrieve the building details we're placing
|
|
|
|
|
|
|
|
|
|
|
@ -359,8 +357,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { |
|
|
|
serverCity = player.getGuild().getOwnedCity(); |
|
|
|
serverCity = player.getGuild().getOwnedCity(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((serverCity != null) && |
|
|
|
if ((serverCity != null) && |
|
|
|
(serverCity.getBane() != null)) { |
|
|
|
(serverCity.getBane() != null)) { |
|
|
|
|
|
|
|
|
|
|
@ -377,95 +373,104 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// cant place siege equipment off city zone.
|
|
|
|
// cant place siege equipment off city zone.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create the siege Building
|
|
|
|
// Create the siege Building
|
|
|
|
|
|
|
|
|
|
|
|
siegeBuilding = createStructure(player, msg.getFirstPlacementInfo(), serverZone); |
|
|
|
siegeBuilding = createStructure(player, msg.getFirstPlacementInfo(), serverZone); |
|
|
|
if (serverCity == null) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
// Oops something went really wrong
|
|
|
|
// Oops something went really wrong
|
|
|
|
|
|
|
|
|
|
|
|
if (siegeBuilding == null) |
|
|
|
if (siegeBuilding == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If there is a bane placed, we limit placement to 2x the stone rank's worth of attacker assets
|
|
|
|
if (serverCity.getBane() == null) |
|
|
|
// and 1x the tree rank for defenders
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (validateSiegeLimits(player, origin, serverCity.getBane()) == false) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// passes validation: can assign auto-protection to war asset
|
|
|
|
|
|
|
|
|
|
|
|
// If there is an bane placed, we protect 2x the stone rank's worth of attacker assets
|
|
|
|
if (serverCity.getBane() != null) |
|
|
|
|
|
|
|
if (serverCity.isLocationOnCityGrid(siegeBuilding.getBounds())) |
|
|
|
|
|
|
|
if (player.getGuild().equals(serverCity.getBane().getOwner().getGuild())) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
// and 1x the tree rank's worth of assets automatically
|
|
|
|
siegeBuilding.setProtectionState(ProtectionState.PROTECTED); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// No bane placed. We're done!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(serverCity, 1000, MBServerStatics.MASK_BUILDING); |
|
|
|
private boolean validateSiegeLimits(PlayerCharacter playerCharacter, ClientConnection origin, Bane bane) { |
|
|
|
|
|
|
|
|
|
|
|
for (AbstractWorldObject awo : awoList) { |
|
|
|
City serverCity = bane.getCity(); |
|
|
|
Building building = (Building)awo; |
|
|
|
HashSet<AbstractWorldObject> awoList; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int maxAttackerAssets = serverCity.getBane().getStone().getRank() * 2; |
|
|
|
|
|
|
|
int maxDefenderAssets = serverCity.getRank(); |
|
|
|
|
|
|
|
int numDefenderBuildings = 0; |
|
|
|
|
|
|
|
int numAttackerBuildings = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Count bow for attackers and defenders
|
|
|
|
|
|
|
|
|
|
|
|
if (building.getBlueprint() != null) |
|
|
|
awoList = WorldGrid.getObjectsInRangePartial(serverCity, 1000, MBServerStatics.MASK_BUILDING); |
|
|
|
if (!building.getBlueprint().isSiegeEquip()) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!building.getLoc().isInsideCircle(serverCity.getLoc(), Enum.CityBoundsType.SIEGE.extents)) |
|
|
|
for (AbstractWorldObject awo : awoList) { |
|
|
|
continue; |
|
|
|
Building building = (Building) awo; |
|
|
|
|
|
|
|
|
|
|
|
if (building.getGuild() == null) |
|
|
|
if (building.getBlueprint() != null) |
|
|
|
|
|
|
|
if (!building.getBlueprint().isSiegeEquip()) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
if (building.getGuild().isErrant()) |
|
|
|
if (!building.getLoc().isInsideCircle(serverCity.getLoc(), Enum.CityBoundsType.SIEGE.extents)) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
if (!building.getGuild().equals(serverCity.getGuild()) && !building.getGuild().equals(serverCity.getBane().getOwner().getGuild())) |
|
|
|
if (building.getGuild() == null) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
// Only count auto protected buildings
|
|
|
|
if (building.getGuild().isErrant()) |
|
|
|
if (building.getProtectionState() != ProtectionState.PROTECTED) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (building.getGuild().equals(serverCity.getGuild())) |
|
|
|
if (!building.getGuild().equals(serverCity.getGuild()) && !building.getGuild().equals(serverCity.getBane().getOwner().getGuild())) |
|
|
|
numDefenderBuildings++; |
|
|
|
continue; |
|
|
|
else if (building.getGuild().equals(serverCity.getBane().getOwner().getGuild())) |
|
|
|
|
|
|
|
numAttackerBuildings++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Validate bane limits on siege assets
|
|
|
|
// Only count auto protected buildings
|
|
|
|
|
|
|
|
if (building.getProtectionState() != ProtectionState.PROTECTED) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
int maxAttackerAssets = serverCity.getBane().getStone().getRank() * 2; |
|
|
|
if (building.getGuild().equals(serverCity.getGuild())) |
|
|
|
int maxDefenderAssets = serverCity.getRank(); |
|
|
|
numDefenderBuildings++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (building.getGuild().equals(serverCity.getBane().getOwner().getGuild())) |
|
|
|
|
|
|
|
numAttackerBuildings++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Validate bane limits on siege assets
|
|
|
|
|
|
|
|
|
|
|
|
if(player.getGuild().equals(serverCity.getGuild())){ |
|
|
|
if (playerCharacter.getGuild().equals(serverCity.getGuild())) { |
|
|
|
//defender attempting to place asset
|
|
|
|
//defender attempting to place asset
|
|
|
|
if(numDefenderBuildings >= maxDefenderAssets){ |
|
|
|
if (numDefenderBuildings >= maxDefenderAssets) { |
|
|
|
PlaceAssetMsg.sendPlaceAssetError(origin,62, ""); |
|
|
|
PlaceAssetMsg.sendPlaceAssetError(origin, 62, ""); |
|
|
|
return true; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if(player.getGuild().equals(serverCity.getBane().getStone().getGuild())){ |
|
|
|
|
|
|
|
|
|
|
|
if (playerCharacter.getGuild().equals(serverCity.getBane().getStone().getGuild())) { |
|
|
|
//attacker attempting to place asset
|
|
|
|
//attacker attempting to place asset
|
|
|
|
if(numAttackerBuildings >= maxAttackerAssets){ |
|
|
|
if (numAttackerBuildings >= maxAttackerAssets) { |
|
|
|
PlaceAssetMsg.sendPlaceAssetError(origin,61, ""); |
|
|
|
PlaceAssetMsg.sendPlaceAssetError(origin, 61, ""); |
|
|
|
return true; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
|
|
|
|
//third party attempting to place asset, early exit
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Passed validation
|
|
|
|
// passes validation: can assign auto-protection to war asset
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
if (serverCity.getBane() != null) |
|
|
|
|
|
|
|
if (serverCity.isLocationOnCityGrid(siegeBuilding.getBounds())) |
|
|
|
|
|
|
|
if (player.getGuild().equals(serverCity.getBane().getOwner().getGuild())) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
siegeBuilding.setProtectionState(ProtectionState.PROTECTED); |
|
|
|
|
|
|
|
// No bane placed. We're done!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean placeTreeOfLife(PlayerCharacter playerCharacter, ClientConnection origin, PlaceAssetMsg msg) { |
|
|
|
private boolean placeTreeOfLife(PlayerCharacter playerCharacter, ClientConnection origin, PlaceAssetMsg msg) { |
|
|
|
|
|
|
|
|
|
|
|
Realm serverRealm; |
|
|
|
Realm serverRealm; |
|
|
|