# Gameplay TODO ## Target-gated Repentance/Instinct resolution ### Problem Repentance and Instinct are resolved through `EffectsJson` action lists. Some actions can be defined with explicit target selectors (`Player`, `Tile`, `Spirit`, `ArchSpirit`, `Ruin`, etc.). If an action semantically requires a target, allowing the card to resolve without one can produce ambiguous or unintended behavior (silent no-op, wrong implicit target, or inconsistent rules enforcement). ### Why this matters - **Rules integrity:** cards that say "choose a target" must not resolve without a legal choice. - **Determinism:** server-side resolution should be unambiguous and reproducible. - **Client UX:** players should get a clear validation error instead of a partial/quiet mis-resolution. - **Future-proofing:** as more conditional and chained actions are added, implicit target fallbacks become high-risk. ### Current state - `ChannelCard` now enforces `CanChannel*` restrictions (including `CanChannelRepentance` and `CanChannelInstinct`). - Instinct is now quick-play (any turn except Setup/Placement/GameOver). - Ability model supports explicit target types and per-action target indexing. - `SearchDeckEffect` is declared in effect models but currently missing server-side execution in `AbilitySystem.ExecuteEffect` (see `gameplay-effects-gap.md`). ### Required fix Add strict server-side target validation for Repentance/Instinct action execution: 1. **Per action**, determine whether target input is mandatory from `TargetSelector`: - mandatory: specific target type with `Count.N > 0` and not `All`, not `UpTo` - optional: `All == true` or `UpTo == true` where fewer than `N` is allowed 2. If mandatory and no matching client target(s) are supplied, reject play (`INSUFFICIENT_TARGETS` or equivalent). 3. Validate target kind compatibility: - `Tile` actions require `Coord` - unit/card/player actions require `InstanceId` (or player resolution contract) 4. Validate ownership/scope/filter legality during resolution (already mostly present) and return explicit error on mismatch. 5. Keep behavior deterministic for multi-action cards: each action uses `ActionIndex`-scoped targets only. ### Acceptance criteria - A Repentance/Instinct card with required targets cannot resolve without valid target payload. - Invalid target payload fails with explicit error. - Optional-target actions still resolve when legal to do so. - Existing non-targeted Repentance/Instinct cards continue to work unchanged. --- ## Aura transition walkthrough scenario (movement) Goal scenario: "A spirit moves on the battlefield and another spirit enters its aura range." ### Current flow in engine 1. `GameEngine.MoveUnit(...)` validates movement/path/MP. 2. Unit position is updated on board. 3. `AbilitySystem.EvaluateAuraTransitions(state, movingUnitId, from, to)` runs. 4. System checks both: - stationary aura units vs moving unit transition - moving unit's own aura vs stationary units 5. If range crossing occurs: - outside -> inside => `EnterAuraRange` trigger fires - inside -> outside => `LeaveAuraRange` trigger fires 6. Triggered abilities are evaluated via `FireTrigger(...)` and matching triggered actions execute. ### Test case outline - Place Aura Spirit A (with AuraRange 1..1 and an `OnEnterAuraRange` trigger). - Place Spirit B outside A's range. - Move B one tile so Manhattan distance to A becomes 1. - Expected: - `EnterAuraRange` trigger emitted with `SourceId=A`, `TargetId=B`. - Any matching triggered actions on A resolve. ### Notes - Aura enter/leave also has dedicated helpers for summon/death transitions: - `EvaluateAurasOnEnter(...)` - `EvaluateAurasOnLeave(...)`