Browse Source

catch process mine window logic

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

56
src/engine/objects/Mine.java

@ -661,37 +661,41 @@ 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()) {
Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID()); try {
//if the tower comes back null, skip this mine Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID());
if(tower == null) //if the tower comes back null, skip this mine
continue; if (tower == null)
//check if this mine needs to open continue;
LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).withSecond(0).withNano(0); //check if this mine needs to open
if(currentTime.isAfter(openTime) && currentTime.isBefore(openTime.plusMinutes(30)) && !mine.wasOpened){ LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).withSecond(0).withNano(0);
mineWindowOpen(mine); //hour and minute match, time to open the window if (currentTime.isAfter(openTime) && currentTime.isBefore(openTime.plusMinutes(30)) && !mine.wasOpened) {
ChatManager.chatSystemChannel(mine.getParentZone().getName() + " " + mine.getMineType() + "MINE is now vulnerable to attack!"); mineWindowOpen(mine); //hour and minute match, time to open the window
continue; 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) { //check to see if the window shoul dbe closing now
//check to see if the tower was destoryed if (currentTime.isAfter(openTime.plusMinutes(29)) && mine.isActive) {
boolean towerDestroyed = tower.getRank() < 1; //check to see if the tower was destoryed
if(towerDestroyed){ boolean towerDestroyed = tower.getRank() < 1;
//check if a valid claimer exists to close the window and claim the mine since the tower was destroyed if (towerDestroyed) {
if(mine.lastClaimer != null) { //check if a valid claimer exists to close the window and claim the mine since the tower was destroyed
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 {
ChatManager.chatSystemChannel("The " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE is still unclaimed. The battle continues.");
}
} else {
//tower was not destroyed, mine window closes
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(tower.getGuild().getNation().getName() + " has successfully defended the " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE, and retains their claim.");
}else{
ChatManager.chatSystemChannel("The " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE is still unclaimed. The battle continues.");
} }
}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