Add campaign shell and map generation recovery

This commit is contained in:
Keith Solomon
2026-03-18 21:35:53 -05:00
parent bcd720cae8
commit 37e2b27870
11 changed files with 1012 additions and 64 deletions
+14 -1
View File
@@ -40,6 +40,18 @@ const DEFAULT_ROOM_DIMENSIONS: Record<RoomClass, { width: number; height: number
const DEFAULT_DIRECTIONS = ["north", "east", "south", "west"] as const;
function getDirectionSeed(roomId: string) {
return Array.from(roomId).reduce((total, char) => total + char.charCodeAt(0), 0);
}
function getDirectionOrder(roomId: string) {
const rotation = getDirectionSeed(roomId) % DEFAULT_DIRECTIONS.length;
return [
...DEFAULT_DIRECTIONS.slice(rotation),
...DEFAULT_DIRECTIONS.slice(0, rotation),
];
}
function inferExitType(exitHint?: string): ExitType {
const normalized = exitHint?.toLowerCase() ?? "";
@@ -91,8 +103,9 @@ function createExits(
): RoomExitState[] {
const exitCount = inferExitCount(roomClass, exitHint);
const exitType = inferExitType(exitHint);
const directionOrder = getDirectionOrder(roomId);
return DEFAULT_DIRECTIONS.slice(0, exitCount).map((direction, index) => ({
return directionOrder.slice(0, exitCount).map((direction, index) => ({
id: `${roomId}.exit.${index + 1}`,
direction,
exitType,