Fix: Repentance/Instinct card target selection + server active ability execution

Client: Repentance/Instinct cards with Active abilities in abilitiesJson now
enter ABILITY_TARGET mode instead of sending play_card immediately. Units on
matching tile affinities (IsOnTileWithAffinity) are highlighted in blue; the
player clicks a target unit and the card is sent with the selected unit target.

Server: FireCardEffects now also processes Active abilities from AbilitiesJson
(after the existing EffectsJson path). Source-side ActivationConditions are
checked; target-side conditions (Subject=Target) are trusted from the client.

New Game.gd helper: send_play_card_with_targets sends play_card with a targets
array so the server can route unit selections to the active ability handler.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-18 14:05:49 -04:00
co-authored by Claude Happy
parent 66452313d5
commit 5d3ee92553
3 changed files with 95 additions and 6 deletions
+24 -3
View File
@@ -114,10 +114,31 @@ public static class AbilitySystem
public static GameState FireCardEffects(GameState state, string actorId, CardInstance card,
IReadOnlyList<AbilityTarget>? clientTargets = null)
{
// 1. EffectsJson — backward-compatible flat action list.
var actions = ParseEffects(card.EffectsJson);
if (actions.Length == 0) return state;
var ctx = new AbilityContext { State = state, ActorId = actorId, Source = card };
ExecuteActions(actions, ctx, clientTargets, requireClientTargets: true);
if (actions.Length > 0)
{
var ctx = new AbilityContext { State = state, ActorId = actorId, Source = card };
ExecuteActions(actions, ctx, clientTargets, requireClientTargets: true);
}
// 2. AbilitiesJson — Active abilities (e.g. Repentance / Instinct cards with targeting).
foreach (var def in ParseAbilities(card.AbilitiesJson).Where(d => d.Type == AbilityType.Active))
{
var ctx = new AbilityContext { State = state, ActorId = actorId, Source = card };
// Evaluate source-side ActivationConditions only (Subject != "Target").
// Target-side conditions are enforced by the client; the resolved targets
// provided by the client are filtered per-target inside ExecuteActions.
if (def.ActivationConditions is { Length: > 0 })
{
bool sourceFailed = def.ActivationConditions
.Where(c => c.Subject != "Target")
.Any(c => !EvaluateCondition(c, ctx, card));
if (sourceFailed) continue;
}
ExecuteActions(def.Actions, ctx, clientTargets, requireClientTargets: true);
}
return state;
}