Browse Source

mines produce once a day, maintenance system for TOL only

lakebane-new
FatBoy-DOTC 5 months ago
parent
commit
c0d1a4f274
  1. 20
      src/engine/gameManager/MaintenanceManager.java
  2. 21
      src/engine/objects/Building.java
  3. 4
      src/engine/server/world/WorldServer.java
  4. 15
      src/engine/workthreads/HalfHourlyJobThread.java
  5. 17
      src/engine/workthreads/HourlyJobThread.java

20
src/engine/gameManager/MaintenanceManager.java

@ -49,19 +49,15 @@ public enum MaintenanceManager {
if (chargeUpkeep(building) == false) if (chargeUpkeep(building) == false)
derankList.add(building); derankList.add(building);
else
setMaintDateTime(building, LocalDateTime.now().plusDays(7));
} }
// Reset maintenance dates for these buildings
for (Building building : maintList) { for (Building building : derankList) {
setMaintDateTime(building, LocalDateTime.now().plusDays(7));
}
// Derak or destroy buildings that did not
// have funds available.
for (Building building : derankList)
building.destroyOrDerank(null); building.destroyOrDerank(null);
if(building.getRank() > 0)
setMaintDateTime(building, LocalDateTime.now().plusDays(1));
}
Logger.info("Structures: " + buildingList.size() + " Maint: " + maintList.size() + " Derank: " + derankList.size()); Logger.info("Structures: " + buildingList.size() + " Maint: " + maintList.size() + " Derank: " + derankList.size());
} }
@ -98,6 +94,10 @@ public enum MaintenanceManager {
continue; continue;
} }
//only ToL pays maintenance
if(building.getBlueprint().getBuildingGroup() != null && !building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL))
continue;
// No maintenance on banestones omfg // No maintenance on banestones omfg
if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.BANESTONE)) if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.BANESTONE))

21
src/engine/objects/Building.java

@ -780,24 +780,9 @@ public class Building extends AbstractWorldObject {
public int getMaintCost() { public int getMaintCost() {
int maintCost = 0; if(this.getBlueprint() != null && this.getBlueprint().getBuildingGroup().equals(BuildingGroup.TOL))
return 3000000;
// Add cost for building structure else return 0;
maintCost += this.getBlueprint().getMaintCost(rank);
// Add costs associated with hirelings
for (AbstractCharacter npc : this.hirelings.keySet()) {
if (npc.getObjectType() != GameObjectType.NPC)
continue;
maintCost += Blueprint.getNpcMaintCost(npc.getRank());
}
return maintCost;
} }
public final void submitOpenDoorJob(int doorID) { public final void submitOpenDoorJob(int doorID) {

4
src/engine/server/world/WorldServer.java

@ -490,8 +490,8 @@ public class WorldServer {
MobRespawnThread.startRespawnThread(); MobRespawnThread.startRespawnThread();
// Run maintenance // Run maintenance
//moved this to hourly job thread to sustain no reboot system
MaintenanceManager.dailyMaintenance(); //MaintenanceManager.dailyMaintenance();
Logger.info("Starting Orphan Item Purge"); Logger.info("Starting Orphan Item Purge");
PurgeOprhans.startPurgeThread(); PurgeOprhans.startPurgeThread();

15
src/engine/workthreads/HalfHourlyJobThread.java

@ -162,20 +162,5 @@ public class HalfHourlyJobThread implements Runnable {
processMineWindow(); processMineWindow();
// Mines can only be claimed once per cycle.
// This will reset at 1am after the last mine
// window closes.
if (LocalDateTime.now().getHour() == 1) {
for (Mine mine : Mine.getMines()) {
try {
mine.depositMineResources();
} catch (Exception e) {
Logger.info(e.getMessage() + " for Mine " + mine.getObjectUUID());
}
mine.wasClaimed = false;
}
}
} }
} }

17
src/engine/workthreads/HourlyJobThread.java

@ -15,6 +15,8 @@ import engine.net.MessageDispatcher;
import engine.objects.*; import engine.objects.*;
import engine.server.world.WorldServer; import engine.server.world.WorldServer;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -51,6 +53,21 @@ public class HourlyJobThread implements Runnable {
Logger.error("missing city map"); Logger.error("missing city map");
} }
//run maintenance every day at 1 am
if(LocalDateTime.now().getHour() == 1) {
MaintenanceManager.dailyMaintenance();
//produce mine resources once a day
for (Mine mine : Mine.getMines()) {
try {
mine.depositMineResources();
} catch (Exception e) {
Logger.info(e.getMessage() + " for Mine " + mine.getObjectUUID());
}
mine.wasClaimed = false;
}
}
// Log metrics to console // Log metrics to console
Logger.info(WorldServer.getUptimeString()); Logger.info(WorldServer.getUptimeString());
Logger.info(SimulationManager.getPopulationString()); Logger.info(SimulationManager.getPopulationString());

Loading…
Cancel
Save