Browse Source

zerg mechanic work

lakebane-master
FatBoy-DOTC 7 months ago
parent
commit
e47430e61b
  1. 2
      src/engine/objects/Mine.java
  2. 60
      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();
} }
} }

60
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;
@ -77,7 +70,7 @@ public boolean isMine = false;
continue; continue;
mine._playerMemory.add(player.getObjectUUID()); mine._playerMemory.add(player.getObjectUUID());
ChatManager.chatSystemInfo(player,"TESTING ZERG MECHANIC"); ChatManager.chatSystemInfo(player, "TESTING ZERG MECHANIC");
} }
boolean updated = false; boolean updated = false;
try { try {
@ -86,22 +79,23 @@ public boolean isMine = false;
Logger.error(e.getMessage()); Logger.error(e.getMessage());
} }
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();
if(mine.dividedPlayers.containsKey(nation)){ Guild entry;
if (mine.dividedPlayers.containsKey(nation)) {
mine.dividedPlayers.get(nation).add(playerID); mine.dividedPlayers.get(nation).add(playerID);
}else{ } else {
ArrayList<Integer> newEntry = new ArrayList<>(); ArrayList<Integer> newEntry = new ArrayList<>();
newEntry.add(playerID); newEntry.add(playerID);
mine.dividedPlayers.put(nation,newEntry); mine.dividedPlayers.put(nation, newEntry);
} }
} }
for(Integer playerID : mine._playerMemory){ for (Integer playerID : mine._playerMemory) {
player = PlayerCharacter.getFromCache(playerID); player = PlayerCharacter.getFromCache(playerID);
if(mine.dividedPlayers.containsKey(player.getGuild().getNation())){ if (mine.dividedPlayers.containsKey(player.getGuild().getNation())) {
int count = mine.dividedPlayers.get(player.getGuild().getNation()).size(); int count = mine.dividedPlayers.get(player.getGuild().getNation()).size();
switch(mine.capSize){ switch (mine.capSize) {
case 3: case 3:
player.ZergMultiplier = ZergManager.getMultiplier3Man(count); player.ZergMultiplier = ZergManager.getMultiplier3Man(count);
break; break;
@ -116,14 +110,16 @@ public boolean isMine = false;
break; break;
} }
player.mineAppliedID = mine.getObjectUUID(); player.mineAppliedID = mine.getObjectUUID();
} else{ } else {
player.ZergMultiplier = 1.0f; player.ZergMultiplier = 1.0f;
player.mineAppliedID = 0; player.mineAppliedID = 0;
} }
} }
} }
}
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);
@ -134,37 +130,37 @@ public boolean isMine = false;
ArrayList<PlayerCharacter> attackers = new ArrayList<>(); ArrayList<PlayerCharacter> attackers = new ArrayList<>();
ArrayList<PlayerCharacter> defenders = new ArrayList<>(); ArrayList<PlayerCharacter> defenders = new ArrayList<>();
for(AbstractWorldObject awo : currentPlayers){ for (AbstractWorldObject awo : currentPlayers) {
PlayerCharacter pc = (PlayerCharacter) awo; PlayerCharacter pc = (PlayerCharacter) awo;
if(!pc.getGuild().getNation().equals(attacker) && !pc.getGuild().getNation().equals(defender)) { if (!pc.getGuild().getNation().equals(attacker) && !pc.getGuild().getNation().equals(defender)) {
pc.teleport(pc.bindLoc); pc.teleport(pc.bindLoc);
pc.ZergMultiplier = 1.0f; pc.ZergMultiplier = 1.0f;
} }
if(pc.getGuild().getNation().equals(attacker)) if (pc.getGuild().getNation().equals(attacker))
attackers.add(pc); attackers.add(pc);
if(pc.getGuild().getNation().equals(defender)) if (pc.getGuild().getNation().equals(defender))
defenders.add(pc); defenders.add(pc);
} }
int treeRank = bane.getCity().getTOL().getRank(); int treeRank = bane.getCity().getTOL().getRank();
for(PlayerCharacter pc : attackers){ for (PlayerCharacter pc : attackers) {
if(treeRank == 8){ if (treeRank == 8) {
pc.ZergMultiplier = ZergManager.getMultiplier40Man(attackers.size()); pc.ZergMultiplier = ZergManager.getMultiplier40Man(attackers.size());
}else{ } else {
pc.ZergMultiplier = ZergManager.getMultiplier20Man(attackers.size()); pc.ZergMultiplier = ZergManager.getMultiplier20Man(attackers.size());
} }
} }
for(PlayerCharacter pc : defenders){ for (PlayerCharacter pc : defenders) {
if(treeRank == 8){ if (treeRank == 8) {
pc.ZergMultiplier = ZergManager.getMultiplier40Man(defenders.size()); pc.ZergMultiplier = ZergManager.getMultiplier40Man(defenders.size());
}else{ } else {
pc.ZergMultiplier = ZergManager.getMultiplier20Man(defenders.size()); pc.ZergMultiplier = ZergManager.getMultiplier20Man(defenders.size());
} }
} }
}
} }
} }

Loading…
Cancel
Save