generated from nhcarrigan/template
fix: preserve runestone bounty flag for legacy defeated bosses (#67)
## Summary - Bosses defeated before `bountyRunestonesClaimed` was introduced had `status: "defeated"` but the field `undefined` - After prestige, the preservation check (`=== true`) missed these bosses, so the first-kill bounty was re-awarded on the next run - Now also treats `status === "defeated"` as proof the bounty was already earned, covering the migration case ## Test plan - [ ] Existing test: `preserves bountyRunestonesClaimed flag on bosses across prestige` — still passes - [ ] New test: `sets bountyRunestonesClaimed on bosses defeated before the flag was introduced` — covers the legacy save migration path - [ ] Full coverage maintained at 100% Closes #52 ✨ This PR was created with help from Hikari~ 🌸 Reviewed-on: #67 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
This commit was merged in pull request #67.
This commit is contained in:
@@ -215,7 +215,10 @@ const buildPostPrestigeState = (
|
|||||||
const currentBoss = currentState.bosses.find((candidate) => {
|
const currentBoss = currentState.bosses.find((candidate) => {
|
||||||
return candidate.id === freshBoss.id;
|
return candidate.id === freshBoss.id;
|
||||||
});
|
});
|
||||||
if (currentBoss?.bountyRunestonesClaimed === true) {
|
if (
|
||||||
|
currentBoss?.bountyRunestonesClaimed === true
|
||||||
|
|| currentBoss?.status === "defeated"
|
||||||
|
) {
|
||||||
return { ...freshBoss, bountyRunestonesClaimed: true };
|
return { ...freshBoss, bountyRunestonesClaimed: true };
|
||||||
}
|
}
|
||||||
return freshBoss;
|
return freshBoss;
|
||||||
|
|||||||
@@ -319,6 +319,32 @@ describe("buildPostPrestigeState", () => {
|
|||||||
expect(matchingBoss?.bountyRunestonesClaimed).toBe(true);
|
expect(matchingBoss?.bountyRunestonesClaimed).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("sets bountyRunestonesClaimed on bosses defeated before the flag was introduced", () => {
|
||||||
|
const legacyDefeatedBoss = {
|
||||||
|
bountyRunestones: 5,
|
||||||
|
crystalReward: 0,
|
||||||
|
currentHp: 0,
|
||||||
|
damagePerSecond: 10,
|
||||||
|
description: "A boss",
|
||||||
|
equipmentRewards: [] as string[],
|
||||||
|
essenceReward: 0,
|
||||||
|
goldReward: 100,
|
||||||
|
id: "troll_king",
|
||||||
|
maxHp: 100,
|
||||||
|
name: "Troll King",
|
||||||
|
prestigeRequirement: 0,
|
||||||
|
status: "defeated" as const,
|
||||||
|
upgradeRewards: [] as string[],
|
||||||
|
zoneId: "verdant_vale",
|
||||||
|
};
|
||||||
|
const state = makeMinimalState({ bosses: [ legacyDefeatedBoss ] as GameState["bosses"] });
|
||||||
|
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||||||
|
const matchingBoss = prestigeState.bosses.find((boss) => {
|
||||||
|
return boss.id === "troll_king";
|
||||||
|
});
|
||||||
|
expect(matchingBoss?.bountyRunestonesClaimed).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
it("accumulates completed quests into lifetime total", () => {
|
it("accumulates completed quests into lifetime total", () => {
|
||||||
const quest = {
|
const quest = {
|
||||||
id: "q_1",
|
id: "q_1",
|
||||||
|
|||||||
Reference in New Issue
Block a user