mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-13 04:45:02 +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.scoreboss.ScoreBossModule;
|
||||||
import emu.nebula.game.tutorial.TutorialModule;
|
import emu.nebula.game.tutorial.TutorialModule;
|
||||||
import emu.nebula.net.GameSession;
|
import emu.nebula.net.GameSession;
|
||||||
|
import emu.nebula.util.Utils;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
|
|
||||||
@@ -34,6 +34,7 @@ public class GameContext implements Runnable {
|
|||||||
|
|
||||||
// Daily
|
// Daily
|
||||||
private long epochDays;
|
private long epochDays;
|
||||||
|
private int epochWeeks;
|
||||||
|
|
||||||
public GameContext() {
|
public GameContext() {
|
||||||
this.sessions = new Object2ObjectOpenHashMap<>();
|
this.sessions = new Object2ObjectOpenHashMap<>();
|
||||||
@@ -103,6 +104,7 @@ public class GameContext implements Runnable {
|
|||||||
|
|
||||||
long lastEpochDays = this.epochDays;
|
long lastEpochDays = this.epochDays;
|
||||||
this.epochDays = date.toEpochDay();
|
this.epochDays = date.toEpochDay();
|
||||||
|
this.epochWeeks = Utils.getWeeks(this.epochDays);
|
||||||
|
|
||||||
// Check if the day was changed
|
// Check if the day was changed
|
||||||
if (this.epochDays > lastEpochDays) {
|
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.Story;
|
||||||
import emu.nebula.proto.Public.WorldClass;
|
import emu.nebula.proto.Public.WorldClass;
|
||||||
import emu.nebula.proto.Public.WorldClassRewardState;
|
import emu.nebula.proto.Public.WorldClassRewardState;
|
||||||
|
import emu.nebula.util.Utils;
|
||||||
import emu.nebula.proto.Public.Title;
|
import emu.nebula.proto.Public.Title;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -592,8 +593,13 @@ public class Player implements GameDatabaseObject {
|
|||||||
return;
|
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
|
// Reset dailies
|
||||||
this.resetDailies(false);
|
this.resetDailies(hasWeekChanged);
|
||||||
|
|
||||||
// Update last epoch day
|
// Update last epoch day
|
||||||
this.lastEpochDay = Nebula.getGameContext().getEpochDays();
|
this.lastEpochDay = Nebula.getGameContext().getEpochDays();
|
||||||
|
|||||||
@@ -262,4 +262,13 @@ public class Utils {
|
|||||||
return false;
|
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