Browse Source

catch process mine window logic

lakebane-master
FatBoy-DOTC 7 months ago
parent
commit
72d73883a4
  1. 20
      src/engine/objects/Mine.java

20
src/engine/objects/Mine.java

@ -661,38 +661,42 @@ public class Mine extends AbstractGameObject {
mine.wasClaimed = true; mine.wasClaimed = true;
return true; return true;
} }
public static void processMineWindows(){ public static void processMineWindows() {
LocalDateTime currentTime = LocalDateTime.now(); LocalDateTime currentTime = LocalDateTime.now();
for (Mine mine : Mine.getMines()) { for (Mine mine : Mine.getMines()) {
try {
Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID()); Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID());
//if the tower comes back null, skip this mine //if the tower comes back null, skip this mine
if(tower == null) if (tower == null)
continue; continue;
//check if this mine needs to open //check if this mine needs to open
LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).withSecond(0).withNano(0); LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).withSecond(0).withNano(0);
if(currentTime.isAfter(openTime) && currentTime.isBefore(openTime.plusMinutes(30)) && !mine.wasOpened){ if (currentTime.isAfter(openTime) && currentTime.isBefore(openTime.plusMinutes(30)) && !mine.wasOpened) {
mineWindowOpen(mine); //hour and minute match, time to open the window mineWindowOpen(mine); //hour and minute match, time to open the window
ChatManager.chatSystemChannel(mine.getParentZone().getName() + " " + mine.getMineType() + "MINE is now vulnerable to attack!"); ChatManager.chatSystemChannel(mine.getParentZone().getName() + " " + mine.getMineType() + "MINE is now vulnerable to attack!");
continue; continue;
} }
//check to see if the window shoul dbe closing now //check to see if the window shoul dbe closing now
if(currentTime.isAfter(openTime.plusMinutes(29)) && mine.isActive) { if (currentTime.isAfter(openTime.plusMinutes(29)) && mine.isActive) {
//check to see if the tower was destoryed //check to see if the tower was destoryed
boolean towerDestroyed = tower.getRank() < 1; boolean towerDestroyed = tower.getRank() < 1;
if(towerDestroyed){ if (towerDestroyed) {
//check if a valid claimer exists to close the window and claim the mine since the tower was destroyed //check if a valid claimer exists to close the window and claim the mine since the tower was destroyed
if(mine.lastClaimer != null) { if (mine.lastClaimer != null) {
mineWindowClose(mine); mineWindowClose(mine);
ChatManager.chatSystemChannel("The fight for " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE has concluded. " + mine.lastClaimer.getName() + " has seized it in the name of " + mine.lastClaimer.getGuild().getNation()); ChatManager.chatSystemChannel("The fight for " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE has concluded. " + mine.lastClaimer.getName() + " has seized it in the name of " + mine.lastClaimer.getGuild().getNation());
}else{ } else {
ChatManager.chatSystemChannel("The " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE is still unclaimed. The battle continues."); ChatManager.chatSystemChannel("The " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE is still unclaimed. The battle continues.");
} }
}else{ } else {
//tower was not destroyed, mine window closes //tower was not destroyed, mine window closes
mineWindowClose(mine); mineWindowClose(mine);
ChatManager.chatSystemChannel(tower.getGuild().getNation().getName() + " has successfully defended the " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE, and retains their claim."); ChatManager.chatSystemChannel(tower.getGuild().getNation().getName() + " has successfully defended the " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE, and retains their claim.");
} }
} }
} catch (Exception ex) {
Logger.error("Mine Failed: " + mine.getObjectUUID() + " " + ex.getMessage());
}
} }
} }
} }

Loading…
Cancel
Save