Browse Source

maintenance to run on specific day of week only

master
FatBoy-DOTC 2 years ago
parent
commit
ecaf56f647
  1. 14
      src/engine/gameManager/MaintenanceManager.java

14
src/engine/gameManager/MaintenanceManager.java

@ -13,9 +13,12 @@ package engine.gameManager;
import engine.Enum; import engine.Enum;
import engine.objects.*; import engine.objects.*;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.time.DayOfWeek;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList; import java.util.ArrayList;
public enum MaintenanceManager { public enum MaintenanceManager {
@ -50,12 +53,12 @@ public enum MaintenanceManager {
if (chargeUpkeep(building) == false) if (chargeUpkeep(building) == false)
derankList.add(building); derankList.add(building);
} }
// Reset maintenance dates for these buildings // Reset maintenance dates for these buildings
for (Building building : maintList) for (Building building : maintList) {
setMaintDateTime(building, building.maintDateTime.plusDays(7)); setMaintDateTime(building, LocalDateTime.now().plusDays(7));
}
// Derak or destroy buildings that did not // Derak or destroy buildings that did not
// have funds available. // have funds available.
@ -120,6 +123,11 @@ public enum MaintenanceManager {
if (building.maintDateTime.isAfter(LocalDateTime.now())) if (building.maintDateTime.isAfter(LocalDateTime.now()))
continue; continue;
//no maintenance if day of week doesnt match
if(LocalDateTime.now().getDayOfWeek().ordinal() != building.maintDateTime.getDayOfWeek().ordinal()){
continue;
}
// Add building to maintenance queue // Add building to maintenance queue
maintList.add(building); maintList.add(building);

Loading…
Cancel
Save