Browse Source

siege asset placement reliant on attcker/defender maximums

master
FatBoy-DOTC 2 years ago
parent
commit
325c8b8254
  1. 45
      src/engine/net/client/handlers/PlaceAssetMsgHandler.java

45
src/engine/net/client/handlers/PlaceAssetMsgHandler.java

@ -23,6 +23,7 @@ import engine.objects.*;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import sun.util.calendar.ZoneInfo;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
@ -122,7 +123,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
} }
// Let's now attempt to place the building // Let's now attempt to place the building
buildingCreated = false; buildingCreated = false;
// Many buildings have particular validation and // Many buildings have particular validation and
@ -394,12 +394,11 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
return true; return true;
// If there is an bane placed, we protect 2x the stone rank's worth of attacker assets // If there is an bane placed, we protect 2x the stone rank's worth of attacker assets
// and 1x the tree rank's worth of assets automatically // and 1x the tree rank's worth of assets automatically
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(serverCity, 1000, MBServerStatics.MASK_BUILDING); HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(serverCity, 1000, MBServerStatics.MASK_BUILDING);
for (AbstractWorldObject awo : awoList) { for (AbstractWorldObject awo : awoList) {
Building building = (Building)awo; Building building = (Building)awo;
@ -426,25 +425,41 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
if (building.getGuild().equals(serverCity.getGuild())) if (building.getGuild().equals(serverCity.getGuild()))
numDefenderBuildings++; numDefenderBuildings++;
else else if (building.getGuild().equals(serverCity.getBane().getOwner().getGuild()))
if (building.getGuild().equals(serverCity.getBane().getOwner().getGuild()))
numAttackerBuildings++; numAttackerBuildings++;
}
// Validate bane limits on siege assets // Validate bane limits on siege assets
//if (serverCity.getBane() != null)
if (serverCity.getBane() != null) // if ((player.getGuild().equals(serverCity.getBane().getOwner().getGuild())) &&
if ((player.getGuild().equals(serverCity.getBane().getOwner().getGuild())) && // (numAttackerBuildings >= serverCity.getBane().getStone().getRank() * 2)) {
(numAttackerBuildings >= serverCity.getBane().getStone().getRank() * 2)) { // return true;
// }
//if ((player.getGuild().equals(serverCity.getGuild())) &&
// (numDefenderBuildings >= serverCity.getTOL().getRank())) {
// return true;
//}
int maxAttackerAssets = serverCity.getBane().getStone().getRank() * 2;
int maxDefenderAssets = serverCity.getRank();
if(player.getGuild() == serverCity.getGuild()){
//defender attempting to place asset
if(numDefenderBuildings == maxDefenderAssets){
return true; return true;
} }
}
if ((player.getGuild().equals(serverCity.getGuild())) && else if(player.getGuild() == serverCity.getBane().getStone().getGuild()){
(numDefenderBuildings >= serverCity.getTOL().getRank())) { //attacker attempting to place asset
if(numAttackerBuildings == maxAttackerAssets){
return true; return true;
} }
}
else{
//third party attempting to place asset, early exit
return true;
}
}

Loading…
Cancel
Save