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 { @@ -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();
}
}

60
src/engine/workthreads/ZergMechanicThread.java

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

Loading…
Cancel
Save