gistfile1.txt
· 1.2 KiB · Text
Eredeti
resetWeek(): void {
const now = new Date();
const newWeekKey = WRank.weekKey(now);
const prevWeekKey = WRank.weekKey(new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000));
// Access internal data via WRank
const prevWeek = WRank.weekFromKey(prevWeekKey);
const newWeek = WRank.currentWeek(); // ensures new week exists
if (prevWeek) {
const goal = Config.get({ section: "wrank", key: "goal" });
for (const nation of [Nation.Capella, Nation.Procyon]) {
const entries = prevWeek.entries[nation];
const rank1 = entries.find((e) => e.currentRank === 1);
// Rank 1 with >= goal TGs becomes Bringer — no exceptions
// Officers use Bringer.override() for manual adjustments
if (rank1 && rank1.tgCount >= goal) {
newWeek.bringer[nation] = rank1.characterName;
} else {
newWeek.bringer[nation] = null;
}
// Overrides do NOT carry forward — each week starts clean
delete (newWeek.bringer as any)[`${nation}Override`];
}
}
WRank.save();
console.log(`[TG] Week reset to ${newWeekKey}. Bringer:`, newWeek.bringer);
},
| 1 | resetWeek(): void { |
| 2 | const now = new Date(); |
| 3 | const newWeekKey = WRank.weekKey(now); |
| 4 | const prevWeekKey = WRank.weekKey(new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000)); |
| 5 | |
| 6 | // Access internal data via WRank |
| 7 | const prevWeek = WRank.weekFromKey(prevWeekKey); |
| 8 | const newWeek = WRank.currentWeek(); // ensures new week exists |
| 9 | |
| 10 | if (prevWeek) { |
| 11 | const goal = Config.get({ section: "wrank", key: "goal" }); |
| 12 | for (const nation of [Nation.Capella, Nation.Procyon]) { |
| 13 | const entries = prevWeek.entries[nation]; |
| 14 | const rank1 = entries.find((e) => e.currentRank === 1); |
| 15 | |
| 16 | // Rank 1 with >= goal TGs becomes Bringer — no exceptions |
| 17 | // Officers use Bringer.override() for manual adjustments |
| 18 | if (rank1 && rank1.tgCount >= goal) { |
| 19 | newWeek.bringer[nation] = rank1.characterName; |
| 20 | } else { |
| 21 | newWeek.bringer[nation] = null; |
| 22 | } |
| 23 | |
| 24 | // Overrides do NOT carry forward — each week starts clean |
| 25 | delete (newWeek.bringer as any)[`${nation}Override`]; |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | WRank.save(); |
| 30 | console.log(`[TG] Week reset to ${newWeekKey}. Bringer:`, newWeek.bringer); |
| 31 | }, |