From ecaf56f647c1ad04f0d502b091f1bbe3f006252f Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 18 Feb 2023 10:54:11 -0600 Subject: [PATCH] maintenance to run on specific day of week only --- src/engine/gameManager/MaintenanceManager.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/MaintenanceManager.java b/src/engine/gameManager/MaintenanceManager.java index cecc5035..f54a904b 100644 --- a/src/engine/gameManager/MaintenanceManager.java +++ b/src/engine/gameManager/MaintenanceManager.java @@ -13,9 +13,12 @@ package engine.gameManager; import engine.Enum; import engine.objects.*; +import org.joda.time.DateTime; import org.pmw.tinylog.Logger; +import java.time.DayOfWeek; import java.time.LocalDateTime; +import java.time.temporal.TemporalAdjusters; import java.util.ArrayList; public enum MaintenanceManager { @@ -50,12 +53,12 @@ public enum MaintenanceManager { if (chargeUpkeep(building) == false) derankList.add(building); } - // Reset maintenance dates for these buildings - for (Building building : maintList) - setMaintDateTime(building, building.maintDateTime.plusDays(7)); + for (Building building : maintList) { + setMaintDateTime(building, LocalDateTime.now().plusDays(7)); + } // Derak or destroy buildings that did not // have funds available. @@ -120,6 +123,11 @@ public enum MaintenanceManager { if (building.maintDateTime.isAfter(LocalDateTime.now())) continue; + + //no maintenance if day of week doesnt match + if(LocalDateTime.now().getDayOfWeek().ordinal() != building.maintDateTime.getDayOfWeek().ordinal()){ + continue; + } // Add building to maintenance queue maintList.add(building);