Skip to content

Commit 23ebad7

Browse files
dhilstclaude
andcommitted
Fix: defeating the demon never granted the ring
curFloor() returns the *generated* floor object, which only carried {index, rooms, byId, entryId, exitId} — not the config flags. So `floor.final` was undefined on defeat, and the ring (and ring/win screens) were never granted even after beating the Level -6 demon; keys still accrued because they key off room.isBoss + floor.index, which is why you could end up with 4 keys and no ring. Generation now carries the floor's tier/label/boss/final/surface metadata onto the generated object. Also name the final boss the demon (not a dragon) in the room title, description and Face button. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 20d10a1 commit 23ebad7

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

game/dungeon.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function generateFloor(floor, rng, manifest, letters) {
128128
r.type = "surface";
129129
r.isExitDown = true;
130130
r.isEntryUp = true; // "up" from the surface = the world / win exit
131-
return { index: floor.index, rooms: [r], byId: new Map([[0, r]]), entryId: 0, exitId: 0 };
131+
return meta(floor, { index: floor.index, rooms: [r], byId: new Map([[0, r]]), entryId: 0, exitId: 0 });
132132
}
133133

134134
const count = floor.final ? 5 : 12;
@@ -181,7 +181,19 @@ function generateFloor(floor, rng, manifest, letters) {
181181
if (exit.type !== "chest") exit.type = "monster";
182182
}
183183

184-
return { index: floor.index, rooms, byId, entryId, exitId };
184+
return meta(floor, { index: floor.index, rooms, byId, entryId, exitId });
185+
}
186+
187+
// Carry the floor's config metadata (tier, boss/final/surface flags, label)
188+
// onto the generated floor object, so the game can read floor.final etc. from
189+
// curFloor() without reaching back into the FLOORS table.
190+
function meta(floor, gen) {
191+
gen.tier = floor.tier ?? null;
192+
gen.label = floor.label;
193+
gen.boss = !!floor.boss;
194+
gen.final = !!floor.final;
195+
gen.surface = !!floor.surface;
196+
return gen;
185197
}
186198

187199
const LETTERS = [

game/main.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ function buildRoomPanel() {
311311

312312
// Encounter.
313313
if ((room.type === "monster") && !isCleared(room)) {
314-
const b = el("button", "btn btn-primary", room.isBoss ? "🐉 Face the dragon" : "🦁 Face the sphinx");
314+
const label = room.isBoss && floor.final ? "😈 Face the demon" : room.isBoss ? "🐉 Face the dragon" : "🦁 Face the sphinx";
315+
const b = el("button", "btn btn-primary", label);
315316
b.addEventListener("click", () => enterCombat(room));
316317
actions.appendChild(b);
317318
}
@@ -358,6 +359,7 @@ function buildRoomPanel() {
358359
function roomTitle(room) {
359360
if (room.type === "surface") return "The Mouth of the Dungeon";
360361
if (room.type === "chest") return "Treasure Room";
362+
if (room.isBoss && curFloor().final) return isCleared(room) ? "The Demon's Ashes" : "The Demon's Throne";
361363
if (room.isBoss) return isCleared(room) ? "The Dragon's Ashes" : "The Dragon's Lair";
362364
return isCleared(room) ? "A Silent Room" : "A Sphinx's Chamber";
363365
}
@@ -367,6 +369,11 @@ function roomDesc(room, floor) {
367369
if (room.type === "chest") {
368370
return run.openedChests.has(rk(floor.index, room.id)) ? "The chest lies open and empty." : "A heavy chest rests against the wall, its lid still shut.";
369371
}
372+
if (room.isBoss && floor.final) {
373+
return isCleared(room)
374+
? "Where the demon stood there is only quiet now, and the ring warm in your hand."
375+
: "The demon waits at the end of everything, the wedding ring glinting between its claws.";
376+
}
370377
if (room.isBoss) {
371378
return isCleared(room) ? "Only scorch marks and settling dust remain where the dragon coiled." : "A dragon guards the hatch, its breath heavy with every doubt you have ever swallowed.";
372379
}

0 commit comments

Comments
 (0)