-
Hex Grid System (
GridManager.swift)- Axial coordinate system for hex tiles
- Pathfinding with A* algorithm
- Reachable tile calculations
- Circular grid layout (radius: 4)
-
Actor System (
Actor.swift,Hero.swift,Enemy.swift)- Base Actor class with HP, movement, attack stats
- Hero with defend ability and gold tracking
- Two enemy types: Grunt (5 HP, 2 damage) and Brute (14 HP, 4 damage)
- Visual HP display on all actors
- Status effects: shield, poison, stun
-
Combat Manager (
CombatManager.swift)- Turn-based combat flow
- Player phase → Enemy phase cycle
- Push mechanics on attacks
- Death handling and gold rewards
- Enemy AI decision making
-
Game Scene (
GameScene.swift)- Full tactical grid visualization
- Touch input for movement and attacks
- Tile highlighting for valid moves/attacks
- Game over and victory screens
- Restart functionality
-
HUD (
HUD.swift)- HP and Gold display
- Turn counter
- Action buttons (Attack, Defend, End Turn)
- Real-time stat updates
-
Player Turn:
- Tap tiles to move (green highlights show valid moves)
- Tap "⚔️ Attack" button, then tap enemy to attack
- Tap "🛡️ Defend" to add +3 shield and end turn
- Tap "End Turn" to skip to enemy phase
-
Enemy Turn:
- Enemies show intent indicators (⚔️ for attack, arrows for movement)
- Enemies move toward hero using pathfinding
- Enemies attack if in range
- Turn automatically returns to player
-
Win/Lose Conditions:
- Victory: All enemies defeated
- Defeat: Hero HP reaches 0
- Collect gold from defeated enemies
- Tap to restart after game ends
- Push System: Hero attacks push enemies 1 tile away
- Damage: Hero deals 3 damage, Grunts deal 2, Brutes deal 4
- Defend: Reduces next incoming damage and adds shield
- Shield: Absorbs damage before HP
- Movement: 1 tile per turn (can be upgraded later)
- Attack Range: Adjacent tiles only (melee)
- Blue Circle: Your Hero
- Red/Orange Circles: Enemies (Grunts/Brutes)
- Green Highlights: Valid movement tiles
- Red Highlights: Valid attack targets
- Numbers on Actors: Current HP (+ shield if any)
- Yellow Arrows: Enemy movement intent
- ⚔️ Icon: Enemy attack intent
Based on your spec, here are the next development priorities:
- Add weapon system (different attack patterns)
- Implement consumables (health potions, bombs)
- Add more enemy types with varied AI
- Cooldown-based special abilities
- Retreat bonus mechanic
- Level generator (procedural encounters)
- Shop system
- Relic/perk system
- Meta-progression (persistent unlocks)
- Multiple biomes/themes
- JSON-based enemy definitions
- External weapon/item configs
- Save/load system
- Debug console
- Better sprites and animations
- Sound effects and music
- Particle effects
- Tutorial system
- Settings menu
- Hero can move to adjacent tiles
- Hero can attack enemies
- Attacks push enemies backward
- Enemies move toward hero
- Enemies attack when adjacent
- HP tracking works correctly
- Game over triggers on hero death
- Victory triggers when all enemies dead
- Defend button grants shield
- Turn counter increments
- Gold awarded on enemy death
- Enemies always choose the shortest path
- Attack if in range, otherwise move closer
- Predictable for tactical planning
- Shows intent before acting
- Player action selection
- Action resolution (immediate)
- Enemy intent display (0.8s)
- Enemy actions execute (0.4s each)
- Status effects process
- Check win/lose conditions
- Next turn begins
Hero:
- HP: 12
- Movement: 1 tile
- Attack: 3 damage + push 1
- Defend: +3 shield
Grunt:
- HP: 5
- Movement: 1 tile
- Attack: 2 damage
Brute:
- HP: 14
- Movement: 1 tile
- Attack: 4 damage + push 1
Rewards:
- Grunt kill: 5 gold
- Brute kill: 15 gold
The code follows clean separation of concerns:
- GridManager: Pure logic, no rendering
- Actors: Data + minimal behavior
- CombatManager: Game rules & flow
- GameScene: Rendering & input
- HUD: UI only
This makes it easy to:
- Test individual systems
- Modify balance numbers
- Add new features
- Debug issues
- ECS-lite: Actors as components
- State Machine: Game phases (player/enemy/gameover)
- Command Pattern: Actions resolved through manager
- Observer: HUD updates on game state changes
- Factory: Enemy creation by type