Update trace hunt season based on time

This commit is contained in:
Melledy committed 2026-10-19 01:03:38 -07:00
1 parent 465ccd769e
commit 2424496472
5 files changed
+93

No files matched your search

@@ -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;
}
}
@@ -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();
}
@@ -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();
@@ -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();
}
@@ -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;
}
}