yet another attempt at mines

This commit is contained in:
2024-05-26 20:01:06 -05:00
parent a2da8f3861
commit 917fddceeb
2 changed files with 57 additions and 14 deletions
+9 -4
View File
@@ -22,7 +22,7 @@ public class MineThread implements Runnable {
}
@Override
public void run() {
nextPulse = LocalDateTime.now().withMinute(0);
nextPulse = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0);
while (true) {
if(LocalDateTime.now().isAfter(nextPulse)) {
processMineWindows();
@@ -33,7 +33,6 @@ public class MineThread implements Runnable {
public static void mineWindowOpen(Mine mine) {
mine.setActive(true);
ChatManager.chatSystemChannel(mine.getParentZone().getName() + "'s Mine is now Active!");
Logger.info(mine.getParentZone().getName() + "'s Mine is now Active!");
}
@@ -119,20 +118,26 @@ public class MineThread implements Runnable {
LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).withSecond(0).withNano(0);
if(currentTime.isAfter(openTime) && !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))) {
if(currentTime.isAfter(openTime.plusMinutes(29)) && mine.isActive) {
//check to see if the tower was destoryed
boolean towerDestroyed = tower.getRank() < 1;
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{
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.");
}
}