A graph-based game map editor for creating dungeon layouts with monsters and rooms.
- Graph-based map generation with configurable depth (1-10 levels)
- Shared goal nodes - multiple paths can lead to the same destination
- Dynamic monster loading via GraphQL with difficulty scaling by depth
- Interactive editing mode - add/remove connections between nodes visually
- Smart node positioning - automatic layout with parent-child centering
- Zoom controls - zoom from 10% to 200% for easy navigation
- Save/Load - export and import maps as JSON files with validation
- Visual feedback - color-coded nodes by monster type and edit mode
- Comprehensive test suite - 95%+ code coverage with unit and integration tests
The application requires a GraphQL endpoint for monster data. Set the endpoint URL in your environment:
NEXT_PUBLIC_GRAPHQL_URL=http://localhost:42069/graphql
npm install
npm run dev
Open http://localhost:3000 in your browser.
npm run build
npm start
- Generate a Map: Set the desired depth and click "Generate Map"
- Select a Node: Click any node to select it and view its properties
- Edit Children Mode: Toggle "Edit Children Mode" to modify connections
- Add/Remove Connections: In edit mode, click nodes to add/remove them as children
- Add New Nodes: Use the "Add Node" button to create new goal nodes
- Change Monster Type: Select different monsters for battle nodes
- Navigate: Use zoom controls to view large maps easily
- Save/Load: Export your map as JSON or import existing maps
Each node in the graph contains:
id
: Unique identifier (sequential starting from 1)roomType
: Integer enum (0=NULL, 1=BATTLE, 2=GOAL)monsterIndex1
: Monster index (16-bit unsigned integer) or null for non-battle roomsnextRooms
: Array of 6 room IDs (0 means no connection)
Room types:
- NULL (0): Starting nodes with no monsters
- BATTLE (1): Combat rooms with monsters (1-6 connections)
- GOAL (2): End rooms with no monsters or connections
The map data follows a strict schema defined in public/map-schema.json
. This ensures data integrity when loading maps and provides validation for external tools.
Run the comprehensive test suite:
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watch
The test suite includes:
- Unit tests for all core modules
- Integration tests for graph operations
- End-to-end tests covering the full generate→edit→save→load workflow
- 95%+ code coverage ensuring reliability
The codebase is organized into clean, testable modules:
lib/types.ts
- Core data structures and MapNode classlib/graph-operations.ts
- Graph traversal and manipulationlib/map-generator.ts
- Map generation logiclib/serialization.ts
- Save/load operationslib/validator.ts
- JSON schema validationcomponents/MapEditor.tsx
- React UI component