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

21
src/engine/objects/Building.java

@ -780,24 +780,9 @@ public class Building extends AbstractWorldObject { @@ -780,24 +780,9 @@ public class Building extends AbstractWorldObject {
public int getMaintCost() {
int maintCost = 0;
// Add cost for building structure
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;
if(this.getBlueprint() != null && this.getBlueprint().getBuildingGroup().equals(BuildingGroup.TOL))
return 3000000;
else return 0;
}
public final void submitOpenDoorJob(int doorID) {

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

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

15
src/engine/workthreads/HalfHourlyJobThread.java

@ -162,20 +162,5 @@ public class HalfHourlyJobThread implements Runnable { @@ -162,20 +162,5 @@ public class HalfHourlyJobThread implements Runnable {
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; @@ -15,6 +15,8 @@ import engine.net.MessageDispatcher;
import engine.objects.*;
import engine.server.world.WorldServer;
import org.pmw.tinylog.Logger;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
@ -51,6 +53,21 @@ public class HourlyJobThread implements Runnable { @@ -51,6 +53,21 @@ public class HourlyJobThread implements Runnable {
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
Logger.info(WorldServer.getUptimeString());
Logger.info(SimulationManager.getPopulationString());

Loading…
Cancel
Save