forked from MagicBane/Server
Refactor WOO change timer mechanics to use the same system as the mine claims. Moved both resets to the hourly job.
This commit is contained in:
@@ -115,13 +115,6 @@ public class dbGuildHandler extends dbHandlerBase {
|
||||
return outputStr;
|
||||
}
|
||||
|
||||
public boolean SET_LAST_WOO_UPDATE(Guild guild, LocalDateTime lastEditTime) {
|
||||
prepareCallable("UPDATE `obj_guild` SET `lastWooEditTime`=? WHERE `UID`=?");
|
||||
setLocalDateTime(1, lastEditTime);
|
||||
setLong(2, (long) guild.getObjectUUID());
|
||||
return (executeUpdate() > 0);
|
||||
}
|
||||
|
||||
public ArrayList<Guild> GET_GUILD_ALLIES(final int id) {
|
||||
prepareCallable("SELECT g.* FROM `obj_guild` g, `dyn_guild_allianceenemylist` l "
|
||||
+ "WHERE l.isAlliance = 1 && l.OtherGuildID = g.UID && l.GuildID=?");
|
||||
|
||||
@@ -81,10 +81,10 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler {
|
||||
if (newMineTime == 24)
|
||||
newMineTime = 0;
|
||||
|
||||
// Enforce 15hr restriction between WOO edits
|
||||
// Enforce time restriction between WOO edits
|
||||
|
||||
if (LocalDateTime.now().isBefore(mineGuild.lastWooEditTime.plusHours(14))) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You must wait 15 hours between WOO changes.");
|
||||
if (mineGuild.wooWasModified) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You can only modify your WOO once per day.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -110,15 +110,7 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler {
|
||||
}
|
||||
|
||||
mineGuild.setMineTime(newMineTime);
|
||||
mineGuild.lastWooEditTime = LocalDateTime.now();
|
||||
|
||||
// Update guild WOO timer for reboot persistence
|
||||
|
||||
if (!DbManager.GuildQueries.SET_LAST_WOO_UPDATE(mineGuild, mineGuild.lastWooEditTime)) {
|
||||
Logger.error("MineWindowChange", "Failed to update woo timer for guild " + mineGuild.getObjectUUID());
|
||||
ChatManager.chatGuildError(playerCharacter, "A Serious error has for to occurred.");
|
||||
return true;
|
||||
}
|
||||
mineGuild.wooWasModified = true;
|
||||
|
||||
ChatManager.chatGuildInfo(playerCharacter, "Mine time updated.");
|
||||
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
@@ -43,7 +40,6 @@ import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -77,14 +73,14 @@ public class Guild extends AbstractWorldObject {
|
||||
private ArrayList<Guild> subGuildList;
|
||||
private int nationUUID = 0;
|
||||
private GuildState guildState = GuildState.Errant;
|
||||
private ConcurrentHashMap<Integer,Condemned> guildCondemned = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<Integer, Condemned> guildCondemned = new ConcurrentHashMap<>();
|
||||
private String hash;
|
||||
private boolean ownerIsNPC;
|
||||
|
||||
private static Guild errantGuild;
|
||||
private static Guild errantNation;
|
||||
|
||||
public LocalDateTime lastWooEditTime;
|
||||
public boolean wooWasModified;
|
||||
public HashMap<Integer, GuildAlliances> guildAlliances = new HashMap<>();
|
||||
|
||||
/**
|
||||
@@ -182,11 +178,7 @@ public class Guild extends AbstractWorldObject {
|
||||
this.teleportMax = rs.getInt("teleportMax");
|
||||
|
||||
this.mineTime = rs.getInt("mineTime");
|
||||
|
||||
Timestamp lastWooRequest = rs.getTimestamp("lastWooEditTime");
|
||||
|
||||
if (lastWooRequest != null)
|
||||
this.lastWooEditTime = lastWooRequest.toLocalDateTime();
|
||||
this.wooWasModified = false;
|
||||
|
||||
this.hash = rs.getString("hash");
|
||||
}
|
||||
@@ -411,10 +403,9 @@ public class Guild extends AbstractWorldObject {
|
||||
|
||||
public boolean isErrant() {
|
||||
return this.getObjectUUID() == Guild.errantGuild.getObjectUUID();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean sameGuild(Guild a, Guild b) {
|
||||
if (a == null || b == null)
|
||||
return false;
|
||||
@@ -937,8 +928,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
||||
|
||||
if (subGuild.getOwnedCity() == null) {
|
||||
subGuild.nation = null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
subGuild.nation = subGuild;
|
||||
}
|
||||
|
||||
@@ -1034,10 +1024,6 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
switch (allianceType) {
|
||||
case RecommendedAlly:
|
||||
if (recommendList.size() == 10) {
|
||||
@@ -1068,7 +1054,6 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
||||
this.recommendList.add(toGuild);
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
case RecommendedEnemy:
|
||||
@@ -1199,21 +1184,17 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
||||
}
|
||||
|
||||
public synchronized boolean removeGuildFromAlliance(Guild toRemove) {
|
||||
if (this.allyList.contains(toRemove)){
|
||||
this.allyList.remove(toRemove);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean removeGuildFromEnemy(Guild toRemove) {
|
||||
if (this.enemyList.contains(toRemove)){
|
||||
this.enemyList.remove(toRemove);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean removeGuildFromRecommended(Guild toRemove) {
|
||||
if (this.recommendList.contains(toRemove)){
|
||||
this.recommendList.remove(toRemove);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1227,7 +1208,6 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
this.guildAlliances.remove(toRemove.getObjectUUID());
|
||||
|
||||
this.removeGuildFromAlliance(toRemove);
|
||||
@@ -1245,7 +1225,6 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
||||
UpdateClientAlliancesMsg ucam = new UpdateClientAlliancesMsg(toUpdate);
|
||||
|
||||
|
||||
|
||||
for (PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()) {
|
||||
|
||||
if (Guild.sameGuild(player.getGuild(), toUpdate)) {
|
||||
@@ -1295,5 +1274,4 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -793,7 +793,7 @@ public class MBServerStatics {
|
||||
public static final int MAX_PLAYER_LOAD_SIZE = 1000;
|
||||
|
||||
// Mine related
|
||||
public static final int MINE_EARLY_WINDOW = 16; // 3pm
|
||||
public static final int MINE_EARLY_WINDOW = 16; // 4pm
|
||||
public static final int MINE_LATE_WINDOW = 0; // Midnight
|
||||
|
||||
// Race
|
||||
|
||||
@@ -22,9 +22,11 @@ import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static engine.server.MBServerStatics.MINE_LATE_WINDOW;
|
||||
|
||||
public class HourlyJobThread implements Runnable {
|
||||
|
||||
private static int hotzoneCount = 0;
|
||||
private static final int hotzoneCount = 0;
|
||||
|
||||
public HourlyJobThread() {
|
||||
|
||||
@@ -56,6 +58,8 @@ public class HourlyJobThread implements Runnable {
|
||||
|
||||
processMineWindow();
|
||||
|
||||
// Deposit mine resources to Guilds
|
||||
|
||||
for (Mine mine : Mine.getMines()) {
|
||||
|
||||
try {
|
||||
@@ -65,6 +69,33 @@ public class HourlyJobThread implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
// Reset time-gated access to WOO slider.
|
||||
// *** Do this after the mines open/close!
|
||||
|
||||
if (LocalDateTime.now().getHour() == MINE_LATE_WINDOW) {
|
||||
Guild guild;
|
||||
|
||||
for (AbstractGameObject dbObject : DbManager.getList(Enum.GameObjectType.Guild)) {
|
||||
guild = (Guild) dbObject;
|
||||
|
||||
if (guild != null)
|
||||
guild.wooWasModified = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Mines can only be claimed once per cycle.
|
||||
// This will reset at 1am after the last mine
|
||||
// window closes.
|
||||
|
||||
if (LocalDateTime.now().getHour() == MINE_LATE_WINDOW + 1) {
|
||||
|
||||
for (Mine mine : Mine.getMines()) {
|
||||
|
||||
if (mine.wasClaimed == true)
|
||||
mine.wasClaimed = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Update city population values
|
||||
|
||||
@@ -101,20 +132,9 @@ public class HourlyJobThread implements Runnable {
|
||||
ArrayList<Mine> mines = Mine.getMines();
|
||||
|
||||
for (Mine mine : mines) {
|
||||
|
||||
try {
|
||||
|
||||
// Mines can only be claimed once a cycle.
|
||||
// The cycle resets at 01:00hrs after the
|
||||
// Last mine window closes.
|
||||
|
||||
if (mine.wasClaimed == true) {
|
||||
|
||||
if (LocalDateTime.now().getHour() == 01)
|
||||
mine.wasClaimed = false;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Open Errant Mines
|
||||
|
||||
if (mine.getOwningGuild().isErrant()) {
|
||||
|
||||
Reference in New Issue
Block a user