Skip to main content

Battle Flow

Guide

Move from Encounter initialization into the player decision and enemy Intent loop, then continue until rewards or defeat resolve

Starting a GameEncounter converts authored definitions into an interactive live battle state, then alternates control of the battlefield between the player and enemies until the battle reaches a clear result.

The diagram above expands a battle into a continuous loop. The Encounter first defines the participants and rules, each phase then assigns a clear responsibility to the player, enemies, or runtime, and every resolution decides whether the loop continues or moves to its final result.

Encounter generation: from static configuration to a live battlefield

GameEncounter connects authored configuration to runtime. It loads the player data, enemy lineup, reward deck, and any special Battle Rules. The battle scene supplies the Manager, Bootstrap, board, hand area, HUD, and presentation references required at runtime.

During initialization, the system:

  • Creates runtime unit state and card instances.

  • Draws and prepares the player's opening hand.

  • Plans the enemies' first-turn intents.

The player now has the current HP, energy, hand, legal targets, and enemy threats needed for a complete decision.

💡 Database Management explains how authored definitions enter the discovery scope. Runtime Data Types explains how they create independent state for the current battle.

Alternating player and enemy phases

PhaseResult visible to the playerRule location
PlayerTurnStartArmor, energy, statuses, card behavior, and draw rules prepare the next decisionStatus and Card timing entries, Hooks, and Encounter Battle Rules
PlayerPhaseThe player reads the battlefield, pays energy, selects a target, and plays a cardCard fields, Card Behavior, and current battle state
PlayerTurnEndThe decision window closes while remaining cards, statuses, and temporary rules continue resolvingCard and Status turn-end behaviors and Battle Rules
EnemyPhaseEach living enemy executes the Intent shown earlier, then plans its next actionEnemy Intent Pattern, Enemy Behavior, and Status timing
tip

Because the opening hand is generated and filled during initialization, turn 1 skips the normal per-turn draw step. Starting with turn 2, the system returns to PlayerTurnStart and performs the regular draw only after every living enemy has finished acting.

Victory, defeat, and interception

At predefined checkpoints during battle, the system evaluates the result: defeating all required enemies produces victory, while reducing the player's HP to zero produces defeat.

To prevent presentation from tearing or low-level logic from conflicting, this result is not applied abruptly. It follows these interception rules:

  • Deferred transition: If effects or action animations are still running through a Gate, or a Choice still requires live player input, the system suspends result resolution and keeps the current Phase.
  • Safe completion: The Phase changes and the final result is declared only after all presentation and player interaction have finished and the system reaches a safe state.

Post-battle resolution

  • Victory: After victory, the system draws content from the Reward Deck configured on the Encounter and opens the loot or three-card reward screen.
  • Defeat: The system skips the reward flow and enters the death or defeat results panel directly.

💡 Quick Start To experience this complete turn loop and post-battle reward flow, see Your First Battle.