Browse Source

new mines system

lakebane-master
FatBoy-DOTC 7 months ago
parent
commit
270301c35b
  1. 35
      src/engine/workthreads/MineThread.java

35
src/engine/workthreads/MineThread.java

@ -13,10 +13,7 @@ import engine.objects.Guild;
import engine.objects.Mine; import engine.objects.Mine;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class MineThread implements Runnable { public class MineThread implements Runnable {
public MineThread(){ public MineThread(){
@ -113,41 +110,19 @@ public class MineThread implements Runnable {
Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID()); Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID());
if(tower == null) if(tower == null)
continue; continue;
LocalDateTime liveTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).minusMinutes(1); LocalDateTime liveTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).minusMinutes(1).plusHours(5);
ZonedDateTime localizedTime = convertCSTToLocalTime(liveTime);
if(!mine.isActive && !mine.wasOpened) { if(!mine.isActive && !mine.wasOpened) {
if (ZonedDateTime.now().isAfter(localizedTime)) { if (LocalDateTime.now().isAfter(liveTime)) {
mineWindowOpen(mine); mineWindowOpen(mine);
// mine has not opened today yet, and it is now after the time it should have, open the mine // mine has not opened today yet, and it is now after the time it should have, open the mine
} }
}else{ }
//mine is active right now //mine is active right now
if (ZonedDateTime.now().isBefore(localizedTime.plusMinutes(30))){ if (LocalDateTime.now().isBefore(liveTime.plusMinutes(30)))
continue; // window is not over yet continue; // window is not over yet
}
if(tower.getRank() == 1){ if(tower.getRank() == 1 || mine.lastClaimer != null)
//mine was not knocked down, close the window
mineWindowClose(mine); mineWindowClose(mine);
}else{
if(mine.lastClaimer != null)
mineWindowClose(mine); //has a claimer, close the window
}
}
} }
} }
public static ZonedDateTime convertCSTToLocalTime(LocalDateTime cstDateTime) {
// Define the CST time zone (Central Standard Time)
ZoneId cstZoneId = ZoneId.of("America/Chicago"); // CST is represented by America/Chicago
// Define the system's default time zone
ZoneId localZoneId = ZoneId.systemDefault();
// Create a ZonedDateTime object for CST
ZonedDateTime cstZonedDateTime = ZonedDateTime.of(cstDateTime, cstZoneId);
// Convert CST to the local time zone
ZonedDateTime localZonedDateTime = cstZonedDateTime.withZoneSameInstant(localZoneId);
return localZonedDateTime;
}
} }

Loading…
Cancel
Save