mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-12 20:34:36 +01:00
Implement weekly resets for battlepass quests
This commit is contained in:
@@ -13,7 +13,7 @@ import emu.nebula.game.player.PlayerModule;
|
||||
import emu.nebula.game.scoreboss.ScoreBossModule;
|
||||
import emu.nebula.game.tutorial.TutorialModule;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
import emu.nebula.util.Utils;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
|
||||
@@ -34,6 +34,7 @@ public class GameContext implements Runnable {
|
||||
|
||||
// Daily
|
||||
private long epochDays;
|
||||
private int epochWeeks;
|
||||
|
||||
public GameContext() {
|
||||
this.sessions = new Object2ObjectOpenHashMap<>();
|
||||
@@ -103,6 +104,7 @@ public class GameContext implements Runnable {
|
||||
|
||||
long lastEpochDays = this.epochDays;
|
||||
this.epochDays = date.toEpochDay();
|
||||
this.epochWeeks = Utils.getWeeks(this.epochDays);
|
||||
|
||||
// Check if the day was changed
|
||||
if (this.epochDays > lastEpochDays) {
|
||||
|
||||
@@ -44,6 +44,7 @@ import emu.nebula.proto.Public.QuestType;
|
||||
import emu.nebula.proto.Public.Story;
|
||||
import emu.nebula.proto.Public.WorldClass;
|
||||
import emu.nebula.proto.Public.WorldClassRewardState;
|
||||
import emu.nebula.util.Utils;
|
||||
import emu.nebula.proto.Public.Title;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -592,8 +593,13 @@ public class Player implements GameDatabaseObject {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if week has changed (Resets on monday)
|
||||
// TODO add a config option
|
||||
int curWeek = Utils.getWeeks(this.getLastEpochDay());
|
||||
boolean hasWeekChanged = Nebula.getGameContext().getEpochWeeks() > curWeek;
|
||||
|
||||
// Reset dailies
|
||||
this.resetDailies(false);
|
||||
this.resetDailies(hasWeekChanged);
|
||||
|
||||
// Update last epoch day
|
||||
this.lastEpochDay = Nebula.getGameContext().getEpochDays();
|
||||
|
||||
@@ -262,4 +262,13 @@ public class Utils {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get amount weeks since this epoch day. Each week starts on monday.
|
||||
* @param epochDays
|
||||
* @return
|
||||
*/
|
||||
public static int getWeeks(long epochDays) {
|
||||
return (int) Math.floor((epochDays + 3) / 7D);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user