Browse Source

zerg mechanic work

lakebane-master
FatBoy-DOTC 8 months ago
parent
commit
e47430e61b
  1. 2
      src/engine/objects/Mine.java
  2. 22
      src/engine/workthreads/ZergMechanicThread.java

2
src/engine/objects/Mine.java

@ -582,7 +582,7 @@ public class Mine extends AbstractGameObject {
if(isAc) { if(isAc) {
Thread zergMechanicThread = new Thread(new ZergMechanicThread(null, this)); Thread zergMechanicThread = new Thread(new ZergMechanicThread(null, this));
zergMechanicThread.setName(this.zoneName + "Mine"); zergMechanicThread.setName(this.parentZone.getName() + "Mine");
zergMechanicThread.start(); zergMechanicThread.start();
} }
} }

22
src/engine/workthreads/ZergMechanicThread.java

@ -33,29 +33,22 @@ import static engine.server.MBServerStatics.MINE_LATE_WINDOW;
public class ZergMechanicThread implements Runnable { public class ZergMechanicThread implements Runnable {
public Bane bane = null; public Bane bane = null;
public Mine mine = null; public Mine mine = null;
public boolean isMine = false;
public ZergMechanicThread(Bane b, Mine m) { public ZergMechanicThread(Bane b, Mine m) {
if(b != null){
this.isMine = false;
}
if(m != null){
this.isMine = true;
}
} }
@Override @Override
public void run() { public void run() {
while(mine != null && mine.isActive) if (mine != null)
RunMineMechanic(); RunMineMechanic();
if (bane != null)
while(bane != null && bane.getSiegePhase().equals(Enum.SiegePhase.WAR))
RunBaneMechanic(); RunBaneMechanic();
} }
public void RunMineMechanic(){ public void RunMineMechanic(){
while(mine.isActive) {
HashSet<AbstractWorldObject> currentPlayers; HashSet<AbstractWorldObject> currentPlayers;
PlayerCharacter player; PlayerCharacter player;
@ -88,7 +81,8 @@ public boolean isMine = false;
mine.dividedPlayers = new HashMap<>(); mine.dividedPlayers = new HashMap<>();
for (Integer playerID : mine._playerMemory) { for (Integer playerID : mine._playerMemory) {
player = PlayerCharacter.getFromCache(playerID); player = PlayerCharacter.getFromCache(playerID);
Guild nation = player.getGuild().getNation(); Guild entry; Guild nation = player.getGuild().getNation();
Guild entry;
if (mine.dividedPlayers.containsKey(nation)) { if (mine.dividedPlayers.containsKey(nation)) {
mine.dividedPlayers.get(nation).add(playerID); mine.dividedPlayers.get(nation).add(playerID);
} else { } else {
@ -122,8 +116,10 @@ public boolean isMine = false;
} }
} }
} }
}
public void RunBaneMechanic(){ public void RunBaneMechanic(){
while(bane.getSiegePhase().equals(Enum.SiegePhase.WAR)) {
HashSet<AbstractWorldObject> currentPlayers; HashSet<AbstractWorldObject> 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);
@ -165,6 +161,6 @@ public boolean isMine = false;
pc.ZergMultiplier = ZergManager.getMultiplier20Man(defenders.size()); pc.ZergMultiplier = ZergManager.getMultiplier20Man(defenders.size());
} }
} }
}
} }
} }

Loading…
Cancel
Save