Engine > Phases > Entity Command Phase

Active when a commandable entity is selected. Left click resolves as move or attack depending on the target tile. Right click and SELECTION_CANCEL cancel. TOWER_PLACEMENT_SELECT and TURN_END interrupt and forward to IDLE.

#handlePointerLeftDown

Resolves a left click as either a move or an attack. If the tile is empty and reachable, delegates to #handleMove. Otherwise checks if the tile is a valid attack target and delegates to #handleAttack.

#handleAttack

Executes the attack via CombatSystem and appends GAME_WIN if no bot units remain.

#handleMove

Executes a unit move: mutates position, spends AP, and returns ENTITY_MOVED.

#handlePostMove

After a move, updates the active entity highlight to the new tile. If the unit can no longer act, transitions to ENTITY_SELECT. Otherwise emits HIGHLIGHT_ENTITY_COMMAND, GHOST_TARGET_ATTACK if attacks remain, and ENTITY_PATHFINDER_ACTIVATE if movement remains.

#handlePostAction

Shared post-action handler for both attack and move. Checks remaining AP and available attacks to determine if the entity can still act. If exhausted, auto-selects the next actionable entity or falls back to ENTITY_SELECT if none remain.

#handleCancel

Cancels the active unit command. Clears the active entity, returns to IDLE, and restores HIGHLIGHT_ENTITY_COMMAND for any units that still have actions available this turn.




© Gamesanova 2026