Browse Source

zerg mechanic work

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

186
src/engine/workthreads/ZergMechanicThread.java

@ -33,138 +33,134 @@ 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;
PlayerCharacter player;
HashSet<AbstractWorldObject> currentPlayers; // Gather current list of players within the zone bounds
PlayerCharacter player; 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) if (playerObject == null)
continue; continue;
player = (PlayerCharacter) playerObject; player = (PlayerCharacter) playerObject;
if (mine._recentMemory.containsKey(player.getObjectUUID())) if (mine._recentMemory.containsKey(player.getObjectUUID()))
mine._recentMemory.remove(player.getObjectUUID()); mine._recentMemory.remove(player.getObjectUUID());
if (mine._playerMemory.contains(player.getObjectUUID())) if (mine._playerMemory.contains(player.getObjectUUID()))
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;
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<Integer> newEntry = new ArrayList<>();
newEntry.add(playerID);
mine.dividedPlayers.put(nation,newEntry);
} }
} boolean updated = false;
for(Integer playerID : mine._playerMemory){ try {
player = PlayerCharacter.getFromCache(playerID); mine.onExit(currentPlayers);
if(mine.dividedPlayers.containsKey(player.getGuild().getNation())){ } catch (Exception e) {
int count = mine.dividedPlayers.get(player.getGuild().getNation()).size(); Logger.error(e.getMessage());
switch(mine.capSize){ }
case 3: mine.dividedPlayers = new HashMap<>();
player.ZergMultiplier = ZergManager.getMultiplier3Man(count); for (Integer playerID : mine._playerMemory) {
break; player = PlayerCharacter.getFromCache(playerID);
case 5: Guild nation = player.getGuild().getNation();
player.ZergMultiplier = ZergManager.getMultiplier5Man(count); Guild entry;
break; if (mine.dividedPlayers.containsKey(nation)) {
case 10: mine.dividedPlayers.get(nation).add(playerID);
player.ZergMultiplier = ZergManager.getMultiplier10Man(count); } else {
break; ArrayList<Integer> newEntry = new ArrayList<>();
case 20: newEntry.add(playerID);
player.ZergMultiplier = ZergManager.getMultiplier20Man(count); mine.dividedPlayers.put(nation, newEntry);
break; }
}
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(){ public void RunBaneMechanic(){
HashSet<AbstractWorldObject> currentPlayers; while(bane.getSiegePhase().equals(Enum.SiegePhase.WAR)) {
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);
Guild attacker = bane.getStone().getGuild().getNation(); Guild attacker = bane.getStone().getGuild().getNation();
Guild defender = bane.getCity().getGuild().getNation(); Guild defender = bane.getCity().getGuild().getNation();
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