Skip to content

Commit 1cdc0f4

Browse files
committed
Added Github action and readme badge
1 parent a34fe49 commit 1cdc0f4

14 files changed

Lines changed: 6488 additions & 415 deletions

.github/workflows/tests.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, master, develop ]
6+
pull_request:
7+
branches: [ main, master, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [18.x, 20.x]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'npm'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Run tests
30+
run: npm test
31+
32+
- name: Run tests with coverage
33+
run: npm run test:coverage
34+
35+
- name: Upload coverage reports to Codecov
36+
if: matrix.node-version == '20.x'
37+
uses: codecov/codecov-action@v3
38+
with:
39+
file: ./coverage/lcov.info
40+
flags: unittests
41+
name: codecov-umbrella
42+
fail_ci_if_error: false

README.md

Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
# Game Map Editor
22

3-
A tree-based game map editor for creating dungeon layouts with monsters and rooms.
3+
[![Tests](https://github.com/brendanasselstine/map-maker/actions/workflows/tests.yml/badge.svg)](https://github.com/brendanasselstine/map-maker/actions/workflows/tests.yml)
4+
5+
A graph-based game map editor for creating dungeon layouts with monsters and rooms.
46

57
## Features
68

7-
- **Tree-based map generation** with configurable depth (1-10 levels)
9+
- **Graph-based map generation** with configurable depth (1-10 levels)
10+
- **Shared goal nodes** - multiple paths can lead to the same destination
811
- **Monster types** with difficulty scaling by depth:
912
- Goblin (easiest, blue)
1013
- Thicc Goblin (orange)
1114
- Troll (red)
1215
- Orc (hardest, purple)
13-
- **Interactive editing** - click nodes to modify door counts and monster types
16+
- **Interactive editing mode** - add/remove connections between nodes visually
17+
- **Smart node positioning** - automatic layout with parent-child centering
1418
- **Zoom controls** - zoom from 10% to 200% for easy navigation
15-
- **Save/Load** - export and import maps as JSON files
16-
- **Visual feedback** - color-coded nodes by monster type
19+
- **Save/Load** - export and import maps as JSON files with validation
20+
- **Visual feedback** - color-coded nodes by monster type and edit mode
21+
- **Comprehensive test suite** - 95%+ code coverage with unit and integration tests
1722

1823
## Getting Started
1924

@@ -36,22 +41,59 @@ npm start
3641
## How to Use
3742

3843
1. **Generate a Map**: Set the desired depth and click "Generate Map"
39-
2. **Edit Nodes**: Click any node to select it and modify its properties
40-
3. **Change Door Count**: Adjusts the number of child nodes (1-4)
41-
4. **Change Monster Type**: Select different monsters for any node (including root)
42-
5. **Navigate**: Use zoom controls to view large maps easily
43-
6. **Save/Load**: Export your map as JSON or import existing maps
44+
2. **Select a Node**: Click any node to select it and view its properties
45+
3. **Edit Children Mode**: Toggle "Edit Children Mode" to modify connections
46+
4. **Add/Remove Connections**: In edit mode, click nodes to add/remove them as children
47+
5. **Add New Nodes**: Use the "Add Node" button to create new goal nodes
48+
6. **Change Monster Type**: Select different monsters for battle nodes
49+
7. **Navigate**: Use zoom controls to view large maps easily
50+
8. **Save/Load**: Export your map as JSON or import existing maps
4451

4552
## Map Structure
4653

47-
Each node in the tree contains:
48-
- `id`: Unique identifier
49-
- `depth`: Level in the tree (0 for root)
50-
- `roomType`: Either "ROOT" or "MONSTER"
51-
- `doorCount`: Number of child nodes (0-4)
52-
- `monsterIndex1`: Monster type (can be any monster type or null for root nodes)
53-
- `children`: Array of child nodes
54+
Each node in the graph contains:
55+
- `id`: Unique identifier (sequential starting from 1)
56+
- `roomType`: Integer enum (0=NULL, 2=BATTLE, 3=GOAL)
57+
- `monsterIndex1`: Monster type string or null for non-battle rooms
58+
- `nextRooms`: Array of 7 room IDs (0 means no connection)
59+
60+
Room types:
61+
- **NULL (0)**: Starting nodes with no monsters
62+
- **BATTLE (2)**: Combat rooms with monsters (1-4 connections)
63+
- **GOAL (3)**: End rooms with no monsters or connections
5464

5565
## JSON Schema
5666

57-
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.
67+
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.
68+
69+
## Testing
70+
71+
Run the comprehensive test suite:
72+
73+
```bash
74+
# Run all tests
75+
npm test
76+
77+
# Run tests with coverage
78+
npm run test:coverage
79+
80+
# Run tests in watch mode
81+
npm run test:watch
82+
```
83+
84+
The test suite includes:
85+
- **Unit tests** for all core modules
86+
- **Integration tests** for graph operations
87+
- **End-to-end tests** covering the full generate→edit→save→load workflow
88+
- **95%+ code coverage** ensuring reliability
89+
90+
## Architecture
91+
92+
The codebase is organized into clean, testable modules:
93+
94+
- `lib/types.ts` - Core data structures and MapNode class
95+
- `lib/graph-operations.ts` - Graph traversal and manipulation
96+
- `lib/map-generator.ts` - Map generation logic
97+
- `lib/serialization.ts` - Save/load operations
98+
- `lib/validator.ts` - JSON schema validation
99+
- `components/MapEditor.tsx` - React UI component

0 commit comments

Comments
 (0)