mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-03-22 07:07:24 +01:00
docs: update contribution guidelines and clarify project architecture
This commit is contained in:
parent
6ea53eb6f9
commit
3f9a7702d4
2 changed files with 53 additions and 94 deletions
131
.github/copilot-instructions.md
vendored
131
.github/copilot-instructions.md
vendored
|
|
@ -1,118 +1,65 @@
|
|||
# Fantasy Map Generator
|
||||
|
||||
Azgaar's Fantasy Map Generator is a web application for creating fantasy maps. It generates detailed fantasy worlds with countries, cities, rivers, biomes, and cultural elements.
|
||||
Azgaar's Fantasy Map Generator is a client-only web application for creating fantasy maps. It generates detailed fantasy worlds with countries, cities, rivers, biomes, and cultural elements.
|
||||
|
||||
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
|
||||
Always reference these instructions first.
|
||||
|
||||
## Working Effectively
|
||||
# Architecture
|
||||
|
||||
- The project uses NPM, Vite, and TypeScript for development and building.
|
||||
- **Setup**: Run `npm install` to install dependencies (requires Node.js >= 24.0.0)
|
||||
- **Development**: Run `npm run dev` to start the Vite development server
|
||||
- Access at: `http://localhost:5173` (Vite's default port)
|
||||
- Hot module replacement (HMR) enabled - changes are reflected immediately
|
||||
- **Building**: Run `npm run build` to compile TypeScript and build for production
|
||||
- TypeScript compilation runs first (`tsc`)
|
||||
- Vite builds the application to `dist/` directory
|
||||
- **Preview**: Run `npm run preview` to preview the production build locally
|
||||
The codebase is gradually transitioning from **vanilla JavaScript to TypeScript** while maintaining compatibility with the existing generation pipeline and legacy `.map` user files.
|
||||
|
||||
## Validation
|
||||
The expected **future architecture** is based on a separation between **world data**, **procedural generation**, **interactive editing**, and **rendering**.
|
||||
|
||||
- Always manually validate any changes by:
|
||||
1. Run `npm run dev` to start the development server (wait for "ready" message)
|
||||
2. Navigate to the application in browser (typically `http://localhost:5173`)
|
||||
3. Click the "►" button to open the menu and generate a new map
|
||||
4. **CRITICAL VALIDATION**: Verify the map generates with countries, cities, roads, and geographic features
|
||||
5. Test UI interaction: click "Layers" button, verify layer controls work
|
||||
6. Test regeneration: click "New Map!" button, verify new map generates correctly
|
||||
- **Known Issues**: Google Analytics and font loading errors are normal (blocked external resources)
|
||||
- For production build validation: run `npm run build` followed by `npm run preview`
|
||||
The application is conceptually divided into four main layers:
|
||||
|
||||
## Repository Structure
|
||||
- **State** — world data and style configuration, the single source of truth
|
||||
- **Generators** — procedural world simulation (model)
|
||||
- **Editors** — user-driven mutations of the world state (controllers)
|
||||
- **Renderer** — map visualization (view)
|
||||
|
||||
### Core Files
|
||||
Flow:
|
||||
settings → generators → world data → renderer
|
||||
UI → editors → world data → renderer
|
||||
|
||||
- `package.json` - NPM package configuration with scripts and dependencies
|
||||
- `vite.config.ts` - Vite build configuration
|
||||
- `tsconfig.json` - TypeScript compiler configuration
|
||||
### Layer responsibilities
|
||||
|
||||
### Source Directories
|
||||
**State (world data)**
|
||||
Stores all map data and style configuration.
|
||||
The data layer must contain **no logic and no rendering code**.
|
||||
|
||||
- `src/` - Source code directory (build input)
|
||||
- `src/index.html` - Main application entry point
|
||||
- `src/utils/` - TypeScript utility modules (migrated from JS)
|
||||
- `public/` - Static assets (copied to build output)
|
||||
- `public/main.js` - Core application logic
|
||||
- `public/versioning.js` - Version management and update handling
|
||||
- `public/modules/` - Core functionality modules:
|
||||
- `modules/ui/` - UI components (editors, tools, style management)
|
||||
- `modules/dynamic/` - runtime modules (export, installation)
|
||||
- `modules/renderers/` - drawing and rendering logic
|
||||
- `public/styles/` - Visual style presets (JSON files)
|
||||
- `public/libs/` - Third-party libraries (D3.js, TinyMCE, etc.)
|
||||
- `public/images/` - Backgrounds, UI elements
|
||||
- `public/charges/` - Heraldic symbols and coat of arms elements
|
||||
- `public/config/` - Heightmap templates and configurations
|
||||
- `public/heightmaps/` - Terrain generation data
|
||||
- `dist/` - Production build output (generated by `npm run build`)
|
||||
**Generators**
|
||||
Implement the procedural world simulation and populate or update world data based on generation settings.
|
||||
|
||||
## Common Tasks
|
||||
**Editors**
|
||||
Implement interactive editing tools used by the user.
|
||||
Editors perform controlled mutations of the world state and can be viewed as **interactive generators**.
|
||||
|
||||
### Making Code Changes
|
||||
**Renderer**
|
||||
Converts the world state into **SVG or WebGL graphics**.
|
||||
Rendering must be a **pure visualization step** and must **not modify world data**.
|
||||
|
||||
1. **TypeScript files** (`src/utils/*.ts`):
|
||||
- Edit TypeScript files in the `src/utils/` directory
|
||||
- Changes are automatically recompiled and hot-reloaded in dev mode
|
||||
- Run `npm run build` to verify TypeScript compilation succeeds
|
||||
2. **JavaScript files** (`public/*.js`, `public/modules/*.js`):
|
||||
- Edit JavaScript files directly in the `public/` directory
|
||||
- Changes are automatically reflected in dev mode via HMR
|
||||
- **Note**: Core application logic is still in JavaScript and gradually being migrated
|
||||
3. **Always test map generation** after making changes
|
||||
4. Update version in `public/versioning.js` for all changes
|
||||
5. For production builds, update file hashes in `src/index.html` if needed (format: `file.js?v=1.108.1`)
|
||||
# Working Effectively
|
||||
|
||||
### Debugging Map Generation
|
||||
The project uses **NPM**, **Vite**, and **TypeScript** for development and building.
|
||||
|
||||
- Open browser developer tools console
|
||||
- Look for timing logs, e.g. "TOTAL: ~0.76s"
|
||||
- Map generation logs show each step (heightmap, rivers, states, etc.)
|
||||
- Error messages will indicate specific generation failures
|
||||
## Setup
|
||||
|
||||
### Testing Different Map Types
|
||||
Install dependencies: `npm install`
|
||||
|
||||
- Use "New Map!" button for quick regeneration
|
||||
- Access "Layers" menu to change map visualization
|
||||
- Available presets: Political, Cultural, Religions, Biomes, Heightmap, Physical, Military
|
||||
Requirements: Node.js **>= 24.0.0**
|
||||
|
||||
## Troubleshooting
|
||||
## Development
|
||||
|
||||
### Application Won't Load
|
||||
Start the development server: `npm run dev`
|
||||
|
||||
- Run `npm install` to ensure dependencies are installed
|
||||
- Run `npm run dev` to start the development server
|
||||
- Check console for JavaScript/TypeScript errors
|
||||
- Verify all files are present in repository
|
||||
- Ensure Node.js version >= 24.0.0 (`node --version`)
|
||||
Access the application at: http://localhost:5173
|
||||
|
||||
### Build Failures
|
||||
## Build
|
||||
|
||||
- Check TypeScript compilation errors (`tsc` output)
|
||||
- Verify all dependencies are installed (`npm install`)
|
||||
- Check `tsconfig.json` for configuration issues
|
||||
- Look for import/module resolution errors
|
||||
Create a production build: `npm run build`
|
||||
|
||||
### Map Generation Fails
|
||||
Build steps:
|
||||
|
||||
- Check browser console for error messages
|
||||
- Look for specific module failures in generation logs
|
||||
- Try refreshing page and generating new map
|
||||
- Verify build completed successfully if using production build
|
||||
|
||||
### Performance Issues
|
||||
|
||||
- Map generation should complete in ~1 second for standard configurations
|
||||
- If slower, check browser console for errors
|
||||
- Development mode may be slower due to HMR overhead
|
||||
|
||||
Remember: This is a sophisticated application that generates complete fantasy worlds with political systems, geography, cultures, and detailed cartographic elements. The project is gradually migrating from vanilla JavaScript to TypeScript. Always validate that your changes preserve the core map generation functionality.
|
||||
1. TypeScript compilation (`tsc`)
|
||||
2. Vite build
|
||||
3. Output written to `dist/`
|
||||
|
|
|
|||
16
README.md
16
README.md
|
|
@ -16,8 +16,6 @@ Join our [Discord server](https://discordapp.com/invite/X7E84HU) and [Reddit com
|
|||
|
||||
Contact me via [email](mailto:azgaar.fmg@yandex.com) if you have non-public suggestions. For bug reports please use [GitHub issues](https://github.com/Azgaar/Fantasy-Map-Generator/issues) or _#fmg-bugs_ channel on Discord. If you are facing performance issues, please read [the tips](https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Tips#performance-tips).
|
||||
|
||||
Pull requests are highly welcomed. The codebase is messy and requires re-design. I will appreciate if you start with minor changes. Check out the [data model](https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Data-model) before contributing.
|
||||
|
||||
You can support the project on [Patreon](https://www.patreon.com/azgaar).
|
||||
|
||||
_Inspiration:_
|
||||
|
|
@ -27,3 +25,17 @@ _Inspiration:_
|
|||
- Amit Patel's [_Polygonal Map Generation for Games_](http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation)
|
||||
|
||||
- Scott Turner's [_Here Dragons Abound_](https://heredragonsabound.blogspot.com)
|
||||
|
||||
## Contribution
|
||||
|
||||
Pull requests are highly welcomed. The codebase is messy and I will appreciate if you start with minor changes. Check out the [data model](https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Data-model) before contributing.
|
||||
|
||||
The codebase is gradually transitioning from **vanilla JavaScript to TypeScript** while maintaining compatibility with the existing generation pipeline and old `.map` user files.
|
||||
|
||||
The expected **future** architecture is based on a separation between **world data**, **procedural generation**, **interactive editing**, and **rendering**. The application is conceptually divided into four main layers: world data and styles (state), generators (model), editors (controllers), renderers (view).
|
||||
|
||||
Flow:
|
||||
settings → generators → world data → renderer
|
||||
UI → editors → world data → renderer.
|
||||
|
||||
The data layer must contain no logic and no rendering code. Generators implement the procedural world simulation. Editors implement interactive editing tools used by the user. They perform controlled mutations of the world state. Editors can be viewed as interactive generators. The renderer converts the world state into SVG or WebGl graphics. Renderer must be pure visualization step and not modify world data.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue