diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index ec3eff57..795655d0 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -15,11 +15,13 @@ import engine.gameManager.*; import engine.net.ByteBufferWriter; import engine.net.client.msg.ErrorPopupMsg; import engine.server.MBServerStatics; +import org.joda.time.DateTime; import org.pmw.tinylog.Logger; import java.net.UnknownHostException; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Time; import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -57,6 +59,12 @@ public class Mine extends AbstractGameObject { public Integer totalPlayers; public boolean hasProduced = false; + + public int liveTime; + + public static ArrayList ChinaMines = new ArrayList<>(); + public static ArrayList EuroMines = new ArrayList<>(); + public static ArrayList AmericaMines = new ArrayList<>(); /** * ResultSet Constructor */ @@ -110,9 +118,70 @@ public class Mine extends AbstractGameObject { Building mineTower = BuildingManager.getBuilding(this.buildingID); mineTower.setMaxHitPoints(5000 * this.capSize); mineTower.setCurrentHitPoints((float)5000 * this.capSize); + setLiveTime(this); //add a comment } + public static void setLiveTime(Mine mine){ + if(EuroMines.size() < 7){ + EuroMines.add(mine); + } else if(ChinaMines.size() < 14){ + ChinaMines.add(mine); + } else{ + AmericaMines.add(mine); + } + if(EuroMines.size() == 7){ + SetEuroTimes(); + } + if(ChinaMines.size() == 14){ + SetChinaTimes(); + } + if(AmericaMines.size() == 14){ + SetAmericaTimes(); + } + } + + public static void SetEuroTimes(){ + EuroMines.get(0).liveTime = 12; + EuroMines.get(1).liveTime = 13; + EuroMines.get(2).liveTime = 14; + EuroMines.get(3).liveTime = 14; + EuroMines.get(4).liveTime = 15; + EuroMines.get(5).liveTime = 15; + EuroMines.get(6).liveTime = 16; + } + public static void SetChinaTimes(){ + ChinaMines.get(0).liveTime = 4; + ChinaMines.get(0).liveTime = 5; + ChinaMines.get(0).liveTime = 6; + ChinaMines.get(0).liveTime = 6; + ChinaMines.get(0).liveTime = 7; + ChinaMines.get(0).liveTime = 7; + ChinaMines.get(0).liveTime = 8; + ChinaMines.get(0).liveTime = 8; + ChinaMines.get(0).liveTime = 9; + ChinaMines.get(0).liveTime = 9; + ChinaMines.get(0).liveTime = 10; + ChinaMines.get(0).liveTime = 10; + ChinaMines.get(0).liveTime = 11; + ChinaMines.get(0).liveTime = 12; + } + public static void SetAmericaTimes(){ + ChinaMines.get(0).liveTime = 14; + ChinaMines.get(0).liveTime = 15; + ChinaMines.get(0).liveTime = 16; + ChinaMines.get(0).liveTime = 16; + ChinaMines.get(0).liveTime = 17; + ChinaMines.get(0).liveTime = 17; + ChinaMines.get(0).liveTime = 18; + ChinaMines.get(0).liveTime = 18; + ChinaMines.get(0).liveTime = 19; + ChinaMines.get(0).liveTime = 19; + ChinaMines.get(0).liveTime = 20; + ChinaMines.get(0).liveTime = 20; + ChinaMines.get(0).liveTime = 21; + ChinaMines.get(0).liveTime = 22; + } public static void releaseMineClaims(PlayerCharacter playerCharacter) { if (playerCharacter == null) @@ -206,7 +275,7 @@ public class Mine extends AbstractGameObject { if (mineNatonGuild.isEmptyGuild() == false && mine.isActive == false) { - int guildWOO = mineNatonGuild.getNation().getMineTime(); + int guildWOO = mine.liveTime;//mineNatonGuild.getNation().getMineTime(); LocalDateTime guildMineTime = mineOpenTime.withHour(guildWOO); if (mineOpenTime.isAfter(guildMineTime) || mine.wasClaimed == true) diff --git a/src/engine/workthreads/HourlyJobThread.java b/src/engine/workthreads/HourlyJobThread.java index 4dc8866b..3cce9e16 100644 --- a/src/engine/workthreads/HourlyJobThread.java +++ b/src/engine/workthreads/HourlyJobThread.java @@ -80,8 +80,9 @@ public class HourlyJobThread implements Runnable { ArrayList mines = Mine.getMines(); for (Mine mine : mines) { - if (LocalDateTime.now().getHour() == 1400) { + if (LocalDateTime.now().getHour() == 1) { mine.wasClaimed = false; + mine.hasProduced = false; } try { @@ -95,7 +96,7 @@ public class HourlyJobThread implements Runnable { // Open Mines owned by nations having their WOO // set to the current mine window. - if (mine.getOwningGuild().getNation().getMineTime() == + if (mine.liveTime == LocalDateTime.now().getHour() && mine.wasClaimed == false) { HourlyJobThread.mineWindowOpen(mine); continue;