Browse Source

system to open and close mines

lakebane-master
FatBoy-DOTC 7 months ago
parent
commit
47503de748
  1. 80
      src/engine/workthreads/MineThread.java

80
src/engine/workthreads/MineThread.java

@ -22,40 +22,84 @@ public class MineThread implements Runnable { @@ -22,40 +22,84 @@ public class MineThread implements Runnable {
}
@Override
public void run() {
LocalDateTime nextPulse = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0);
while (true){
if(LocalDateTime.now().isAfter(nextPulse)) {
//LocalDateTime nextPulse = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0);
while (true) {
for (Mine mine : Mine.getMines()) {
Building mineTower = BuildingManager.getBuilding(mine.getBuildingID());
if (mineTower == null)
if(mine.wasClaimed)
continue;
LocalDateTime now = LocalDateTime.now();
int minute = 0;
if (mine.firstThirty == false)
if (!mine.firstThirty)
minute = 30;
LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveTime).withMinute(minute).withSecond(0);
LocalDateTime closeTime = openTime.plusMinutes(29);
LocalDateTime closeTime = openTime.plusMinutes(30);
//current time is after start time and before close time, open mine window
if (LocalDateTime.now().isAfter(openTime.minusMinutes(1)) && !mine.wasClaimed && !mine.wasOpened) {
if (now.isAfter(openTime)) {
mineWindowOpen(mine);
continue;
continue; // mine has not opened today yet, and it is now after the time it should have, open the mine
}
if (mine.isActive) {
if (LocalDateTime.now().isAfter(closeTime) && mineTower.getRank() > 0)
mineWindowClose(mine); //mine was never knocked down, close window
if(now.isAfter(closeTime) && BuildingManager.getBuilding(mine.getBuildingID()).getRank() == 1) {
mineWindowClose(mine);
continue; // mine was never knocked down, close it
}
if (LocalDateTime.now().isAfter(closeTime) && mineTower.getRank() < 1 && mine.lastClaimer != null)
mineWindowClose(mine); //mine was knocked down and was claimed, close window
if(now.isAfter(closeTime) && mine.lastClaimer == null){
if(mine.firstThirty){
mine.firstThirty = false;
}else{
mine.firstThirty = true;
mine.liveTime += 1;
}
continue; // roll over to the next 30-minute window, mine was knocked down and not claimed
}
nextPulse = nextPulse.plusMinutes(30);
mineWindowClose(mine); // finished checking parameters, close the mine
}
}
// if(LocalDateTime.now().isAfter(nextPulse)) {
// for (Mine mine : Mine.getMines()) {
// Building mineTower = BuildingManager.getBuilding(mine.getBuildingID());
// if (mineTower == null)
// continue;
// int minute = 0;
// if (mine.firstThirty == false)
// minute = 30;
// LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveTime).withMinute(minute).withSecond(0);
// LocalDateTime closeTime = openTime.plusMinutes(29);
//current time is after start time and before close time, open mine window
// if (LocalDateTime.now().isAfter(openTime.minusMinutes(1)) && !mine.wasClaimed && !mine.wasOpened) {
// mineWindowOpen(mine);
// continue;
// }
// if (mine.isActive) {
//
// if (LocalDateTime.now().isAfter(closeTime) && mineTower.getRank() > 0)
// mineWindowClose(mine); //mine was never knocked down, close window
//
// if (LocalDateTime.now().isAfter(closeTime) && mineTower.getRank() < 1 && mine.lastClaimer != null)
// mineWindowClose(mine); //mine was knocked down and was claimed, close window
// }
// }
// nextPulse = nextPulse.plusMinutes(30);
// }
//}
}
public static void mineWindowOpen(Mine mine) {

Loading…
Cancel
Save