Tactical and turn-based games (grid tactics like XCOM / Fire Emblem / Into the Breach, hex strategy, 4X-lite, turn-based RPG battles). Turn and phase structure, action points, movement range with weighted pathfinding, attack ranges and line of sight, hit chance and damage forecasts, cover and terrain, enemy AI that scores moves, undo, animation queues separate from rules, deterministic game sta...
Download skill (.zip) Files on GitHubTurn-based strategy
Core: meaningful decisions with full information (or calculated risk), one move at a time.
Starter template
A playable starter for the game-scaffolding template is in assets/starter/. Grid tactics: terrain costs and defense, movement range (Dijkstra), melee and ranged attack ranges, damage forecast with counterattacks, undo move, end turn, and an enemy AI that scores every reachable tile.
python3 <game-scaffolding>/scripts/scaffold.py my-game --title "My Game" --starter <this skill>/assets/starter
Controls: Tap a unit, then a blue tile to move or a red enemy to attack. Keys: arrows + Enter, C cancel, Q wait, Z undo, E end turn. Esc pauses. All numbers to tune are in src/config.js; the gameplay is in src/scenes/play.js.
Selection, movement, undo, the enemy turn and a multi-round battle were tested with a bot.
Architecture that makes it easy
- Pure game state + rules (no rendering inside):
state = applyAction(state, action). Undo = keep previous states; saves = serialize state; AI = try actions on copies. Unit-test the rules in node. - Presentation layer plays an animation queue from the action results (“move along path”, “attack”, “die”), and input is blocked until the queue finishes.
- Turn flow: player phase → enemy phase (or initiative order), each unit with action points (move + act).
Growing the starter (tested modules)
- Grid (or hex) map with terrain costs; movement range = Dijkstra up to the unit’s points (pathfinding
flowFieldfrom the unit with a distance cap, orastarper hovered tile for the path preview). - Attack range +
lineOfSight(pathfinding) for ranged units; cover reduces hit chance. - Forecast: before confirming, show hit %, damage, and the counterattack. Use a seeded rng (procedural-generation
rng) so reloading doesn’t reroll (no save-scumming, if you want that). - Enemy AI: for each unit, score candidate (move, action) pairs: damage dealt, kills, danger at the destination, objective
progress; pick the best with a little randomness (enemy-ai
chooseActionidea). - Undo last move (until an action with randomness is taken).
Design
- Few, distinct unit types with clear counters. Show every number the player needs. Telegraph enemy intents (Into the Breach style) for puzzle-like tactics.
- Short battles (5–15 minutes on the web). Objectives beyond “kill all” (escape, defend, rescue).
UI
Tap / click a unit → highlighted move tiles (blue) and attack tiles (red) → tap a tile → confirm. Big tiles on phones (≥ 44 px), an End turn button, and a turn indicator. Keyboard: arrows to move a cursor, Enter confirm, Esc cancel, Tab next unit.
Pitfalls
Rules tangled with animations (bugs with undo and saves), hidden math, AI that’s slow on big maps (limit search, stagger), and long enemy turns (speed up animations, allow skipping).