Feature: implement game shell UI with room navigation and combat mechanics

This commit is contained in:
Keith Solomon
2026-03-15 14:02:19 -05:00
parent d504008030
commit fb6cbfe9fb
4 changed files with 804 additions and 117 deletions

View File

@@ -6,9 +6,11 @@ import { createStartingAdventurer } from "./character";
import {
createRunState,
enterCurrentRoom,
getAvailableMoves,
resolveRunEnemyTurn,
resolveRunPlayerTurn,
startCombatInCurrentRoom,
travelCurrentExit,
} from "./runState";
function createSequenceRoller(values: number[]) {
@@ -183,4 +185,46 @@ describe("run state flow", () => {
false,
);
});
it("lists available traversable exits for the current room", () => {
const run = createRunState({
content: sampleContentPack,
campaignId: "campaign.1",
adventurer: createAdventurer(),
});
expect(getAvailableMoves(run)).toEqual([
expect.objectContaining({
direction: "north",
generated: false,
}),
]);
});
it("travels through an unresolved exit, generates a room, and enters it", () => {
const run = createRunState({
content: sampleContentPack,
campaignId: "campaign.1",
adventurer: createAdventurer(),
at: "2026-03-15T14:00:00.000Z",
});
const result = travelCurrentExit({
content: sampleContentPack,
run,
exitDirection: "north",
roller: createSequenceRoller([1, 1]),
at: "2026-03-15T14:05:00.000Z",
});
expect(result.run.currentRoomId).toBe("room.level1.room.002");
expect(result.run.dungeon.levels["1"]!.discoveredRoomOrder).toEqual([
"room.level1.start",
"room.level1.room.002",
]);
expect(result.run.dungeon.levels["1"]!.rooms["room.level1.room.002"]!.discovery.entered).toBe(
true,
);
expect(result.run.log[0]?.text).toContain("Travelled north");
});
});