Files
hexifyer/core/terrain.ts
Axel Meyer f302932ea8 Phase 1: Core hex engine, Leaflet overlay, terrain painting UI
- core/: Pure TS hex engine (axial coords, hex grid, terrain types,
  edge connectivity with constraint solver, HexMap state model)
- src/map/: Leaflet L.CRS.Simple map init, Canvas-based hex overlay
  layer (L.GridLayer), click/edge interaction detection
- src/ui/: Sidebar with toolbar (Select/Paint/Feature modes),
  terrain picker, hex inspector, map settings (hex size, grid, opacity)
- pipeline/: Tile pyramid generator (sharp, from source image)
- tests/: 32 passing tests for coords, hex-grid, edge-connectivity
- Uses Kiepenkerl tiles (symlinked) for development

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 10:32:52 +00:00

37 lines
1.7 KiB
TypeScript

import type { TerrainType } from './types.js';
export const TERRAIN_TYPES: TerrainType[] = [
// Area fills (drawn first, below linear features)
{ id: 'ocean', name: 'Ocean/Sea', category: 'area', color: '#2a5574', zIndex: 0 },
{ id: 'lake', name: 'Lake', category: 'area', color: '#4a90c4', zIndex: 1 },
{ id: 'plains', name: 'Plains', category: 'area', color: '#c4b060', zIndex: 2 },
{ id: 'farmland', name: 'Farmland', category: 'area', color: '#a4c639', zIndex: 3 },
{ id: 'forest', name: 'Forest', category: 'area', color: '#2d6a2d', zIndex: 4 },
{ id: 'hills', name: 'Hills', category: 'area', color: '#8a7a5a', zIndex: 5 },
{ id: 'mountains', name: 'Mountains', category: 'area', color: '#6a6a6a', zIndex: 6 },
{ id: 'settlement', name: 'Settlement', category: 'area', color: '#8b4513', zIndex: 7 },
// Linear features (drawn on top, have edge connectivity)
{ id: 'river', name: 'River', category: 'linear', color: '#2a7fff', zIndex: 10 },
{ id: 'road', name: 'Road', category: 'linear', color: '#a0522d', zIndex: 11 },
{ id: 'coastline', name: 'Coastline', category: 'linear', color: '#1a4a6a', zIndex: 12 },
];
const terrainMap = new Map<string, TerrainType>(
TERRAIN_TYPES.map(t => [t.id, t]),
);
export function getTerrainType(id: string): TerrainType | undefined {
return terrainMap.get(id);
}
export function getAreaTerrains(): TerrainType[] {
return TERRAIN_TYPES.filter(t => t.category === 'area');
}
export function getLinearTerrains(): TerrainType[] {
return TERRAIN_TYPES.filter(t => t.category === 'linear');
}
/** Default terrain for unpainted hexes */
export const DEFAULT_BASE_TERRAIN = 'plains';