diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 899c24a2..b261d266 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -582,7 +582,7 @@ public class Mine extends AbstractGameObject { if(isAc) { Thread zergMechanicThread = new Thread(new ZergMechanicThread(null, this)); - zergMechanicThread.setName(this.zoneName + "Mine"); + zergMechanicThread.setName(this.parentZone.getName() + "Mine"); zergMechanicThread.start(); } } diff --git a/src/engine/workthreads/ZergMechanicThread.java b/src/engine/workthreads/ZergMechanicThread.java index 0b023b83..cf36db27 100644 --- a/src/engine/workthreads/ZergMechanicThread.java +++ b/src/engine/workthreads/ZergMechanicThread.java @@ -33,138 +33,134 @@ import static engine.server.MBServerStatics.MINE_LATE_WINDOW; public class ZergMechanicThread implements Runnable { public Bane bane = null; public Mine mine = null; -public boolean isMine = false; public ZergMechanicThread(Bane b, Mine m) { - if(b != null){ - this.isMine = false; - } - if(m != null){ - this.isMine = true; - } + } @Override public void run() { - while(mine != null && mine.isActive) + if (mine != null) RunMineMechanic(); - - while(bane != null && bane.getSiegePhase().equals(Enum.SiegePhase.WAR)) + if (bane != null) RunBaneMechanic(); } public void RunMineMechanic(){ + while(mine.isActive) { + HashSet currentPlayers; + PlayerCharacter player; - HashSet currentPlayers; - PlayerCharacter player; - - // Gather current list of players within the zone bounds - Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID()); - currentPlayers = WorldGrid.getObjectsInRangePartial(tower.loc, Enum.CityBoundsType.GRID.extents * 0.5f, MBServerStatics.MASK_PLAYER); + // Gather current list of players within the zone bounds + Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID()); + currentPlayers = WorldGrid.getObjectsInRangePartial(tower.loc, Enum.CityBoundsType.GRID.extents * 0.5f, MBServerStatics.MASK_PLAYER); - for (AbstractWorldObject playerObject : currentPlayers) { + for (AbstractWorldObject playerObject : currentPlayers) { - if (playerObject == null) - continue; + if (playerObject == null) + continue; - player = (PlayerCharacter) playerObject; + player = (PlayerCharacter) playerObject; - if (mine._recentMemory.containsKey(player.getObjectUUID())) - mine._recentMemory.remove(player.getObjectUUID()); + if (mine._recentMemory.containsKey(player.getObjectUUID())) + mine._recentMemory.remove(player.getObjectUUID()); - if (mine._playerMemory.contains(player.getObjectUUID())) - continue; + if (mine._playerMemory.contains(player.getObjectUUID())) + continue; - mine._playerMemory.add(player.getObjectUUID()); - ChatManager.chatSystemInfo(player,"TESTING ZERG MECHANIC"); - } - boolean updated = false; - try { - mine.onExit(currentPlayers); - } catch (Exception e) { - Logger.error(e.getMessage()); - } - mine.dividedPlayers = new HashMap<>(); - for(Integer playerID : mine._playerMemory){ - player = PlayerCharacter.getFromCache(playerID); - Guild nation = player.getGuild().getNation(); Guild entry; - if(mine.dividedPlayers.containsKey(nation)){ - mine.dividedPlayers.get(nation).add(playerID); - }else{ - ArrayList newEntry = new ArrayList<>(); - newEntry.add(playerID); - mine.dividedPlayers.put(nation,newEntry); + mine._playerMemory.add(player.getObjectUUID()); + ChatManager.chatSystemInfo(player, "TESTING ZERG MECHANIC"); } - } - for(Integer playerID : mine._playerMemory){ - player = PlayerCharacter.getFromCache(playerID); - if(mine.dividedPlayers.containsKey(player.getGuild().getNation())){ - int count = mine.dividedPlayers.get(player.getGuild().getNation()).size(); - switch(mine.capSize){ - case 3: - player.ZergMultiplier = ZergManager.getMultiplier3Man(count); - break; - case 5: - player.ZergMultiplier = ZergManager.getMultiplier5Man(count); - break; - case 10: - player.ZergMultiplier = ZergManager.getMultiplier10Man(count); - break; - case 20: - player.ZergMultiplier = ZergManager.getMultiplier20Man(count); - break; + boolean updated = false; + try { + mine.onExit(currentPlayers); + } catch (Exception e) { + Logger.error(e.getMessage()); + } + mine.dividedPlayers = new HashMap<>(); + for (Integer playerID : mine._playerMemory) { + player = PlayerCharacter.getFromCache(playerID); + Guild nation = player.getGuild().getNation(); + Guild entry; + if (mine.dividedPlayers.containsKey(nation)) { + mine.dividedPlayers.get(nation).add(playerID); + } else { + ArrayList newEntry = new ArrayList<>(); + newEntry.add(playerID); + mine.dividedPlayers.put(nation, newEntry); + } + } + for (Integer playerID : mine._playerMemory) { + player = PlayerCharacter.getFromCache(playerID); + if (mine.dividedPlayers.containsKey(player.getGuild().getNation())) { + int count = mine.dividedPlayers.get(player.getGuild().getNation()).size(); + switch (mine.capSize) { + case 3: + player.ZergMultiplier = ZergManager.getMultiplier3Man(count); + break; + case 5: + player.ZergMultiplier = ZergManager.getMultiplier5Man(count); + break; + case 10: + player.ZergMultiplier = ZergManager.getMultiplier10Man(count); + break; + case 20: + player.ZergMultiplier = ZergManager.getMultiplier20Man(count); + break; + } + player.mineAppliedID = mine.getObjectUUID(); + } else { + player.ZergMultiplier = 1.0f; + player.mineAppliedID = 0; } - player.mineAppliedID = mine.getObjectUUID(); - } else{ - player.ZergMultiplier = 1.0f; - player.mineAppliedID = 0; } } } public void RunBaneMechanic(){ - HashSet currentPlayers; + while(bane.getSiegePhase().equals(Enum.SiegePhase.WAR)) { + HashSet currentPlayers; - currentPlayers = WorldGrid.getObjectsInRangePartial(bane.getCity().loc, Enum.CityBoundsType.GRID.extents * 2.0f, MBServerStatics.MASK_PLAYER); + currentPlayers = WorldGrid.getObjectsInRangePartial(bane.getCity().loc, Enum.CityBoundsType.GRID.extents * 2.0f, MBServerStatics.MASK_PLAYER); - Guild attacker = bane.getStone().getGuild().getNation(); - Guild defender = bane.getCity().getGuild().getNation(); + Guild attacker = bane.getStone().getGuild().getNation(); + Guild defender = bane.getCity().getGuild().getNation(); - ArrayList attackers = new ArrayList<>(); - ArrayList defenders = new ArrayList<>(); + ArrayList attackers = new ArrayList<>(); + ArrayList defenders = new ArrayList<>(); - for(AbstractWorldObject awo : currentPlayers){ - PlayerCharacter pc = (PlayerCharacter) awo; - if(!pc.getGuild().getNation().equals(attacker) && !pc.getGuild().getNation().equals(defender)) { - pc.teleport(pc.bindLoc); - pc.ZergMultiplier = 1.0f; - } + for (AbstractWorldObject awo : currentPlayers) { + PlayerCharacter pc = (PlayerCharacter) awo; + if (!pc.getGuild().getNation().equals(attacker) && !pc.getGuild().getNation().equals(defender)) { + pc.teleport(pc.bindLoc); + pc.ZergMultiplier = 1.0f; + } - if(pc.getGuild().getNation().equals(attacker)) - attackers.add(pc); + if (pc.getGuild().getNation().equals(attacker)) + attackers.add(pc); - if(pc.getGuild().getNation().equals(defender)) - defenders.add(pc); - } + if (pc.getGuild().getNation().equals(defender)) + defenders.add(pc); + } - int treeRank = bane.getCity().getTOL().getRank(); + int treeRank = bane.getCity().getTOL().getRank(); - for(PlayerCharacter pc : attackers){ - if(treeRank == 8){ - pc.ZergMultiplier = ZergManager.getMultiplier40Man(attackers.size()); - }else{ - pc.ZergMultiplier = ZergManager.getMultiplier20Man(attackers.size()); + for (PlayerCharacter pc : attackers) { + if (treeRank == 8) { + pc.ZergMultiplier = ZergManager.getMultiplier40Man(attackers.size()); + } else { + pc.ZergMultiplier = ZergManager.getMultiplier20Man(attackers.size()); + } } - } - for(PlayerCharacter pc : defenders){ - if(treeRank == 8){ - pc.ZergMultiplier = ZergManager.getMultiplier40Man(defenders.size()); - }else{ - pc.ZergMultiplier = ZergManager.getMultiplier20Man(defenders.size()); + for (PlayerCharacter pc : defenders) { + if (treeRank == 8) { + pc.ZergMultiplier = ZergManager.getMultiplier40Man(defenders.size()); + } else { + pc.ZergMultiplier = ZergManager.getMultiplier20Man(defenders.size()); + } } } - } }