Browse Source

Cleanup of NextMindWindow logic.

master
MagicBot 2 years ago
parent
commit
5929d5dd56
  1. 35
      src/engine/objects/Mine.java

35
src/engine/objects/Mine.java

@ -180,22 +180,22 @@ public class Mine extends AbstractGameObject {
private void setNextMineWindow() { private void setNextMineWindow() {
//default time, 9 pm est int nextMineHour = MBServerStatics.MINE_EARLY_WINDOW;;
int mineHour = 21; LocalDateTime nextOpenDate = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0);
if (this.owningGuild != null || this.owningGuild.isErrant() == false) // Use the new owners Mine WOO. If errant use Early window for this server.
mineHour = this.owningGuild.getNation().getMineTime();
int days = 1;
//midnight hours if (this.owningGuild != null || this.owningGuild.isErrant() == false)
if (this.openDate.getHour() != 0 && this.openDate.getHour() != 24 && (this.openDate.getDayOfMonth() == LocalDateTime.now().getDayOfMonth())) nextMineHour = this.owningGuild.getMineTime();
if (mineHour == 0 || mineHour == 24)
days = 2;
LocalDateTime newTime = this.openDate.plusDays(days).withHour(mineHour).withMinute(0).withSecond(0).withNano(0); if ((this.openDate.getHour() == 0 || this.openDate.getHour() == 24) &&
(this.owningGuild.getMineTime() != 0 && this.owningGuild.getMineTime() != 24))
nextOpenDate = nextOpenDate.withHour(nextMineHour);
else
nextOpenDate = nextOpenDate.withHour(nextMineHour).plusDays(1);
DbManager.MineQueries.CHANGE_MINE_TIME(this, newTime); DbManager.MineQueries.CHANGE_MINE_TIME(this, nextOpenDate);
this.openDate = newTime; this.openDate = nextOpenDate;
} }
public static void loadAllMines() { public static void loadAllMines() {
@ -577,15 +577,8 @@ try{
this.nationName = nation.getName(); this.nationName = nation.getName();
this.nationTag = nation.getGuildTag(); this.nationTag = nation.getGuildTag();
LocalDateTime guildDate = LocalDateTime.now().withHour(this.owningGuild.getMineTime()).withMinute(0).withSecond(0).withNano(0); setNextMineWindow();
setLastChange(System.currentTimeMillis());
if (this.openDate.getDayOfMonth() == LocalDateTime.now().getDayOfMonth())
if (this.owningGuild.getMineTime() == 0 || this.owningGuild.getMineTime() == 24)
guildDate = guildDate.plusDays(1);
guildDate = guildDate.withHour(this.owningGuild.getMineTime()).withMinute(0).withSecond(0).withNano(0);
this.openDate = guildDate;
Mine.setLastChange(System.currentTimeMillis());
if (mineBuilding.getRank() < 1){ if (mineBuilding.getRank() < 1){

Loading…
Cancel
Save