Browse Source

catch process mine window logic

lakebane-master
FatBoy-DOTC 6 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 { @@ -661,38 +661,42 @@ public class Mine extends AbstractGameObject {
mine.wasClaimed = true;
return true;
}
public static void processMineWindows(){
public static void processMineWindows() {
LocalDateTime currentTime = LocalDateTime.now();
for (Mine mine : Mine.getMines()) {
try {
Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID());
//if the tower comes back null, skip this mine
if(tower == null)
if (tower == null)
continue;
//check if this mine needs to open
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
ChatManager.chatSystemChannel(mine.getParentZone().getName() + " " + mine.getMineType() + "MINE is now vulnerable to attack!");
continue;
}
//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
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
if(mine.lastClaimer != null) {
if (mine.lastClaimer != null) {
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());
}else{
} else {
ChatManager.chatSystemChannel("The " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE is still unclaimed. The battle continues.");
}
}else{
} else {
//tower was not destroyed, mine window closes
mineWindowClose(mine);
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