Selection issues, model issues, ability bug
This commit is contained in:
@@ -218,15 +218,32 @@ public static class AbilitySystem
|
||||
|
||||
foreach (var effect in action.Effects)
|
||||
{
|
||||
if (effect is not SummonTokenEffect ste || ste.TileFilter is not { Length: > 0 }) continue;
|
||||
if (effect is not SummonTokenEffect ste) continue;
|
||||
|
||||
var ct = clientTargets.FirstOrDefault(t => t.ActionIndex == ai && t.Coord is not null);
|
||||
if (ct is null) continue;
|
||||
|
||||
var coord = new Coord(ct.Coord!.X, ct.Coord!.Y);
|
||||
var tile = ctx.State.Board.GetTile(coord);
|
||||
if (tile is null || !TileMatchesFilters(ste.TileFilter, tile, ctx))
|
||||
|
||||
// Tile must exist and be empty for a SummonToken.
|
||||
if (tile is null || !tile.IsEmpty)
|
||||
throw new GameException("INVALID_TILE");
|
||||
|
||||
// Explicit TileFilter (e.g. TileAffinityMatches).
|
||||
if (ste.TileFilter is { Length: > 0 } && !TileMatchesFilters(ste.TileFilter, tile, ctx))
|
||||
throw new GameException("INVALID_TILE");
|
||||
|
||||
// Validate the token's own affinity against the tile.
|
||||
if (!string.IsNullOrEmpty(ste.TokenDefJson))
|
||||
{
|
||||
var proto = JsonSerializer.Deserialize<CardInstance>(ste.TokenDefJson, _jsonOpts);
|
||||
if (proto is not null
|
||||
&& !string.IsNullOrEmpty(proto.Affinity) && proto.Affinity != "Void"
|
||||
&& Enum.TryParse<Affinity>(proto.Affinity, out var tokenAffinity)
|
||||
&& !AffinitySystem.IsAffinityValid(tile, tokenAffinity))
|
||||
throw new GameException("INVALID_TILE");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user