From 910754021242229c46b4440ba369240390c9dd36 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 7 Mar 2024 20:04:58 -0600 Subject: [PATCH] 30 minute mine windows --- src/engine/objects/Mine.java | 31 ++++++++++++------ src/engine/server/world/WorldServer.java | 4 +-- src/engine/workthreads/HourlyJobThread.java | 35 +++++++++++++++------ 3 files changed, 49 insertions(+), 21 deletions(-) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 1a93fa2a..df2ea260 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -60,7 +60,7 @@ public class Mine extends AbstractGameObject { public boolean hasProduced = false; public int liveTime; - public Boolean fullHour = true; + public Boolean firstThirty = true; public static ArrayList ChinaMines = new ArrayList<>(); public static ArrayList EuroMines = new ArrayList<>(); @@ -123,17 +123,9 @@ public class Mine extends AbstractGameObject { public static void SetTimes(){ EuroMines.get(0).liveTime = 12; - EuroMines.get(0).fullHour = true; - EuroMines.get(1).liveTime = 12; - EuroMines.get(1).fullHour = false; - EuroMines.get(2).liveTime = 12; - EuroMines.get(2).fullHour = false; - EuroMines.get(3).liveTime = 12; - EuroMines.get(3).fullHour = true; - EuroMines.get(4).liveTime = 13; EuroMines.get(5).liveTime = 13; EuroMines.get(6).liveTime = 13; @@ -256,6 +248,27 @@ public class Mine extends AbstractGameObject { ChinaMines.add(serverMines.get(33)); AmericaMines.add(serverMines.get(34)); SetTimes(); + for(Mine mine : EuroMines){ + if(EuroMines.indexOf(mine) %2 == 0 ){ + mine.firstThirty = true; + } else{ + mine.firstThirty = false; + } + } + for(Mine mine : AmericaMines){ + if(AmericaMines.indexOf(mine) %2 == 0 ){ + mine.firstThirty = true; + } else{ + mine.firstThirty = false; + } + } + for(Mine mine : ChinaMines){ + if(ChinaMines.indexOf(mine) %2 == 0 ){ + mine.firstThirty = true; + } else{ + mine.firstThirty = false; + } + } } catch (Exception e) { e.printStackTrace(); } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 8e07c464..3342bd22 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -231,9 +231,9 @@ public class WorldServer { hourlyJobThread.setName("hourlyJob"); hourlyJobThread.start(); if(LocalDateTime.now().isAfter(LocalDateTime.now().withMinute(30).withSecond(0))) { - nextHourlyJobTime = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(1); + nextHourlyJobTime = LocalDateTime.now().withMinute(0).withSecond(1).plusHours(1); }else{ - nextHourlyJobTime = LocalDateTime.now().withMinute(30).withSecond(0); + nextHourlyJobTime = LocalDateTime.now().withMinute(30).withSecond(1); } } diff --git a/src/engine/workthreads/HourlyJobThread.java b/src/engine/workthreads/HourlyJobThread.java index 50f14331..5f725842 100644 --- a/src/engine/workthreads/HourlyJobThread.java +++ b/src/engine/workthreads/HourlyJobThread.java @@ -21,6 +21,7 @@ import engine.objects.*; import engine.server.world.WorldServer; import org.pmw.tinylog.Logger; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; @@ -93,18 +94,32 @@ public class HourlyJobThread implements Runnable { continue; } + if (mine.liveTime == LocalDateTime.now().getHour() && mine.wasClaimed == false) { + if(mine.firstThirty == true && LocalDateTime.now().isAfter(LocalDateTime.now().withHour(mine.liveTime).withMinute(0).withSecond(0)) && LocalDateTime.now().isBefore(LocalDateTime.now().withHour(mine.liveTime).withMinute(30).withSecond(0))){ + mineWindowOpen(mine); + continue; + } + if(mine.firstThirty == false && LocalDateTime.now().isAfter(LocalDateTime.now().withHour(mine.liveTime).withMinute(30).withSecond(0)) && LocalDateTime.now().isBefore(LocalDateTime.now().withHour(mine.liveTime).withMinute(0).withSecond(0).plusHours(1))){ + mineWindowOpen(mine); + continue; + } + + } + + + // Open Mines owned by nations having their WOO // set to the current mine window. - if (mine.liveTime == LocalDateTime.now().getHour() && mine.wasClaimed == false) { - if (mine.fullHour == true) { - HourlyJobThread.mineWindowOpen(mine); - continue; - } - else if(LocalDateTime.now().isBefore(LocalDateTime.now().withMinute(29).withSecond(59))) { - mineWindowOpen(mine); - continue; - } - } + //if (mine.liveTime == LocalDateTime.now().getHour() && mine.wasClaimed == false) { + /// if (mine.fullHour == true) { + // HourlyJobThread.mineWindowOpen(mine); + // continue; + // } + // else if(LocalDateTime.now().isBefore(LocalDateTime.now().withMinute(29).withSecond(59))) { + // mineWindowOpen(mine); + // continue; + // } + //} // Close the mine if it reaches this far mineWindowClose(mine);