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;
|
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) {
|
public ArrayList<Guild> GET_GUILD_ALLIES(final int id) {
|
||||||
prepareCallable("SELECT g.* FROM `obj_guild` g, `dyn_guild_allianceenemylist` l "
|
prepareCallable("SELECT g.* FROM `obj_guild` g, `dyn_guild_allianceenemylist` l "
|
||||||
+ "WHERE l.isAlliance = 1 && l.OtherGuildID = g.UID && l.GuildID=?");
|
+ "WHERE l.isAlliance = 1 && l.OtherGuildID = g.UID && l.GuildID=?");
|
||||||
|
|||||||
@@ -81,10 +81,10 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler {
|
|||||||
if (newMineTime == 24)
|
if (newMineTime == 24)
|
||||||
newMineTime = 0;
|
newMineTime = 0;
|
||||||
|
|
||||||
// Enforce 15hr restriction between WOO edits
|
// Enforce time restriction between WOO edits
|
||||||
|
|
||||||
if (LocalDateTime.now().isBefore(mineGuild.lastWooEditTime.plusHours(14))) {
|
if (mineGuild.wooWasModified) {
|
||||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You must wait 15 hours between WOO changes.");
|
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You can only modify your WOO once per day.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,15 +110,7 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mineGuild.setMineTime(newMineTime);
|
mineGuild.setMineTime(newMineTime);
|
||||||
mineGuild.lastWooEditTime = LocalDateTime.now();
|
mineGuild.wooWasModified = true;
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatManager.chatGuildInfo(playerCharacter, "Mine time updated.");
|
ChatManager.chatGuildInfo(playerCharacter, "Mine time updated.");
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,6 @@
|
|||||||
// www.magicbane.com
|
// www.magicbane.com
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
@@ -43,7 +40,6 @@ import java.sql.SQLException;
|
|||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@@ -77,14 +73,14 @@ public class Guild extends AbstractWorldObject {
|
|||||||
private ArrayList<Guild> subGuildList;
|
private ArrayList<Guild> subGuildList;
|
||||||
private int nationUUID = 0;
|
private int nationUUID = 0;
|
||||||
private GuildState guildState = GuildState.Errant;
|
private GuildState guildState = GuildState.Errant;
|
||||||
private ConcurrentHashMap<Integer,Condemned> guildCondemned = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Integer, Condemned> guildCondemned = new ConcurrentHashMap<>();
|
||||||
private String hash;
|
private String hash;
|
||||||
private boolean ownerIsNPC;
|
private boolean ownerIsNPC;
|
||||||
|
|
||||||
private static Guild errantGuild;
|
private static Guild errantGuild;
|
||||||
private static Guild errantNation;
|
private static Guild errantNation;
|
||||||
|
|
||||||
public LocalDateTime lastWooEditTime;
|
public boolean wooWasModified;
|
||||||
public HashMap<Integer, GuildAlliances> guildAlliances = new HashMap<>();
|
public HashMap<Integer, GuildAlliances> guildAlliances = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -182,11 +178,7 @@ public class Guild extends AbstractWorldObject {
|
|||||||
this.teleportMax = rs.getInt("teleportMax");
|
this.teleportMax = rs.getInt("teleportMax");
|
||||||
|
|
||||||
this.mineTime = rs.getInt("mineTime");
|
this.mineTime = rs.getInt("mineTime");
|
||||||
|
this.wooWasModified = false;
|
||||||
Timestamp lastWooRequest = rs.getTimestamp("lastWooEditTime");
|
|
||||||
|
|
||||||
if (lastWooRequest != null)
|
|
||||||
this.lastWooEditTime = lastWooRequest.toLocalDateTime();
|
|
||||||
|
|
||||||
this.hash = rs.getString("hash");
|
this.hash = rs.getString("hash");
|
||||||
}
|
}
|
||||||
@@ -411,10 +403,9 @@ public class Guild extends AbstractWorldObject {
|
|||||||
|
|
||||||
public boolean isErrant() {
|
public boolean isErrant() {
|
||||||
return this.getObjectUUID() == Guild.errantGuild.getObjectUUID();
|
return this.getObjectUUID() == Guild.errantGuild.getObjectUUID();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean sameGuild(Guild a, Guild b) {
|
public static boolean sameGuild(Guild a, Guild b) {
|
||||||
if (a == null || b == null)
|
if (a == null || b == null)
|
||||||
return false;
|
return false;
|
||||||
@@ -937,8 +928,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
|
|
||||||
if (subGuild.getOwnedCity() == null) {
|
if (subGuild.getOwnedCity() == null) {
|
||||||
subGuild.nation = null;
|
subGuild.nation = null;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
subGuild.nation = subGuild;
|
subGuild.nation = subGuild;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1034,10 +1024,6 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch (allianceType) {
|
switch (allianceType) {
|
||||||
case RecommendedAlly:
|
case RecommendedAlly:
|
||||||
if (recommendList.size() == 10) {
|
if (recommendList.size() == 10) {
|
||||||
@@ -1068,7 +1054,6 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
this.recommendList.add(toGuild);
|
this.recommendList.add(toGuild);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case RecommendedEnemy:
|
case RecommendedEnemy:
|
||||||
@@ -1199,21 +1184,17 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean removeGuildFromAlliance(Guild toRemove) {
|
public synchronized boolean removeGuildFromAlliance(Guild toRemove) {
|
||||||
if (this.allyList.contains(toRemove)){
|
|
||||||
this.allyList.remove(toRemove);
|
this.allyList.remove(toRemove);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean removeGuildFromEnemy(Guild toRemove) {
|
public synchronized boolean removeGuildFromEnemy(Guild toRemove) {
|
||||||
if (this.enemyList.contains(toRemove)){
|
|
||||||
this.enemyList.remove(toRemove);
|
this.enemyList.remove(toRemove);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean removeGuildFromRecommended(Guild toRemove) {
|
public synchronized boolean removeGuildFromRecommended(Guild toRemove) {
|
||||||
if (this.recommendList.contains(toRemove)){
|
|
||||||
this.recommendList.remove(toRemove);
|
this.recommendList.remove(toRemove);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1227,7 +1208,6 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.guildAlliances.remove(toRemove.getObjectUUID());
|
this.guildAlliances.remove(toRemove.getObjectUUID());
|
||||||
|
|
||||||
this.removeGuildFromAlliance(toRemove);
|
this.removeGuildFromAlliance(toRemove);
|
||||||
@@ -1245,7 +1225,6 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
UpdateClientAlliancesMsg ucam = new UpdateClientAlliancesMsg(toUpdate);
|
UpdateClientAlliancesMsg ucam = new UpdateClientAlliancesMsg(toUpdate);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()) {
|
for (PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()) {
|
||||||
|
|
||||||
if (Guild.sameGuild(player.getGuild(), toUpdate)) {
|
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;
|
public static final int MAX_PLAYER_LOAD_SIZE = 1000;
|
||||||
|
|
||||||
// Mine related
|
// 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
|
public static final int MINE_LATE_WINDOW = 0; // Midnight
|
||||||
|
|
||||||
// Race
|
// Race
|
||||||
|
|||||||
@@ -22,9 +22,11 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import static engine.server.MBServerStatics.MINE_LATE_WINDOW;
|
||||||
|
|
||||||
public class HourlyJobThread implements Runnable {
|
public class HourlyJobThread implements Runnable {
|
||||||
|
|
||||||
private static int hotzoneCount = 0;
|
private static final int hotzoneCount = 0;
|
||||||
|
|
||||||
public HourlyJobThread() {
|
public HourlyJobThread() {
|
||||||
|
|
||||||
@@ -56,6 +58,8 @@ public class HourlyJobThread implements Runnable {
|
|||||||
|
|
||||||
processMineWindow();
|
processMineWindow();
|
||||||
|
|
||||||
|
// Deposit mine resources to Guilds
|
||||||
|
|
||||||
for (Mine mine : Mine.getMines()) {
|
for (Mine mine : Mine.getMines()) {
|
||||||
|
|
||||||
try {
|
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
|
// Update city population values
|
||||||
|
|
||||||
@@ -101,20 +132,9 @@ public class HourlyJobThread implements Runnable {
|
|||||||
ArrayList<Mine> mines = Mine.getMines();
|
ArrayList<Mine> mines = Mine.getMines();
|
||||||
|
|
||||||
for (Mine mine : mines) {
|
for (Mine mine : mines) {
|
||||||
|
|
||||||
try {
|
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
|
// Open Errant Mines
|
||||||
|
|
||||||
if (mine.getOwningGuild().isErrant()) {
|
if (mine.getOwningGuild().isErrant()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user