Compare commits
1 Commits
feature/en
...
5debb5bd5e
| Author | SHA1 | Date | |
|---|---|---|---|
| 5debb5bd5e |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,4 +3,3 @@ dist/
|
|||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
vite.config.js
|
vite.config.js
|
||||||
vite.config.d.ts
|
vite.config.d.ts
|
||||||
Notes/rendered-pages/
|
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
|
||||||
|
|
||||||
import { lookupTable } from "@/rules/tables";
|
|
||||||
|
|
||||||
import { findRoomTemplateForLookup, findTableByCode } from "./contentHelpers";
|
|
||||||
import { sampleContentPack } from "./sampleContentPack";
|
|
||||||
|
|
||||||
function createSequenceRoller(values: number[]) {
|
|
||||||
let index = 0;
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
const next = values[index];
|
|
||||||
index += 1;
|
|
||||||
return next;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("level 1 content helpers", () => {
|
|
||||||
it("finds encoded level 1 encounter tables by code", () => {
|
|
||||||
const table = findTableByCode(sampleContentPack, "L1A");
|
|
||||||
|
|
||||||
expect(table.name).toBe("Level 1 Animals");
|
|
||||||
expect(table.entries).toHaveLength(6);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("resolves a small room template from a table lookup", () => {
|
|
||||||
const lookup = lookupTable(findTableByCode(sampleContentPack, "L1SR"), {
|
|
||||||
roller: createSequenceRoller([3, 4]),
|
|
||||||
});
|
|
||||||
|
|
||||||
const roomTemplate = findRoomTemplateForLookup(sampleContentPack, lookup);
|
|
||||||
|
|
||||||
expect(lookup.roll.total).toBe(7);
|
|
||||||
expect(roomTemplate.title).toBe("Murtayne Effigy");
|
|
||||||
expect(roomTemplate.roomClass).toBe("small");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("resolves a large room template from a table lookup", () => {
|
|
||||||
const lookup = lookupTable(findTableByCode(sampleContentPack, "L1LR"), {
|
|
||||||
roller: createSequenceRoller([5, 5]),
|
|
||||||
});
|
|
||||||
|
|
||||||
const roomTemplate = findRoomTemplateForLookup(sampleContentPack, lookup);
|
|
||||||
|
|
||||||
expect(lookup.roll.total).toBe(10);
|
|
||||||
expect(roomTemplate.title).toBe("Slate Shrine");
|
|
||||||
expect(roomTemplate.roomClass).toBe("large");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
import type { ContentPack, RoomTemplate, TableDefinition } from "@/types/content";
|
|
||||||
import type { TableLookupResult } from "@/rules/tables";
|
|
||||||
|
|
||||||
export function findTableByCode(content: ContentPack, code: string): TableDefinition {
|
|
||||||
const table = content.tables.find((entry) => entry.code === code);
|
|
||||||
|
|
||||||
if (!table) {
|
|
||||||
throw new Error(`Unknown table code: ${code}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return table;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function findRoomTemplateById(
|
|
||||||
content: ContentPack,
|
|
||||||
roomTemplateId: string,
|
|
||||||
): RoomTemplate {
|
|
||||||
const roomTemplate = content.roomTemplates.find((entry) => entry.id === roomTemplateId);
|
|
||||||
|
|
||||||
if (!roomTemplate) {
|
|
||||||
throw new Error(`Unknown room template id: ${roomTemplateId}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return roomTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function findRoomTemplateForLookup(
|
|
||||||
content: ContentPack,
|
|
||||||
lookup: TableLookupResult,
|
|
||||||
): RoomTemplate {
|
|
||||||
const roomReference = lookup.entry.references?.find((reference) => reference.type === "room");
|
|
||||||
|
|
||||||
if (!roomReference) {
|
|
||||||
throw new Error(`Lookup result ${lookup.tableId}:${lookup.entryKey} does not point to a room.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return findRoomTemplateById(content, roomReference.id);
|
|
||||||
}
|
|
||||||
@@ -1,649 +0,0 @@
|
|||||||
import type { RoomTemplate } from "@/types/content";
|
|
||||||
|
|
||||||
export const level1RoomTemplates: RoomTemplate[] = [
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.empty-room",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 42,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P1",
|
|
||||||
tableEntryKey: "2",
|
|
||||||
title: "Empty Room",
|
|
||||||
text: "A bare chamber with little more than dust and stone.",
|
|
||||||
encounterText: "Nothing here.",
|
|
||||||
exitHint: "Archways only.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "empty"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.abandoned-guard-post",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 42,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P1",
|
|
||||||
tableEntryKey: "3",
|
|
||||||
title: "Abandoned Guard Post",
|
|
||||||
text: "A disused guard station with ruined furnishings and signs of looting.",
|
|
||||||
encounterText: "Search debris for wooden objects beneath collapsed furniture.",
|
|
||||||
exitHint: "Wooden doors.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "search"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.guard-post",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 42,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P1",
|
|
||||||
tableEntryKey: "4",
|
|
||||||
title: "Guard Post",
|
|
||||||
text: "A still-used guard room with a table, benches, and simple fixtures.",
|
|
||||||
encounterText: "If occupied, use the martial encounter table.",
|
|
||||||
exitHint: "Reinforced wooden doors.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "guards"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.storage-area",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 42,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P1",
|
|
||||||
tableEntryKey: "5",
|
|
||||||
title: "Storage Area",
|
|
||||||
text: "Crates and barrels fill the walls, with spoiled goods hidden among them.",
|
|
||||||
encounterText: "Roll for food, drink, or crate events while searching.",
|
|
||||||
exitHint: "Archways.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "loot"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.meeting-room",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 42,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P1",
|
|
||||||
tableEntryKey: "6",
|
|
||||||
title: "Meeting Room",
|
|
||||||
text: "Simple tables and chairs suggest an old gathering place.",
|
|
||||||
encounterText: "Workers or a crazed preacher may be present depending on the table roll.",
|
|
||||||
exitHint: "Wooden doors.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "social"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.blacksmith-space",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 42,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P1",
|
|
||||||
tableEntryKey: "7",
|
|
||||||
title: "Blacksmith Space",
|
|
||||||
text: "An anvil and cold forge remain in a soot-darkened workshop.",
|
|
||||||
encounterText: "Roll for weapon loot or a worker-themed encounter.",
|
|
||||||
exitHint: "Archways.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "craft"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.holding-cell",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 42,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P1",
|
|
||||||
tableEntryKey: "8",
|
|
||||||
title: "Holding Cell",
|
|
||||||
text: "A grim cell with chains, a chamber pot, and signs of former prisoners.",
|
|
||||||
encounterText: "Check whether the cell is empty or contains a prisoner.",
|
|
||||||
exitHint: "Reinforced doors.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "cell"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.wash-room",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 42,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P1",
|
|
||||||
tableEntryKey: "9",
|
|
||||||
title: "Wash Room",
|
|
||||||
text: "Buckets, basins, and cloths suggest a communal cleaning room.",
|
|
||||||
encounterText: "May contain slimy or fungal threats and hidden salvage.",
|
|
||||||
exitHint: "Random roll for exits.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "utility"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.kennel",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 42,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P1",
|
|
||||||
tableEntryKey: "10",
|
|
||||||
title: "Kennel",
|
|
||||||
text: "A low room littered with straw and the stink of animals.",
|
|
||||||
encounterText: "Use the level 1 dogs table if occupied.",
|
|
||||||
exitHint: "Wooden doors.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "animals"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.snake-pit",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 42,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P1",
|
|
||||||
tableEntryKey: "11",
|
|
||||||
title: "Snake Pit",
|
|
||||||
text: "A dusty pit cut into the floor houses a nest of snakes.",
|
|
||||||
encounterText: "Open the chest only if you survive the pit's occupants.",
|
|
||||||
exitHint: "Random roll for exits.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "animals", "hazard"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.weapon-dump",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 42,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P1",
|
|
||||||
tableEntryKey: "12",
|
|
||||||
title: "Weapon Dump",
|
|
||||||
text: "Broken weapons and shields spill from a long-past discard pile.",
|
|
||||||
encounterText: "Roll for random weapons and possible fungal attackers.",
|
|
||||||
exitHint: "Wooden doors.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "loot", "weapons"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.guard-room",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 43,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P2",
|
|
||||||
tableEntryKey: "2",
|
|
||||||
title: "Guard Room",
|
|
||||||
text: "A stone room with table, chairs, and signs of routine occupation.",
|
|
||||||
encounterText: "Use the guards encounter table if occupied.",
|
|
||||||
exitHint: "Wooden doors.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "guards"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.pool-room",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 43,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P2",
|
|
||||||
tableEntryKey: "3",
|
|
||||||
title: "Pool Room",
|
|
||||||
text: "A raised stone pool dominates the center of this damp chamber.",
|
|
||||||
encounterText: "Investigating the pool may trigger a slimy or animal threat.",
|
|
||||||
exitHint: "Wooden doors.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "water"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.storage-area-2",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 43,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P2",
|
|
||||||
tableEntryKey: "4",
|
|
||||||
title: "Storage Area",
|
|
||||||
text: "Ropes, cloth, and supplies are stacked among the dust.",
|
|
||||||
encounterText: "Arms and empty chests invite a guarded search.",
|
|
||||||
exitHint: "Archways.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "loot"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.canteen",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 43,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P2",
|
|
||||||
tableEntryKey: "5",
|
|
||||||
title: "Canteen",
|
|
||||||
text: "Rough tables and stools fill an old communal eating space.",
|
|
||||||
encounterText: "Labourers or workers may still be here.",
|
|
||||||
exitHint: "Wooden doors.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "social"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.mourning-quarters",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 43,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P2",
|
|
||||||
tableEntryKey: "6",
|
|
||||||
title: "Mourning Quarters",
|
|
||||||
text: "An eerie chamber of candles, a shrouded bier, and stale grief.",
|
|
||||||
encounterText: "A corpse may be present and can trigger a level 1 corpse interaction.",
|
|
||||||
exitHint: "Random roll for exits.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "ritual"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.holding-cell-2",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 43,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P2",
|
|
||||||
tableEntryKey: "7",
|
|
||||||
title: "Holding Cell",
|
|
||||||
text: "A bare cell cut off from the rest of the room by bars.",
|
|
||||||
encounterText: "Check for a prisoner before searching further.",
|
|
||||||
exitHint: "Reinforced doors.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "cell"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.training-room",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 43,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P2",
|
|
||||||
tableEntryKey: "8",
|
|
||||||
title: "Training Room",
|
|
||||||
text: "Mannequins, target poles, and old practice gear fill the space.",
|
|
||||||
encounterText: "Armour and weapons training prompts a follow-up armour or item roll.",
|
|
||||||
exitHint: "Random roll for exits.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "training"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.dorm",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 43,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P2",
|
|
||||||
tableEntryKey: "9",
|
|
||||||
title: "Dorm",
|
|
||||||
text: "Hammocks and scattered belongings suggest a once-lived-in barracks room.",
|
|
||||||
encounterText: "Use the people table if the dorm is occupied.",
|
|
||||||
exitHint: "Wooden doors.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "sleeping"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.apothecary",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 43,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P2",
|
|
||||||
tableEntryKey: "10",
|
|
||||||
title: "Apothecary",
|
|
||||||
text: "Shelves of jars and bottles crowd a room thick with old herbs.",
|
|
||||||
encounterText: "Medicine or potion finds compete with apothecary occupants.",
|
|
||||||
exitHint: "Random roll for exits.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "alchemy"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.damp-space",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 43,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P2",
|
|
||||||
tableEntryKey: "11",
|
|
||||||
title: "Damp Space",
|
|
||||||
text: "Moist stone and fungus overrun this clammy side room.",
|
|
||||||
encounterText: "A fungal encounter may attack when the fungus is disturbed.",
|
|
||||||
exitHint: "Reinforced doors.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "fungal"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.normal.chapel",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 43,
|
|
||||||
roomClass: "normal",
|
|
||||||
tableCode: "L1R-P2",
|
|
||||||
tableEntryKey: "12",
|
|
||||||
title: "Chapel",
|
|
||||||
text: "Candles, benches, and a central altar mark a room of devotion.",
|
|
||||||
encounterText: "Dark clergy or a corpse event can emerge here after the altar is examined.",
|
|
||||||
exitHint: "Curtains.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "religious"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.large.stone-workshop",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 40,
|
|
||||||
roomClass: "large",
|
|
||||||
tableCode: "L1LR",
|
|
||||||
tableEntryKey: "2",
|
|
||||||
title: "Stone Workshop",
|
|
||||||
text: "Large tables, stone shelves, and an oversized work area dominate the room.",
|
|
||||||
encounterText: "No built-in encounter.",
|
|
||||||
exitHint: "Wooden doors.",
|
|
||||||
tags: ["human-ancestry", "large", "craft"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.large.marble-hall",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 40,
|
|
||||||
roomClass: "large",
|
|
||||||
tableCode: "L1LR",
|
|
||||||
tableEntryKey: "3",
|
|
||||||
title: "Marble Hall",
|
|
||||||
text: "A ceremonial hall lined with pillars and a raised seating platform.",
|
|
||||||
encounterText: "No built-in encounter.",
|
|
||||||
exitHint: "Archways.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "large", "hall"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.large.old-mess-hall",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 40,
|
|
||||||
roomClass: "large",
|
|
||||||
tableCode: "L1LR",
|
|
||||||
tableEntryKey: "4",
|
|
||||||
title: "Old Mess Hall",
|
|
||||||
text: "Long tables and benches suggest a once-busy common dining area.",
|
|
||||||
encounterText: "No built-in encounter.",
|
|
||||||
exitHint: "Wooden doors.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "large", "social"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.large.penitentiary",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 40,
|
|
||||||
roomClass: "large",
|
|
||||||
tableCode: "L1LR",
|
|
||||||
tableEntryKey: "5",
|
|
||||||
title: "Penitentiary",
|
|
||||||
text: "A chained whipping post and harsh punishments define this grim chamber.",
|
|
||||||
encounterText: "No built-in encounter.",
|
|
||||||
exitHint: "Reinforced doors.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "large", "punishment"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.large.fountain-room",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 40,
|
|
||||||
roomClass: "large",
|
|
||||||
tableCode: "L1LR",
|
|
||||||
tableEntryKey: "6",
|
|
||||||
title: "Fountain Room",
|
|
||||||
text: "A circular fountain and polished floor lend this chamber a sacred tone.",
|
|
||||||
encounterText: "No built-in encounter.",
|
|
||||||
exitHint: "Archways.",
|
|
||||||
tags: ["human-ancestry", "large", "water"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.large.temple",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 40,
|
|
||||||
roomClass: "large",
|
|
||||||
tableCode: "L1LR",
|
|
||||||
tableEntryKey: "7",
|
|
||||||
title: "Temple",
|
|
||||||
text: "Benches and chandeliers frame a formal place of worship.",
|
|
||||||
encounterText: "No built-in encounter.",
|
|
||||||
exitHint: "Archways.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "large", "religious"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.large.sparring-chamber",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 40,
|
|
||||||
roomClass: "large",
|
|
||||||
tableCode: "L1LR",
|
|
||||||
tableEntryKey: "8",
|
|
||||||
title: "Sparring Chamber",
|
|
||||||
text: "Sand, markings, and weapons racks show this room was used for training.",
|
|
||||||
encounterText: "A warrior can appear here.",
|
|
||||||
exitHint: "Wooden doors.",
|
|
||||||
tags: ["human-ancestry", "large", "training"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.large.crate-store",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 40,
|
|
||||||
roomClass: "large",
|
|
||||||
tableCode: "L1LR",
|
|
||||||
tableEntryKey: "9",
|
|
||||||
title: "Crate Store",
|
|
||||||
text: "Crates and stacked stone create shadows and possible hidden spaces.",
|
|
||||||
encounterText: "No built-in encounter.",
|
|
||||||
exitHint: "Archways.",
|
|
||||||
tags: ["human-ancestry", "large", "loot"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.large.slate-shrine",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 40,
|
|
||||||
roomClass: "large",
|
|
||||||
tableCode: "L1LR",
|
|
||||||
tableEntryKey: "10",
|
|
||||||
title: "Slate Shrine",
|
|
||||||
text: "A central slate monolith marks a room of devotion and offering.",
|
|
||||||
encounterText: "No built-in encounter.",
|
|
||||||
exitHint: "Archways.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "large", "religious"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.large.dormitory",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 40,
|
|
||||||
roomClass: "large",
|
|
||||||
tableCode: "L1LR",
|
|
||||||
tableEntryKey: "11",
|
|
||||||
title: "Dormitory",
|
|
||||||
text: "Rows of bunks and sparse belongings line the walls.",
|
|
||||||
encounterText: "No built-in encounter.",
|
|
||||||
exitHint: "Wooden doors.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "large", "sleeping"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.large.library",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 40,
|
|
||||||
roomClass: "large",
|
|
||||||
tableCode: "L1LR",
|
|
||||||
tableEntryKey: "12",
|
|
||||||
title: "Library",
|
|
||||||
text: "Towering bookshelves and guarded knowledge define this vast archive.",
|
|
||||||
encounterText: "Two guards can be found here.",
|
|
||||||
exitHint: "Wooden doors.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "large", "books"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.small.empty-space",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 46,
|
|
||||||
roomClass: "small",
|
|
||||||
tableCode: "L1SR",
|
|
||||||
tableEntryKey: "2",
|
|
||||||
title: "Empty Space",
|
|
||||||
text: "A bare side space with nothing of note.",
|
|
||||||
encounterText: "Nothing here.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "small", "empty"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.small.strange-text",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 46,
|
|
||||||
roomClass: "small",
|
|
||||||
tableCode: "L1SR",
|
|
||||||
tableEntryKey: "3",
|
|
||||||
title: "Strange Text",
|
|
||||||
text: "An old message linking the corridor to ancient hunger and warning.",
|
|
||||||
encounterText: "No encounter.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "small", "lore"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.small.grazada-mural",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 46,
|
|
||||||
roomClass: "small",
|
|
||||||
tableCode: "L1SR",
|
|
||||||
tableEntryKey: "4",
|
|
||||||
title: "Grazada Mural",
|
|
||||||
text: "A tiled image of the goddess of sacrifice fills the wall.",
|
|
||||||
encounterText: "A possible favour interaction.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "small", "religious"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.small.intuneric-mosaic",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 46,
|
|
||||||
roomClass: "small",
|
|
||||||
tableCode: "L1SR",
|
|
||||||
tableEntryKey: "5",
|
|
||||||
title: "Intuneric Mosaic",
|
|
||||||
text: "A shrine mosaic to the god of influence and gifts.",
|
|
||||||
encounterText: "A possible favour interaction.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "small", "religious"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.small.maduva-statue",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 46,
|
|
||||||
roomClass: "small",
|
|
||||||
tableCode: "L1SR",
|
|
||||||
tableEntryKey: "6",
|
|
||||||
title: "Maduva Statue",
|
|
||||||
text: "A twisted statue of Maduva stands watch in the niche.",
|
|
||||||
encounterText: "A possible favour interaction.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "small", "religious"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.small.murtayne-effigy",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 46,
|
|
||||||
roomClass: "small",
|
|
||||||
tableCode: "L1SR",
|
|
||||||
tableEntryKey: "7",
|
|
||||||
title: "Murtayne Effigy",
|
|
||||||
text: "A rotting fleshy effigy marks a place linked to disease and corruption.",
|
|
||||||
encounterText: "A possible favour interaction.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "small", "religious"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.small.nevzator-doll",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 46,
|
|
||||||
roomClass: "small",
|
|
||||||
tableCode: "L1SR",
|
|
||||||
tableEntryKey: "8",
|
|
||||||
title: "Nevzator Doll",
|
|
||||||
text: "A rope doll symbolizes hidden dealings and quiet bargains.",
|
|
||||||
encounterText: "A possible favour interaction.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "small", "religious"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.small.radacina-tapestry",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 46,
|
|
||||||
roomClass: "small",
|
|
||||||
tableCode: "L1SR",
|
|
||||||
tableEntryKey: "9",
|
|
||||||
title: "Radacina Tapestry",
|
|
||||||
text: "A tapestry of Radacina, deity of teaching, hangs in the space.",
|
|
||||||
encounterText: "A possible favour interaction.",
|
|
||||||
unique: true,
|
|
||||||
tags: ["human-ancestry", "small", "religious"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.small.heated-space",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 46,
|
|
||||||
roomClass: "small",
|
|
||||||
tableCode: "L1SR",
|
|
||||||
tableEntryKey: "10",
|
|
||||||
title: "Heated Space",
|
|
||||||
text: "Warmth and wavering shadows suggest hidden heat behind the walls.",
|
|
||||||
encounterText: "No encounter.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "small", "atmosphere"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.small.wall-shrine",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 46,
|
|
||||||
roomClass: "small",
|
|
||||||
tableCode: "L1SR",
|
|
||||||
tableEntryKey: "11",
|
|
||||||
title: "Wall Shrine",
|
|
||||||
text: "A small offering niche waits at the wall's edge.",
|
|
||||||
encounterText: "A possible favour interaction.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "small", "religious"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "room.level1.small.banner-arms",
|
|
||||||
level: 1,
|
|
||||||
sourcePage: 46,
|
|
||||||
roomClass: "small",
|
|
||||||
tableCode: "L1SR",
|
|
||||||
tableEntryKey: "12",
|
|
||||||
title: "Banner Arms",
|
|
||||||
text: "Crossed spears and an old shield suggest a ceremonial martial display.",
|
|
||||||
encounterText: "No encounter.",
|
|
||||||
unique: false,
|
|
||||||
tags: ["human-ancestry", "small", "martial"],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -1,224 +0,0 @@
|
|||||||
import type { TableDefinition } from "@/types/content";
|
|
||||||
|
|
||||||
export const level1EncounterTables: TableDefinition[] = [
|
|
||||||
{
|
|
||||||
id: "table.level1.animals",
|
|
||||||
code: "L1A",
|
|
||||||
name: "Level 1 Animals",
|
|
||||||
category: "level",
|
|
||||||
level: 1,
|
|
||||||
page: 38,
|
|
||||||
diceKind: "d6",
|
|
||||||
entries: [
|
|
||||||
{ key: "1", exact: 1, label: "Giant Rat" },
|
|
||||||
{ key: "2", exact: 2, label: "Huge Rat" },
|
|
||||||
{ key: "3", exact: 3, label: "Work Dog" },
|
|
||||||
{ key: "4", exact: 4, label: "Guard Dog" },
|
|
||||||
{ key: "5", exact: 5, label: "Shard Rock Python" },
|
|
||||||
{ key: "6", exact: 6, label: "Giant Horned Anaconda" },
|
|
||||||
],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "table.level1.martial",
|
|
||||||
code: "L1M",
|
|
||||||
name: "Level 1 Martial",
|
|
||||||
category: "level",
|
|
||||||
level: 1,
|
|
||||||
page: 38,
|
|
||||||
diceKind: "d6",
|
|
||||||
entries: [
|
|
||||||
{ key: "1", exact: 1, label: "Guard" },
|
|
||||||
{ key: "2", exact: 2, label: "Guard" },
|
|
||||||
{ key: "3", exact: 3, label: "Warrior" },
|
|
||||||
{ key: "4", exact: 4, label: "Veteran" },
|
|
||||||
{ key: "5", exact: 5, label: "Veteran" },
|
|
||||||
{ key: "6", exact: 6, label: "Guard and Guard" },
|
|
||||||
],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "table.level1.dogs",
|
|
||||||
code: "L1D",
|
|
||||||
name: "Level 1 Dogs",
|
|
||||||
category: "level",
|
|
||||||
level: 1,
|
|
||||||
page: 38,
|
|
||||||
diceKind: "d6",
|
|
||||||
entries: [
|
|
||||||
{ key: "1", exact: 1, label: "Work Dog" },
|
|
||||||
{ key: "2", exact: 2, label: "Guard Dog" },
|
|
||||||
{ key: "3", exact: 3, label: "Guard Dog" },
|
|
||||||
{ key: "4", exact: 4, label: "Guard Hound" },
|
|
||||||
{ key: "5", exact: 5, label: "War Hound" },
|
|
||||||
{ key: "6", exact: 6, label: "Guard and Work Dog" },
|
|
||||||
],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "table.level1.people",
|
|
||||||
code: "L1P",
|
|
||||||
name: "Level 1 People",
|
|
||||||
category: "level",
|
|
||||||
level: 1,
|
|
||||||
page: 38,
|
|
||||||
diceKind: "d6",
|
|
||||||
entries: [
|
|
||||||
{ key: "1", exact: 1, label: "Labourer" },
|
|
||||||
{ key: "2", exact: 2, label: "Crazed Preacher" },
|
|
||||||
{ key: "3", exact: 3, label: "Thug" },
|
|
||||||
{ key: "4", exact: 4, label: "Guard" },
|
|
||||||
{ key: "5", exact: 5, label: "Guard and Guard Dog" },
|
|
||||||
{ key: "6", exact: 6, label: "Labourer and Guard Dog" },
|
|
||||||
],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "table.level1.fungal",
|
|
||||||
code: "L1F",
|
|
||||||
name: "Level 1 Fungal",
|
|
||||||
category: "level",
|
|
||||||
level: 1,
|
|
||||||
page: 38,
|
|
||||||
diceKind: "d6",
|
|
||||||
entries: [
|
|
||||||
{ key: "1", exact: 1, label: "Fungal Geist" },
|
|
||||||
{ key: "2", exact: 2, label: "Fungal Geist" },
|
|
||||||
{ key: "3", exact: 3, label: "Musty Bloater" },
|
|
||||||
{ key: "4", exact: 4, label: "Musty Bloater" },
|
|
||||||
{ key: "5", exact: 5, label: "Musty Bloater" },
|
|
||||||
{ key: "6", exact: 6, label: "Slimy Gorger" },
|
|
||||||
],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "table.level1.guards",
|
|
||||||
code: "L1G",
|
|
||||||
name: "Level 1 Guards",
|
|
||||||
category: "level",
|
|
||||||
level: 1,
|
|
||||||
page: 38,
|
|
||||||
diceKind: "d6",
|
|
||||||
entries: [
|
|
||||||
{ key: "1", exact: 1, label: "Thug" },
|
|
||||||
{ key: "2", exact: 2, label: "Thug" },
|
|
||||||
{ key: "3", exact: 3, label: "Guard" },
|
|
||||||
{ key: "4", exact: 4, label: "Guard" },
|
|
||||||
{ key: "5", exact: 5, label: "Guard" },
|
|
||||||
{ key: "6", exact: 6, label: "Guard and Warrior" },
|
|
||||||
],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "table.level1.workers",
|
|
||||||
code: "L1W",
|
|
||||||
name: "Level 1 Workers",
|
|
||||||
category: "level",
|
|
||||||
level: 1,
|
|
||||||
page: 38,
|
|
||||||
diceKind: "d6",
|
|
||||||
entries: [
|
|
||||||
{ key: "1", exact: 1, label: "Thug" },
|
|
||||||
{ key: "2", exact: 2, label: "Thug" },
|
|
||||||
{ key: "3", exact: 3, label: "Labourer" },
|
|
||||||
{ key: "4", exact: 4, label: "Artisan" },
|
|
||||||
{ key: "5", exact: 5, label: "Blacksmith" },
|
|
||||||
{ key: "6", exact: 6, label: "Artisan and Medic" },
|
|
||||||
],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "table.level1.crate",
|
|
||||||
code: "L1CE",
|
|
||||||
name: "Level 1 Crate",
|
|
||||||
category: "level",
|
|
||||||
level: 1,
|
|
||||||
page: 38,
|
|
||||||
diceKind: "d6",
|
|
||||||
entries: [
|
|
||||||
{
|
|
||||||
key: "1",
|
|
||||||
exact: 1,
|
|
||||||
label: "Slimy Gorger Ambush",
|
|
||||||
text: "A slimy gorger drops from above and attacks immediately.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "2",
|
|
||||||
exact: 2,
|
|
||||||
label: "Giant Rat Pair",
|
|
||||||
text: "A pair of giant rats attacks while the room is being searched.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "3",
|
|
||||||
exact: 3,
|
|
||||||
label: "Huge Rat Ambush",
|
|
||||||
text: "A huge rat leaps from under the crate and attacks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "4",
|
|
||||||
exact: 4,
|
|
||||||
label: "Insect Swarm",
|
|
||||||
text: "Scuttling insects spill out from beneath a corpse during the search.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "5",
|
|
||||||
exact: 5,
|
|
||||||
label: "Corpse Trap",
|
|
||||||
text: "Searching the fallen body triggers a level 1 corpse-interaction event.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "6",
|
|
||||||
exact: 6,
|
|
||||||
label: "Hooked Bag",
|
|
||||||
text: "A bag fixed near the ceiling calls for a follow-up item table roll.",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "table.level1.large-rooms",
|
|
||||||
code: "L1LR",
|
|
||||||
name: "Level 1 Large Rooms",
|
|
||||||
category: "room",
|
|
||||||
level: 1,
|
|
||||||
page: 40,
|
|
||||||
diceKind: "2d6",
|
|
||||||
entries: [
|
|
||||||
{ key: "2", exact: 2, label: "Stone Workshop", references: [{ type: "room", id: "room.level1.large.stone-workshop" }] },
|
|
||||||
{ key: "3", exact: 3, label: "Marble Hall", references: [{ type: "room", id: "room.level1.large.marble-hall" }] },
|
|
||||||
{ key: "4", exact: 4, label: "Old Mess Hall", references: [{ type: "room", id: "room.level1.large.old-mess-hall" }] },
|
|
||||||
{ key: "5", exact: 5, label: "Penitentiary", references: [{ type: "room", id: "room.level1.large.penitentiary" }] },
|
|
||||||
{ key: "6", exact: 6, label: "Fountain Room", references: [{ type: "room", id: "room.level1.large.fountain-room" }] },
|
|
||||||
{ key: "7", exact: 7, label: "Temple", references: [{ type: "room", id: "room.level1.large.temple" }] },
|
|
||||||
{ key: "8", exact: 8, label: "Sparring Chamber", references: [{ type: "room", id: "room.level1.large.sparring-chamber" }] },
|
|
||||||
{ key: "9", exact: 9, label: "Crate Store", references: [{ type: "room", id: "room.level1.large.crate-store" }] },
|
|
||||||
{ key: "10", exact: 10, label: "Slate Shrine", references: [{ type: "room", id: "room.level1.large.slate-shrine" }] },
|
|
||||||
{ key: "11", exact: 11, label: "Dormitory", references: [{ type: "room", id: "room.level1.large.dormitory" }] },
|
|
||||||
{ key: "12", exact: 12, label: "Library", references: [{ type: "room", id: "room.level1.large.library" }] },
|
|
||||||
],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "table.level1.small-rooms",
|
|
||||||
code: "L1SR",
|
|
||||||
name: "Level 1 Small Rooms",
|
|
||||||
category: "room",
|
|
||||||
level: 1,
|
|
||||||
page: 46,
|
|
||||||
diceKind: "2d6",
|
|
||||||
entries: [
|
|
||||||
{ key: "2", exact: 2, label: "Empty Space", references: [{ type: "room", id: "room.level1.small.empty-space" }] },
|
|
||||||
{ key: "3", exact: 3, label: "Strange Text", references: [{ type: "room", id: "room.level1.small.strange-text" }] },
|
|
||||||
{ key: "4", exact: 4, label: "Grazada Mural", references: [{ type: "room", id: "room.level1.small.grazada-mural" }] },
|
|
||||||
{ key: "5", exact: 5, label: "Intuneric Mosaic", references: [{ type: "room", id: "room.level1.small.intuneric-mosaic" }] },
|
|
||||||
{ key: "6", exact: 6, label: "Maduva Statue", references: [{ type: "room", id: "room.level1.small.maduva-statue" }] },
|
|
||||||
{ key: "7", exact: 7, label: "Murtayne Effigy", references: [{ type: "room", id: "room.level1.small.murtayne-effigy" }] },
|
|
||||||
{ key: "8", exact: 8, label: "Nevzator Doll", references: [{ type: "room", id: "room.level1.small.nevzator-doll" }] },
|
|
||||||
{ key: "9", exact: 9, label: "Radacina Tapestry", references: [{ type: "room", id: "room.level1.small.radacina-tapestry" }] },
|
|
||||||
{ key: "10", exact: 10, label: "Heated Space", references: [{ type: "room", id: "room.level1.small.heated-space" }] },
|
|
||||||
{ key: "11", exact: 11, label: "Wall Shrine", references: [{ type: "room", id: "room.level1.small.wall-shrine" }] },
|
|
||||||
{ key: "12", exact: 12, label: "Banner Arms", references: [{ type: "room", id: "room.level1.small.banner-arms" }] },
|
|
||||||
],
|
|
||||||
mvp: true,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
import type { ContentPack } from "@/types/content";
|
import type { ContentPack } from "@/types/content";
|
||||||
|
|
||||||
import { contentPackSchema } from "@/schemas/content";
|
import { contentPackSchema } from "@/schemas/content";
|
||||||
import { level1RoomTemplates } from "./level1Rooms";
|
|
||||||
import { level1EncounterTables } from "./level1Tables";
|
|
||||||
|
|
||||||
const samplePack = {
|
const samplePack = {
|
||||||
version: "0.1.0",
|
version: "0.1.0",
|
||||||
@@ -12,7 +10,6 @@ const samplePack = {
|
|||||||
"Source/2D6 Dungeon - Play Sheet.pdf",
|
"Source/2D6 Dungeon - Play Sheet.pdf",
|
||||||
],
|
],
|
||||||
tables: [
|
tables: [
|
||||||
...level1EncounterTables,
|
|
||||||
{
|
{
|
||||||
id: "table.weapon-manoeuvres-1",
|
id: "table.weapon-manoeuvres-1",
|
||||||
code: "WMT1",
|
code: "WMT1",
|
||||||
@@ -172,7 +169,6 @@ const samplePack = {
|
|||||||
{
|
{
|
||||||
id: "room.level1.entry",
|
id: "room.level1.entry",
|
||||||
level: 1,
|
level: 1,
|
||||||
sourcePage: 42,
|
|
||||||
roomClass: "start",
|
roomClass: "start",
|
||||||
tableCode: "L1R",
|
tableCode: "L1R",
|
||||||
tableEntryKey: "entry",
|
tableEntryKey: "entry",
|
||||||
@@ -186,7 +182,6 @@ const samplePack = {
|
|||||||
tags: ["starter", "entry"],
|
tags: ["starter", "entry"],
|
||||||
mvp: true,
|
mvp: true,
|
||||||
},
|
},
|
||||||
...level1RoomTemplates,
|
|
||||||
],
|
],
|
||||||
townServices: [
|
townServices: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
|
||||||
|
|
||||||
import { sampleContentPack } from "@/data/sampleContentPack";
|
|
||||||
|
|
||||||
import {
|
|
||||||
expandLevelFromExit,
|
|
||||||
getUnresolvedExits,
|
|
||||||
initializeDungeonLevel,
|
|
||||||
} from "./dungeon";
|
|
||||||
|
|
||||||
function createSequenceRoller(values: number[]) {
|
|
||||||
let index = 0;
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
const next = values[index];
|
|
||||||
index += 1;
|
|
||||||
return next;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("dungeon state", () => {
|
|
||||||
it("initializes level 1 with a generated start room", () => {
|
|
||||||
const levelState = initializeDungeonLevel({ content: sampleContentPack });
|
|
||||||
|
|
||||||
expect(levelState.level).toBe(1);
|
|
||||||
expect(levelState.discoveredRoomOrder).toEqual(["room.level1.start"]);
|
|
||||||
expect(levelState.rooms["room.level1.start"]?.roomClass).toBe("start");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("lists unresolved traversable exits in discovery order", () => {
|
|
||||||
const levelState = initializeDungeonLevel({ content: sampleContentPack });
|
|
||||||
|
|
||||||
expect(getUnresolvedExits(levelState)).toEqual([
|
|
||||||
expect.objectContaining({
|
|
||||||
roomId: "room.level1.start",
|
|
||||||
direction: "north",
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("expands the dungeon from a chosen exit and links both rooms", () => {
|
|
||||||
const levelState = initializeDungeonLevel({ content: sampleContentPack });
|
|
||||||
const result = expandLevelFromExit({
|
|
||||||
content: sampleContentPack,
|
|
||||||
levelState,
|
|
||||||
fromRoomId: "room.level1.start",
|
|
||||||
exitDirection: "north",
|
|
||||||
roomTableCode: "L1SR",
|
|
||||||
roller: createSequenceRoller([3, 3]),
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(result.createdRoom.position).toEqual({ x: 0, y: -1 });
|
|
||||||
expect(result.levelState.discoveredRoomOrder).toEqual([
|
|
||||||
"room.level1.start",
|
|
||||||
"room.level1.small.002",
|
|
||||||
]);
|
|
||||||
expect(result.fromRoom.exits[0]?.leadsToRoomId).toBe("room.level1.small.002");
|
|
||||||
expect(result.createdRoom.exits.some((exit) => exit.leadsToRoomId === "room.level1.start")).toBe(
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("rejects placement into an occupied coordinate", () => {
|
|
||||||
const levelState = initializeDungeonLevel({ content: sampleContentPack });
|
|
||||||
const expanded = expandLevelFromExit({
|
|
||||||
content: sampleContentPack,
|
|
||||||
levelState,
|
|
||||||
fromRoomId: "room.level1.start",
|
|
||||||
exitDirection: "north",
|
|
||||||
roomTableCode: "L1SR",
|
|
||||||
roomId: "room.level1.small.a",
|
|
||||||
roller: createSequenceRoller([3, 3]),
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(() =>
|
|
||||||
expandLevelFromExit({
|
|
||||||
content: sampleContentPack,
|
|
||||||
levelState: expanded.levelState,
|
|
||||||
fromRoomId: "room.level1.start",
|
|
||||||
exitDirection: "north",
|
|
||||||
roomTableCode: "L1SR",
|
|
||||||
roomId: "room.level1.small.b",
|
|
||||||
roller: createSequenceRoller([4, 4]),
|
|
||||||
}),
|
|
||||||
).toThrow("already connected");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,219 +0,0 @@
|
|||||||
import type { ContentPack } from "@/types/content";
|
|
||||||
import type { DungeonLevelState, RoomExitState, RoomState } from "@/types/state";
|
|
||||||
|
|
||||||
import { createLevelShell, generateLevel1StartRoom, generateRoomFromTable } from "./rooms";
|
|
||||||
import type { DiceRoller } from "./dice";
|
|
||||||
|
|
||||||
type CardinalDirection = "north" | "east" | "south" | "west";
|
|
||||||
|
|
||||||
export type InitializeLevelOptions = {
|
|
||||||
content: ContentPack;
|
|
||||||
level?: number;
|
|
||||||
startRoomId?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type ExpandFromExitOptions = {
|
|
||||||
content: ContentPack;
|
|
||||||
levelState: DungeonLevelState;
|
|
||||||
fromRoomId: string;
|
|
||||||
exitDirection: CardinalDirection;
|
|
||||||
roomTableCode: string;
|
|
||||||
roomId?: string;
|
|
||||||
roller?: DiceRoller;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type ExpansionResult = {
|
|
||||||
levelState: DungeonLevelState;
|
|
||||||
createdRoom: RoomState;
|
|
||||||
fromRoom: RoomState;
|
|
||||||
};
|
|
||||||
|
|
||||||
const DIRECTION_VECTORS: Record<CardinalDirection, { x: number; y: number }> = {
|
|
||||||
north: { x: 0, y: -1 },
|
|
||||||
east: { x: 1, y: 0 },
|
|
||||||
south: { x: 0, y: 1 },
|
|
||||||
west: { x: -1, y: 0 },
|
|
||||||
};
|
|
||||||
|
|
||||||
const OPPOSITE_DIRECTION: Record<CardinalDirection, CardinalDirection> = {
|
|
||||||
north: "south",
|
|
||||||
east: "west",
|
|
||||||
south: "north",
|
|
||||||
west: "east",
|
|
||||||
};
|
|
||||||
|
|
||||||
function cloneRoom(room: RoomState): RoomState {
|
|
||||||
return {
|
|
||||||
...room,
|
|
||||||
position: { ...room.position },
|
|
||||||
dimensions: { ...room.dimensions },
|
|
||||||
exits: room.exits.map((exit) => ({ ...exit })),
|
|
||||||
discovery: { ...room.discovery },
|
|
||||||
encounter: room.encounter
|
|
||||||
? {
|
|
||||||
...room.encounter,
|
|
||||||
creatureIds: [...room.encounter.creatureIds],
|
|
||||||
creatureNames: room.encounter.creatureNames
|
|
||||||
? [...room.encounter.creatureNames]
|
|
||||||
: undefined,
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
objects: room.objects.map((object) => ({
|
|
||||||
...object,
|
|
||||||
effects: object.effects ? [...object.effects] : undefined,
|
|
||||||
})),
|
|
||||||
notes: [...room.notes],
|
|
||||||
flags: [...room.flags],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function cloneLevel(levelState: DungeonLevelState): DungeonLevelState {
|
|
||||||
return {
|
|
||||||
...levelState,
|
|
||||||
rooms: Object.fromEntries(
|
|
||||||
Object.entries(levelState.rooms).map(([roomId, room]) => [roomId, cloneRoom(room)]),
|
|
||||||
),
|
|
||||||
discoveredRoomOrder: [...levelState.discoveredRoomOrder],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function findExit(room: RoomState, direction: CardinalDirection): RoomExitState {
|
|
||||||
const exit = room.exits.find((candidate) => candidate.direction === direction);
|
|
||||||
|
|
||||||
if (!exit) {
|
|
||||||
throw new Error(`Room ${room.id} does not have an exit facing ${direction}.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
function computeNextPosition(room: RoomState, direction: CardinalDirection) {
|
|
||||||
const offset = DIRECTION_VECTORS[direction];
|
|
||||||
|
|
||||||
return {
|
|
||||||
x: room.position.x + offset.x,
|
|
||||||
y: room.position.y + offset.y,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function connectRooms(
|
|
||||||
fromRoom: RoomState,
|
|
||||||
toRoom: RoomState,
|
|
||||||
direction: CardinalDirection,
|
|
||||||
) {
|
|
||||||
const fromExit = findExit(fromRoom, direction);
|
|
||||||
fromExit.leadsToRoomId = toRoom.id;
|
|
||||||
fromExit.discovered = true;
|
|
||||||
|
|
||||||
const oppositeDirection = OPPOSITE_DIRECTION[direction];
|
|
||||||
const returnExit =
|
|
||||||
toRoom.exits.find((candidate) => candidate.direction === oppositeDirection) ?? toRoom.exits[0];
|
|
||||||
|
|
||||||
if (!returnExit) {
|
|
||||||
throw new Error(`Generated room ${toRoom.id} does not have an available return exit.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
returnExit.direction = oppositeDirection;
|
|
||||||
returnExit.leadsToRoomId = fromRoom.id;
|
|
||||||
returnExit.discovered = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNextRoomId(levelState: DungeonLevelState, roomClass: string) {
|
|
||||||
const sequence = levelState.discoveredRoomOrder.length + 1;
|
|
||||||
return `room.level${levelState.level}.${roomClass}.${String(sequence).padStart(3, "0")}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assertCoordinateAvailable(levelState: DungeonLevelState, position: { x: number; y: number }) {
|
|
||||||
const occupiedRoom = Object.values(levelState.rooms).find(
|
|
||||||
(room) => room.position.x === position.x && room.position.y === position.y,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (occupiedRoom) {
|
|
||||||
throw new Error(
|
|
||||||
`Cannot place a new room at (${position.x}, ${position.y}); ${occupiedRoom.id} already occupies that position.`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function initializeDungeonLevel(
|
|
||||||
options: InitializeLevelOptions,
|
|
||||||
): DungeonLevelState {
|
|
||||||
const level = options.level ?? 1;
|
|
||||||
|
|
||||||
if (level !== 1) {
|
|
||||||
throw new Error("Only Level 1 initialization is currently implemented.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const levelState = createLevelShell(level);
|
|
||||||
const startResult = generateLevel1StartRoom(
|
|
||||||
options.content,
|
|
||||||
options.startRoomId ?? `room.level${level}.start`,
|
|
||||||
);
|
|
||||||
|
|
||||||
levelState.rooms[startResult.room.id] = startResult.room;
|
|
||||||
levelState.discoveredRoomOrder.push(startResult.room.id);
|
|
||||||
|
|
||||||
return levelState;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getUnresolvedExits(levelState: DungeonLevelState) {
|
|
||||||
return levelState.discoveredRoomOrder.flatMap((roomId) => {
|
|
||||||
const room = levelState.rooms[roomId];
|
|
||||||
|
|
||||||
return room.exits
|
|
||||||
.filter((exit) => !exit.leadsToRoomId && exit.traversable)
|
|
||||||
.map((exit) => ({
|
|
||||||
roomId,
|
|
||||||
exitId: exit.id,
|
|
||||||
direction: exit.direction,
|
|
||||||
exitType: exit.exitType,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function expandLevelFromExit(
|
|
||||||
options: ExpandFromExitOptions,
|
|
||||||
): ExpansionResult {
|
|
||||||
const levelState = cloneLevel(options.levelState);
|
|
||||||
const fromRoom = levelState.rooms[options.fromRoomId];
|
|
||||||
|
|
||||||
if (!fromRoom) {
|
|
||||||
throw new Error(`Unknown source room id: ${options.fromRoomId}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const sourceExit = findExit(fromRoom, options.exitDirection);
|
|
||||||
|
|
||||||
if (sourceExit.leadsToRoomId) {
|
|
||||||
throw new Error(`Exit ${sourceExit.id} is already connected to ${sourceExit.leadsToRoomId}.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sourceExit.traversable) {
|
|
||||||
throw new Error(`Exit ${sourceExit.id} is not traversable.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const position = computeNextPosition(fromRoom, options.exitDirection);
|
|
||||||
assertCoordinateAvailable(levelState, position);
|
|
||||||
|
|
||||||
const provisionalRoomId =
|
|
||||||
options.roomId ?? getNextRoomId(levelState, options.roomTableCode === "L1SR" ? "small" : "room");
|
|
||||||
const result = generateRoomFromTable({
|
|
||||||
content: options.content,
|
|
||||||
roomId: provisionalRoomId,
|
|
||||||
level: levelState.level,
|
|
||||||
roomTableCode: options.roomTableCode,
|
|
||||||
position,
|
|
||||||
roller: options.roller,
|
|
||||||
});
|
|
||||||
|
|
||||||
connectRooms(fromRoom, result.room, options.exitDirection);
|
|
||||||
|
|
||||||
levelState.rooms[fromRoom.id] = fromRoom;
|
|
||||||
levelState.rooms[result.room.id] = result.room;
|
|
||||||
levelState.discoveredRoomOrder.push(result.room.id);
|
|
||||||
|
|
||||||
return {
|
|
||||||
levelState,
|
|
||||||
createdRoom: result.room,
|
|
||||||
fromRoom,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
|
||||||
|
|
||||||
import { sampleContentPack } from "@/data/sampleContentPack";
|
|
||||||
|
|
||||||
import { createRoomStateFromTemplate } from "./rooms";
|
|
||||||
import { resolveRoomEncounter } from "./encounters";
|
|
||||||
|
|
||||||
function createSequenceRoller(values: number[]) {
|
|
||||||
let index = 0;
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
const next = values[index];
|
|
||||||
index += 1;
|
|
||||||
return next;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("encounter resolution", () => {
|
|
||||||
it("marks explicitly empty rooms as having no encounter", () => {
|
|
||||||
const room = createRoomStateFromTemplate(
|
|
||||||
sampleContentPack,
|
|
||||||
"room.level1.small.empty",
|
|
||||||
1,
|
|
||||||
"room.level1.small.empty-space",
|
|
||||||
);
|
|
||||||
room.notes.push("Nothing here.");
|
|
||||||
|
|
||||||
const result = resolveRoomEncounter(sampleContentPack, room);
|
|
||||||
|
|
||||||
expect(result.encounter?.creatureIds).toEqual([]);
|
|
||||||
expect(result.encounter?.resultLabel).toBe("No encounter");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("uses room context to resolve a guard encounter table", () => {
|
|
||||||
const room = createRoomStateFromTemplate(
|
|
||||||
sampleContentPack,
|
|
||||||
"room.level1.guard-room",
|
|
||||||
1,
|
|
||||||
"room.level1.normal.guard-room",
|
|
||||||
);
|
|
||||||
room.notes.push("Use the guards encounter table if occupied.");
|
|
||||||
|
|
||||||
const result = resolveRoomEncounter(
|
|
||||||
sampleContentPack,
|
|
||||||
room,
|
|
||||||
createSequenceRoller([6]),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(result.lookup?.entry.label).toBe("Guard and Warrior");
|
|
||||||
expect(result.encounter?.sourceTableCode).toBe("L1G");
|
|
||||||
expect(result.encounter?.creatureNames).toEqual(["Guard", "Warrior"]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("resolves crate events from room context when the room hints at crate rolls", () => {
|
|
||||||
const room = createRoomStateFromTemplate(
|
|
||||||
sampleContentPack,
|
|
||||||
"room.level1.storage-area",
|
|
||||||
1,
|
|
||||||
"room.level1.normal.storage-area",
|
|
||||||
);
|
|
||||||
room.notes.push("Roll for food, drink, or crate events while searching.");
|
|
||||||
|
|
||||||
const result = resolveRoomEncounter(
|
|
||||||
sampleContentPack,
|
|
||||||
room,
|
|
||||||
createSequenceRoller([2]),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(result.lookup?.entry.label).toBe("Giant Rat Pair");
|
|
||||||
expect(result.encounter?.sourceTableCode).toBe("L1CE");
|
|
||||||
expect(result.encounter?.creatureNames).toEqual(["Giant Rat Pair"]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
import { findTableByCode } from "@/data/contentHelpers";
|
|
||||||
import type { ContentPack } from "@/types/content";
|
|
||||||
import type { EncounterState, RoomState } from "@/types/state";
|
|
||||||
|
|
||||||
import { lookupTable, type TableLookupResult } from "./tables";
|
|
||||||
import type { DiceRoller } from "./dice";
|
|
||||||
|
|
||||||
export type EncounterResolutionResult = {
|
|
||||||
room: RoomState;
|
|
||||||
encounter?: EncounterState;
|
|
||||||
lookup?: TableLookupResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
const ROOM_HINT_TO_TABLE: Array<{ pattern: RegExp; tableCode: string }> = [
|
|
||||||
{ pattern: /\bdogs?\b/i, tableCode: "L1D" },
|
|
||||||
{ pattern: /\bguards?\b/i, tableCode: "L1G" },
|
|
||||||
{ pattern: /\bmartial\b/i, tableCode: "L1M" },
|
|
||||||
{ pattern: /\bworkers?\b/i, tableCode: "L1W" },
|
|
||||||
{ pattern: /\blabourers?\b/i, tableCode: "L1P" },
|
|
||||||
{ pattern: /\bpreacher\b/i, tableCode: "L1P" },
|
|
||||||
{ pattern: /\banimals?\b/i, tableCode: "L1A" },
|
|
||||||
{ pattern: /\bsnakes?\b/i, tableCode: "L1A" },
|
|
||||||
{ pattern: /\bfungal\b/i, tableCode: "L1F" },
|
|
||||||
{ pattern: /\bslimy\b/i, tableCode: "L1F" },
|
|
||||||
{ pattern: /\bcrate\b/i, tableCode: "L1CE" },
|
|
||||||
];
|
|
||||||
|
|
||||||
function splitEncounterLabel(label: string) {
|
|
||||||
return label
|
|
||||||
.split(/\sand\s/i)
|
|
||||||
.map((part) => part.trim())
|
|
||||||
.filter(Boolean);
|
|
||||||
}
|
|
||||||
|
|
||||||
function inferEncounterTableCode(room: RoomState) {
|
|
||||||
const noteText = room.notes.join(" ");
|
|
||||||
const flagText = room.flags.join(" ");
|
|
||||||
const combinedText = `${noteText} ${flagText}`;
|
|
||||||
|
|
||||||
for (const mapping of ROOM_HINT_TO_TABLE) {
|
|
||||||
if (mapping.pattern.test(combinedText)) {
|
|
||||||
return mapping.tableCode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isNonEncounterRoom(room: RoomState) {
|
|
||||||
const noteText = room.notes.join(" ").toLowerCase();
|
|
||||||
return noteText.includes("nothing here") || noteText.includes("no encounter");
|
|
||||||
}
|
|
||||||
|
|
||||||
export function resolveRoomEncounter(
|
|
||||||
content: ContentPack,
|
|
||||||
room: RoomState,
|
|
||||||
roller?: DiceRoller,
|
|
||||||
): EncounterResolutionResult {
|
|
||||||
if (room.encounter?.resolved) {
|
|
||||||
return {
|
|
||||||
room,
|
|
||||||
encounter: room.encounter,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isNonEncounterRoom(room)) {
|
|
||||||
const emptyEncounter: EncounterState = {
|
|
||||||
id: `${room.id}.encounter`,
|
|
||||||
creatureIds: [],
|
|
||||||
creatureNames: [],
|
|
||||||
resultLabel: "No encounter",
|
|
||||||
resolved: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
room: {
|
|
||||||
...room,
|
|
||||||
encounter: emptyEncounter,
|
|
||||||
},
|
|
||||||
encounter: emptyEncounter,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const tableCode = inferEncounterTableCode(room);
|
|
||||||
|
|
||||||
if (!tableCode) {
|
|
||||||
return { room };
|
|
||||||
}
|
|
||||||
|
|
||||||
const table = findTableByCode(content, tableCode);
|
|
||||||
const lookup = lookupTable(table, { roller });
|
|
||||||
const creatureNames = splitEncounterLabel(lookup.entry.label);
|
|
||||||
const encounter: EncounterState = {
|
|
||||||
id: `${room.id}.encounter`,
|
|
||||||
sourceTableCode: tableCode,
|
|
||||||
creatureIds: creatureNames.map((_, index) => `${room.id}.creature.${index + 1}`),
|
|
||||||
creatureNames,
|
|
||||||
resultLabel: lookup.entry.label,
|
|
||||||
resolved: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
room: {
|
|
||||||
...room,
|
|
||||||
encounter,
|
|
||||||
},
|
|
||||||
encounter,
|
|
||||||
lookup,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
|
||||||
|
|
||||||
import { sampleContentPack } from "@/data/sampleContentPack";
|
|
||||||
|
|
||||||
import {
|
|
||||||
createLevelShell,
|
|
||||||
createRoomStateFromTemplate,
|
|
||||||
generateLevel1StartRoom,
|
|
||||||
generateRoomFromTable,
|
|
||||||
} from "./rooms";
|
|
||||||
|
|
||||||
function createSequenceRoller(values: number[]) {
|
|
||||||
let index = 0;
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
const next = values[index];
|
|
||||||
index += 1;
|
|
||||||
return next;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("room generation", () => {
|
|
||||||
it("creates the level 1 start room from its template", () => {
|
|
||||||
const result = generateLevel1StartRoom(sampleContentPack);
|
|
||||||
|
|
||||||
expect(result.templateSource).toBe("direct-template");
|
|
||||||
expect(result.room.roomClass).toBe("start");
|
|
||||||
expect(result.room.position).toEqual({ x: 0, y: 0 });
|
|
||||||
expect(result.room.exits).toHaveLength(1);
|
|
||||||
expect(result.room.exits[0]?.direction).toBe("north");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("generates a small room from the encoded small-room table", () => {
|
|
||||||
const result = generateRoomFromTable({
|
|
||||||
content: sampleContentPack,
|
|
||||||
roomId: "room.level1.small.001",
|
|
||||||
level: 1,
|
|
||||||
roomTableCode: "L1SR",
|
|
||||||
position: { x: 2, y: 1 },
|
|
||||||
roller: createSequenceRoller([5, 5]),
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(result.lookup?.roll.total).toBe(10);
|
|
||||||
expect(result.room.templateId).toBe("room.level1.small.heated-space");
|
|
||||||
expect(result.room.dimensions).toEqual({ width: 2, height: 3 });
|
|
||||||
expect(result.room.exits).toHaveLength(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("generates a large room from the encoded large-room table", () => {
|
|
||||||
const result = generateRoomFromTable({
|
|
||||||
content: sampleContentPack,
|
|
||||||
roomId: "room.level1.large.001",
|
|
||||||
level: 1,
|
|
||||||
roomTableCode: "L1LR",
|
|
||||||
position: { x: 4, y: 3 },
|
|
||||||
roller: createSequenceRoller([4, 4]),
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(result.lookup?.roll.total).toBe(8);
|
|
||||||
expect(result.room.templateId).toBe("room.level1.large.sparring-chamber");
|
|
||||||
expect(result.room.dimensions).toEqual({ width: 6, height: 6 });
|
|
||||||
expect(result.room.exits).toHaveLength(3);
|
|
||||||
expect(result.room.flags).toContain("large");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("respects explicit template exits when they are defined", () => {
|
|
||||||
const room = createRoomStateFromTemplate(
|
|
||||||
sampleContentPack,
|
|
||||||
"room.level1.custom.start",
|
|
||||||
1,
|
|
||||||
"room.level1.entry",
|
|
||||||
{ x: 0, y: 0 },
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(room.exits).toEqual([
|
|
||||||
expect.objectContaining({
|
|
||||||
direction: "north",
|
|
||||||
exitType: "door",
|
|
||||||
discovered: true,
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("creates a clean level shell for future dungeon state", () => {
|
|
||||||
const level = createLevelShell(1);
|
|
||||||
|
|
||||||
expect(level.themeName).toBe("The Entry");
|
|
||||||
expect(level.rooms).toEqual({});
|
|
||||||
expect(level.discoveredRoomOrder).toEqual([]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
import {
|
|
||||||
findRoomTemplateById,
|
|
||||||
findRoomTemplateForLookup,
|
|
||||||
findTableByCode,
|
|
||||||
} from "@/data/contentHelpers";
|
|
||||||
import type { ContentPack, ExitType, RoomClass } from "@/types/content";
|
|
||||||
import type { DungeonLevelState, RoomExitState, RoomState } from "@/types/state";
|
|
||||||
|
|
||||||
import { lookupTable, type TableLookupResult } from "./tables";
|
|
||||||
import type { DiceRoller } from "./dice";
|
|
||||||
|
|
||||||
export type RoomGenerationOptions = {
|
|
||||||
content: ContentPack;
|
|
||||||
roomId: string;
|
|
||||||
level: number;
|
|
||||||
roomTemplateId?: string;
|
|
||||||
roomTableCode?: string;
|
|
||||||
roomClass?: RoomClass;
|
|
||||||
position?: {
|
|
||||||
x: number;
|
|
||||||
y: number;
|
|
||||||
};
|
|
||||||
roller?: DiceRoller;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type RoomGenerationResult = {
|
|
||||||
room: RoomState;
|
|
||||||
lookup?: TableLookupResult;
|
|
||||||
templateSource: "direct-template" | "table-lookup";
|
|
||||||
};
|
|
||||||
|
|
||||||
const DEFAULT_ROOM_DIMENSIONS: Record<RoomClass, { width: number; height: number }> = {
|
|
||||||
start: { width: 4, height: 4 },
|
|
||||||
normal: { width: 4, height: 4 },
|
|
||||||
small: { width: 2, height: 3 },
|
|
||||||
large: { width: 6, height: 6 },
|
|
||||||
special: { width: 4, height: 4 },
|
|
||||||
stairs: { width: 4, height: 4 },
|
|
||||||
};
|
|
||||||
|
|
||||||
const DEFAULT_DIRECTIONS = ["north", "east", "south", "west"] as const;
|
|
||||||
|
|
||||||
function inferExitType(exitHint?: string): ExitType {
|
|
||||||
const normalized = exitHint?.toLowerCase() ?? "";
|
|
||||||
|
|
||||||
if (normalized.includes("reinforced")) {
|
|
||||||
return "locked";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (normalized.includes("curtain")) {
|
|
||||||
return "open";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (normalized.includes("archway")) {
|
|
||||||
return "open";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (normalized.includes("wooden")) {
|
|
||||||
return "door";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "door";
|
|
||||||
}
|
|
||||||
|
|
||||||
function inferExitCount(roomClass: RoomClass, exitHint?: string) {
|
|
||||||
const normalized = exitHint?.toLowerCase() ?? "";
|
|
||||||
|
|
||||||
if (normalized.includes("random")) {
|
|
||||||
return roomClass === "large" ? 3 : 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (normalized.includes("archway")) {
|
|
||||||
return roomClass === "large" ? 3 : 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (roomClass === "small") {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (roomClass === "large") {
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createExits(
|
|
||||||
roomId: string,
|
|
||||||
roomClass: RoomClass,
|
|
||||||
exitHint?: string,
|
|
||||||
): RoomExitState[] {
|
|
||||||
const exitCount = inferExitCount(roomClass, exitHint);
|
|
||||||
const exitType = inferExitType(exitHint);
|
|
||||||
|
|
||||||
return DEFAULT_DIRECTIONS.slice(0, exitCount).map((direction, index) => ({
|
|
||||||
id: `${roomId}.exit.${index + 1}`,
|
|
||||||
direction,
|
|
||||||
exitType,
|
|
||||||
discovered: roomClass === "start",
|
|
||||||
traversable: true,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createRoomStateFromTemplate(
|
|
||||||
content: ContentPack,
|
|
||||||
roomId: string,
|
|
||||||
level: number,
|
|
||||||
roomTemplateId: string,
|
|
||||||
position = { x: 0, y: 0 },
|
|
||||||
): RoomState {
|
|
||||||
const template = findRoomTemplateById(content, roomTemplateId);
|
|
||||||
const dimensions = template.dimensions ?? DEFAULT_ROOM_DIMENSIONS[template.roomClass];
|
|
||||||
const exits =
|
|
||||||
template.exits?.map((exit, index) => ({
|
|
||||||
id: `${roomId}.exit.${index + 1}`,
|
|
||||||
direction: exit.direction ?? DEFAULT_DIRECTIONS[index] ?? "north",
|
|
||||||
exitType: exit.exitType,
|
|
||||||
discovered: template.roomClass === "start",
|
|
||||||
traversable: exit.exitType !== "locked",
|
|
||||||
destinationLevel: exit.destinationLevel,
|
|
||||||
})) ?? createExits(roomId, template.roomClass, template.exitHint);
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: roomId,
|
|
||||||
level,
|
|
||||||
templateId: template.id,
|
|
||||||
position,
|
|
||||||
dimensions,
|
|
||||||
roomClass: template.roomClass,
|
|
||||||
exits,
|
|
||||||
discovery: {
|
|
||||||
generated: true,
|
|
||||||
entered: template.roomClass === "start",
|
|
||||||
cleared: false,
|
|
||||||
searched: false,
|
|
||||||
},
|
|
||||||
encounter: undefined,
|
|
||||||
objects: [],
|
|
||||||
notes: [template.text ?? template.title].filter(Boolean),
|
|
||||||
flags: [
|
|
||||||
`table:${template.tableCode}`,
|
|
||||||
`entry:${template.tableEntryKey}`,
|
|
||||||
...(template.unique ? ["unique"] : []),
|
|
||||||
...template.tags,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function generateRoomFromTable(
|
|
||||||
options: RoomGenerationOptions,
|
|
||||||
): RoomGenerationResult {
|
|
||||||
if (!options.roomTableCode) {
|
|
||||||
throw new Error("Room table code is required for table-based room generation.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const table = findTableByCode(options.content, options.roomTableCode);
|
|
||||||
const lookup = lookupTable(table, { roller: options.roller });
|
|
||||||
const template = findRoomTemplateForLookup(options.content, lookup);
|
|
||||||
const room = createRoomStateFromTemplate(
|
|
||||||
options.content,
|
|
||||||
options.roomId,
|
|
||||||
options.level,
|
|
||||||
template.id,
|
|
||||||
options.position,
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
room,
|
|
||||||
lookup,
|
|
||||||
templateSource: "table-lookup",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function generateLevel1StartRoom(
|
|
||||||
content: ContentPack,
|
|
||||||
roomId = "room.level1.start",
|
|
||||||
): RoomGenerationResult {
|
|
||||||
const room = createRoomStateFromTemplate(content, roomId, 1, "room.level1.entry", {
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
room,
|
|
||||||
templateSource: "direct-template",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createLevelShell(level: number): DungeonLevelState {
|
|
||||||
return {
|
|
||||||
level,
|
|
||||||
themeName: level === 1 ? "The Entry" : undefined,
|
|
||||||
rooms: {},
|
|
||||||
discoveredRoomOrder: [],
|
|
||||||
secretDoorUsed: false,
|
|
||||||
exhaustedExitSearch: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -159,15 +159,11 @@ export const exitTemplateSchema = z.object({
|
|||||||
export const roomTemplateSchema = z.object({
|
export const roomTemplateSchema = z.object({
|
||||||
id: z.string().min(1),
|
id: z.string().min(1),
|
||||||
level: z.number().int().positive(),
|
level: z.number().int().positive(),
|
||||||
sourcePage: z.number().int().positive().optional(),
|
|
||||||
roomClass: z.enum(["normal", "small", "large", "special", "start", "stairs"]),
|
roomClass: z.enum(["normal", "small", "large", "special", "start", "stairs"]),
|
||||||
tableCode: z.string().min(1),
|
tableCode: z.string().min(1),
|
||||||
tableEntryKey: z.string().min(1),
|
tableEntryKey: z.string().min(1),
|
||||||
title: z.string().min(1),
|
title: z.string().min(1),
|
||||||
text: z.string().optional(),
|
text: z.string().optional(),
|
||||||
encounterText: z.string().optional(),
|
|
||||||
exitHint: z.string().optional(),
|
|
||||||
unique: z.boolean().optional(),
|
|
||||||
dimensions: z
|
dimensions: z
|
||||||
.object({
|
.object({
|
||||||
width: z.number().int().positive(),
|
width: z.number().int().positive(),
|
||||||
|
|||||||
@@ -110,8 +110,6 @@ export const encounterStateSchema = z.object({
|
|||||||
id: z.string().min(1),
|
id: z.string().min(1),
|
||||||
sourceTableCode: z.string().optional(),
|
sourceTableCode: z.string().optional(),
|
||||||
creatureIds: z.array(z.string()),
|
creatureIds: z.array(z.string()),
|
||||||
creatureNames: z.array(z.string()).optional(),
|
|
||||||
resultLabel: z.string().optional(),
|
|
||||||
resolved: z.boolean(),
|
resolved: z.boolean(),
|
||||||
surprise: z.boolean().optional(),
|
surprise: z.boolean().optional(),
|
||||||
rewardPending: z.boolean().optional(),
|
rewardPending: z.boolean().optional(),
|
||||||
|
|||||||
@@ -165,15 +165,11 @@ export type RoomClass = "normal" | "small" | "large" | "special" | "start" | "st
|
|||||||
export type RoomTemplate = {
|
export type RoomTemplate = {
|
||||||
id: string;
|
id: string;
|
||||||
level: number;
|
level: number;
|
||||||
sourcePage?: number;
|
|
||||||
roomClass: RoomClass;
|
roomClass: RoomClass;
|
||||||
tableCode: string;
|
tableCode: string;
|
||||||
tableEntryKey: string;
|
tableEntryKey: string;
|
||||||
title: string;
|
title: string;
|
||||||
text?: string;
|
text?: string;
|
||||||
encounterText?: string;
|
|
||||||
exitHint?: string;
|
|
||||||
unique?: boolean;
|
|
||||||
dimensions?: {
|
dimensions?: {
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
|
|||||||
@@ -111,8 +111,6 @@ export type EncounterState = {
|
|||||||
id: string;
|
id: string;
|
||||||
sourceTableCode?: string;
|
sourceTableCode?: string;
|
||||||
creatureIds: string[];
|
creatureIds: string[];
|
||||||
creatureNames?: string[];
|
|
||||||
resultLabel?: string;
|
|
||||||
resolved: boolean;
|
resolved: boolean;
|
||||||
surprise?: boolean;
|
surprise?: boolean;
|
||||||
rewardPending?: boolean;
|
rewardPending?: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user