From f1e8384af0643192758b777d9e00d11feb95f6c3 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 21 May 2024 20:19:19 -0500 Subject: [PATCH] mines will start again --- src/engine/workthreads/MineThread.java | 41 +++++++++++--------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/engine/workthreads/MineThread.java b/src/engine/workthreads/MineThread.java index fc7197f0..266fa1d7 100644 --- a/src/engine/workthreads/MineThread.java +++ b/src/engine/workthreads/MineThread.java @@ -23,45 +23,38 @@ public class MineThread implements Runnable { @Override public void run() { LocalDateTime nextPulse = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0); - while (true) { - LocalDateTime now = LocalDateTime.now(); - - if (now.isAfter(nextPulse)) { + while (true){ + if(LocalDateTime.now().isAfter(nextPulse)) { for (Mine mine : Mine.getMines()) { - // Reset mine at 4:00 AM - if (nextPulse.getHour() == 4 && nextPulse.getMinute() == 0) { - mine.wasClaimed = false; - mine.hasProduced = false; - } Building mineTower = BuildingManager.getBuilding(mine.getBuildingID()); - if (mineTower == null) { + + if (mineTower == null) continue; - } - int minute = mine.firstThirty ? 0 : 30; - LocalDateTime openTime = now.withHour(mine.liveTime).withMinute(minute).withSecond(0).withNano(0); + int minute = 0; + if (mine.firstThirty == false) + minute = 30; + + LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveTime).withMinute(minute).withSecond(0); LocalDateTime closeTime = openTime.plusMinutes(29); - if (!mine.wasClaimed && !mine.wasOpened && now.isAfter(openTime.minusMinutes(1))) { + //current time is after start time and before close time, open mine window + if (LocalDateTime.now().isAfter(openTime.minusMinutes(1)) && !mine.wasClaimed && !mine.wasOpened) { mineWindowOpen(mine); continue; } + if (mine.isActive) { + + if (LocalDateTime.now().isAfter(closeTime) && mineTower.getRank() > 0) + mineWindowClose(mine); //mine was never knocked down, close window - if (mine.isActive && now.isAfter(closeTime)) { - if (mineTower.getRank() > 0 || (mineTower.getRank() < 1 && mine.lastClaimer != null)) { - mineWindowClose(mine); - } + if (LocalDateTime.now().isAfter(closeTime) && mineTower.getRank() < 1 && mine.lastClaimer != null) + mineWindowClose(mine); //mine was knocked down and was claimed, close window } } nextPulse = nextPulse.plusMinutes(30); } - - try { - Thread.sleep(1000); // Avoid busy-waiting - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } } }