2.6 KiB
2.6 KiB
Implementation Plan - Phase 1: Dungeon Generation
Goal Description
Build a robust, data-driven procedural dungeon generator that supports campaign-specific requirements (custom exits vs. objective rooms). This logic will be decoupled from the 3D visualization to ensure testability.
Architecture
The engine will consist of three main components:
- Tile Registry: Definitions of all available board sections (Rooms, Corridors, T-Junctions, Corners).
- Dungeon Deck: A deck manager that handles the probability of drawing specific room types.
- Generator Core: The state machine that places tiles on a virtual grid.
User Review Required
Important
Campaign Logic Deviation: The rulebook specifies random dungeons. We are implementing a constrained "Mission" system where:
- Current functionality must support "Forced Exits" after X tiles for early campaign missions.
- Final missions revert to standard "Objective Room" search.
Proposed Changes
[NEW] src/engine/dungeon/
We will structure the engine purely in JS logic first.
[NEW] TileDefinitions.js
- Data Structure:
{ id: 'corridor_straight', type: 'corridor', // 'room', 'objective' width: 2, length: 5, exits: [ {x:0, y:0, dir:'N'}, ... ] // Local coords }
[NEW] DungeonDeck.js
- Handles the stack of cards.
- Methods:
draw(),shuffle(),insert(card, position). - Campaign Injection: Ability to inject specific "Events" or "Rooms" at certain deck depths (e.g., "After 10 cards, shuffle the Exit card into the top 3").
[NEW] Generator.js
- Grid System: A virtual 2D array or Map
Map<"x,y", TileID>to track occupancy. - Algorithm:
- Place Entry Room at (0,0).
- Add Entry Exits to
OpenExitsList. - Step:
- Pick an Exit from
OpenExitsList. - Draw Card from
DungeonDeck. - Attempt to place Tile at Exit.
- IF Collision: Discard and try alternative (or end path).
- IF Success: Register Tile, Remove used Exit, Add new Exits.
- Pick an Exit from
Campaign Integration
- Mission Config Payload:
{ missionId: "campaign_1_mission_1", deckComposition: [ ... ], specialRules: { forceExitAfter: 10, // Logic: Treat specific room as 'Objective' for generation purposes exitType: "ladder_room" } }
Verification Plan
Automated Tests
- Unit Tests: Verify
Generatorcan place tiles without overlapping. - Logic Tests: Verify "Exit functionality" triggers correctly after N tiles.