From 2424496472d53c906bf61717e8a8160e4ef227b2 Mon Sep 17 00:00:00 2001 From: Melledy <121644117+Melledy@users.noreply.github.com> Date: Mon, 19 Oct 2026 01:03:38 -0700 Subject: [PATCH] Update trace hunt season based on time --- .../data/resources/TraceHuntControlDef.java | 13 +++++++ .../java/emu/nebula/game/GameContext.java | 6 ++++ .../java/emu/nebula/game/player/Player.java | 5 +++ .../game/tracehunt/TraceHuntManager.java | 33 +++++++++++++++++ .../game/tracehunt/TraceHuntModule.java | 36 +++++++++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 src/main/java/emu/nebula/game/tracehunt/TraceHuntModule.java diff --git a/src/main/java/emu/nebula/data/resources/TraceHuntControlDef.java b/src/main/java/emu/nebula/data/resources/TraceHuntControlDef.java index fec3d9d..dd09671 100644 --- a/src/main/java/emu/nebula/data/resources/TraceHuntControlDef.java +++ b/src/main/java/emu/nebula/data/resources/TraceHuntControlDef.java @@ -2,6 +2,7 @@ package emu.nebula.data.resources; import emu.nebula.data.BaseDef; import emu.nebula.data.ResourceType; +import emu.nebula.util.Utils; import lombok.Getter; @Getter @@ -10,8 +11,20 @@ public class TraceHuntControlDef extends BaseDef { private int Id; private int[] BossList; + private String StartTime; + private String EndTime; + + private transient long startDate; + private transient long endDate; + @Override public int getId() { return Id; } + + @Override + public void onLoad() { + this.startDate = Utils.dateToMilliseconds(this.StartTime) / 1000; + this.endDate = Utils.dateToMilliseconds(this.EndTime) / 1000; + } } diff --git a/src/main/java/emu/nebula/game/GameContext.java b/src/main/java/emu/nebula/game/GameContext.java index 17fcce9..932efa7 100644 --- a/src/main/java/emu/nebula/game/GameContext.java +++ b/src/main/java/emu/nebula/game/GameContext.java @@ -12,6 +12,7 @@ import emu.nebula.game.jointdrill.JointDrillModule; import emu.nebula.game.mall.PayModule; import emu.nebula.game.player.PlayerModule; import emu.nebula.game.scoreboss.ScoreBossModule; +import emu.nebula.game.tracehunt.TraceHuntModule; import emu.nebula.game.tutorial.TutorialModule; import emu.nebula.net.GameSession; import emu.nebula.util.ResetCycle; @@ -31,6 +32,7 @@ public class GameContext implements Runnable { private final TutorialModule tutorialModule; private final ActivityModule activityModule; private final ScoreBossModule scoreBossModule; + private final TraceHuntModule traceHuntModule; private final JointDrillModule jointDrillModule; private final BanModule banModule; private final PayModule payModule; @@ -53,6 +55,7 @@ public class GameContext implements Runnable { this.tutorialModule = new TutorialModule(this); this.activityModule = new ActivityModule(this); this.scoreBossModule = new ScoreBossModule(this); + this.traceHuntModule = new TraceHuntModule(this); this.jointDrillModule = new JointDrillModule(this); this.banModule = new BanModule(this); this.payModule = new PayModule(this); @@ -120,6 +123,9 @@ public class GameContext implements Runnable { // Update score boss season this.getScoreBossModule().updateSeason(); + // Update trace hunt control + this.getTraceHuntModule().updateControl(); + // Reset dailies for players this.resetDailies(); } diff --git a/src/main/java/emu/nebula/game/player/Player.java b/src/main/java/emu/nebula/game/player/Player.java index f834e0d..9cd4440 100644 --- a/src/main/java/emu/nebula/game/player/Player.java +++ b/src/main/java/emu/nebula/game/player/Player.java @@ -857,6 +857,11 @@ public class Player implements GameDatabaseObject { // See if we need to reset dailies this.checkResetDailies(); + // Try to update trace hunt control + if (this.getTraceHuntManager().updateControl()) { + this.getTraceHuntManager().save(); + } + // Fix any broken honor ids this.checkBrokenHonor(); diff --git a/src/main/java/emu/nebula/game/tracehunt/TraceHuntManager.java b/src/main/java/emu/nebula/game/tracehunt/TraceHuntManager.java index b91e7cb..836e210 100644 --- a/src/main/java/emu/nebula/game/tracehunt/TraceHuntManager.java +++ b/src/main/java/emu/nebula/game/tracehunt/TraceHuntManager.java @@ -89,6 +89,36 @@ public class TraceHuntManager extends PlayerManager implements GameDatabaseObjec return GameData.getTraceHuntControlDataTable().get(this.getControlId()); } + /** + * Tries to update the player's trace hunt control. + * Changing control resets all of the player's trace hunt progress. + */ + public boolean updateControl() { + // Get the current control id from the module + int controlId = Nebula.getGameContext().getTraceHuntModule().getControlId(); + + // Nothing to do if the control hasnt changed + if (this.controlId == controlId) { + return false; + } + + // Update to the new control + this.controlId = controlId; + + // Reset all progress from the previous control + this.getBosses().clear(); + this.resetBoss(); + + // Set the first boss of the new control + var control = this.getControlData(); + if (control != null && control.getBossList().length > 0) { + this.bossId = control.getBossList()[0]; + } + + // Success + return true; + } + public int getRandomMedals() { int medals = Utils.randomRange(125, 150); double rate = GameData.getTraceHuntLevelDataTable().get(this.getLevel()).getTokenRate() * 0.01D; @@ -143,6 +173,9 @@ public class TraceHuntManager extends PlayerManager implements GameDatabaseObjec this.dailyPermitProgress = 0; this.dailyPermits = 0; + // Tries to update control + this.updateControl(); + // Save to database this.save(); } diff --git a/src/main/java/emu/nebula/game/tracehunt/TraceHuntModule.java b/src/main/java/emu/nebula/game/tracehunt/TraceHuntModule.java new file mode 100644 index 0000000..51ae0e8 --- /dev/null +++ b/src/main/java/emu/nebula/game/tracehunt/TraceHuntModule.java @@ -0,0 +1,36 @@ +package emu.nebula.game.tracehunt; + +import emu.nebula.Nebula; +import emu.nebula.data.GameData; +import emu.nebula.game.GameContext; +import emu.nebula.game.GameContextModule; + +public class TraceHuntModule extends GameContextModule { + private int controlId; + + public TraceHuntModule(GameContext context) { + super(context); + this.updateControl(); + } + + public int getControlId() { + return this.controlId; + } + + public void updateControl() { + int control = 1; + long time = Nebula.getCurrentServerTime(); + + for (var data : GameData.getTraceHuntControlDataTable()) { + if (data.getId() <= control) { + continue; + } + + if (time >= data.getStartDate()) { + control = data.getId(); + } + } + + this.controlId = control; + } +}