Fix ability lock-out guards, implement SummonTokenEffect, thread card targets

- GameEngine.Transition: enforce CanTransitionArchSpirit flag
- GameEngine.ChannelCard: enforce CanChannelSpirit, CanChannelRepentance,
  CanChannelInstinct, CanChannelRuin, CanChannelTerramorphaMono/Di/Tri
- GameEngine.ChannelCard: accept IReadOnlyList<AbilityTarget>? cardTargets;
  thread through FireCardEffects for Repentance/Instinct effects
- AbilitySystem.FireCardEffects: accept and forward clientTargets to ExecuteActions
- AbilitySystem.ExecuteEffect: implement SummonTokenEffect — deserialize TokenDefJson,
  create SpiritToken FieldCard, place on board, fire UnitEnterBattlefield + aura enter
- GamePlayCardRequest: add IReadOnlyList<AbilityTarget>? Targets for unit/tile inputs
- GamePlayCardHandler: pass req.Targets to ChannelCard

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-02-26 21:10:20 -05:00
co-authored by Claude Happy
parent 0641fb2324
commit 7c89f4d0db
4 changed files with 71 additions and 12 deletions
+59 -2
View File
@@ -94,12 +94,13 @@ public static class AbilitySystem
/// Resolve the EffectsJson action list on a non-unit card (Repentance, Instinct, Ruin)
/// immediately when it is channeled. The card itself is the source in the context.
/// </summary>
public static GameState FireCardEffects(GameState state, string actorId, CardInstance card)
public static GameState FireCardEffects(GameState state, string actorId, CardInstance card,
IReadOnlyList<AbilityTarget>? clientTargets = null)
{
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: null);
ExecuteActions(actions, ctx, clientTargets);
return state;
}
@@ -741,11 +742,67 @@ public static class AbilitySystem
break;
}
// ── §5.11 Token summoning ─────────────────────────────────────────
case SummonTokenEffect ste when target is Coord coord:
{
var board = ctx.State.Board;
if (board is null) break;
var tile = board.GetTile(coord);
if (tile is null || !tile.IsEmpty) break;
// TokenDefJson is deserialized directly as CardInstance field values.
var proto = JsonSerializer.Deserialize<CardInstance>(ste.TokenDefJson, _jsonOpts);
if (proto is null) break;
proto.InstanceId = Guid.NewGuid().ToString("N")[..8];
proto.CardType = "SpiritToken";
var tokenField = CreateTokenFieldCard(proto, coord);
ctx.State.Players[ctx.ActorId].Field.Add(tokenField);
board.PlaceUnit(coord, tokenField.InstanceId, ctx.ActorId);
FireTrigger(ctx.State, new TriggerOccurrence
{
Kind = TriggerEventKind.UnitEnterBattlefield,
ActorId = ctx.ActorId,
UnitType = "SpiritToken",
Data = new TriggerEventData { SourceId = tokenField.InstanceId },
});
EvaluateAurasOnEnter(ctx.State, tokenField.InstanceId);
break;
}
default:
break;
}
}
private static FieldCard CreateTokenFieldCard(CardInstance proto, Coord position)
=> new()
{
InstanceId = proto.InstanceId,
Name = proto.Name,
CardType = "SpiritToken",
Affinity = proto.Affinity,
MaxHealth = proto.MaxHealth,
CurrentHealth = proto.MaxHealth,
MaxDefense = proto.MaxDefense,
CurrentDefense = proto.MaxDefense,
Damage = proto.Damage,
CanAttack = proto.CanAttack,
CanDefend = proto.CanDefend,
CanMove = proto.CanMove,
MovementType = proto.MovementType,
MaxMp = proto.MaxMp,
CurrentMp = proto.MaxMp ?? 0,
MinAttackRange = proto.MinAttackRange,
MaxAttackRange = proto.MaxAttackRange,
RequiresLos = proto.RequiresLos,
AbilitiesJson = proto.AbilitiesJson,
IsExhausted = false,
Position = position,
};
// ── Damage helper ─────────────────────────────────────────────────────────
private static void ApplyDamageToUnit(