From a768f1b27cf1421f2f1fbce346073120925094d8 Mon Sep 17 00:00:00 2001 From: dingo Date: Mon, 23 Mar 2026 12:33:03 -0400 Subject: [PATCH] Fix Battlefield tile targeting and SetAffinity on tiles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: Battlefield/All tile targets were always empty — the tile resolution path required client-provided coords for every case, but board-wide abilities (Scope=Battlefield, All=true) never send coords from the client. Added server-side enumeration of all board tiles for this case. Fix: SetAffinity on a tile now writes both Base1 and Base2 to the new affinity so AffinitySystem.Resolve returns the correct value unambiguously. Reversal tracks both slots independently so both are restored when the duration expires. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- .../src/SOR.Game/Abilities/AbilitySystem.cs | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Server/src/SOR.Game/Abilities/AbilitySystem.cs b/Server/src/SOR.Game/Abilities/AbilitySystem.cs index f6c066e..f94b187 100644 --- a/Server/src/SOR.Game/Abilities/AbilitySystem.cs +++ b/Server/src/SOR.Game/Abilities/AbilitySystem.cs @@ -497,6 +497,19 @@ public static class AbilitySystem if (selector.Type == TargetType.Tile) { + // Battlefield scope with All=true: enumerate every board tile server-side. + // The client does not (and should not) send coords for board-wide tile effects. + if (selector.Scope == TargetScope.Battlefield && selector.Count.All + && ctx.State.Board is { } board) + { + var allTiles = board.Tiles.Values + .Select(t => (object)t.Coord) + .ToList(); + if (activationRange is not null) + allTiles = FilterTargetsByAbilityRange(allTiles, ctx, activationRange); + return allTiles; + } + if (clientTargets is null) return []; var tiles = clientTargets .Where(t => t.ActionIndex == actionIndex && t.Coord is not null) @@ -994,16 +1007,20 @@ public static class AbilitySystem } case SetAffinityEffect sa when target is Coord coord: { - // SetAffinity on a tile overrides Base2 (the dominant slot) and tracks the - // original value for duration-based reversal. + // SetAffinity on a tile writes both slots so the resolved affinity is unambiguous, + // and tracks a reversal for each slot so both are restored when the duration expires. var tile = ctx.State.Board?.GetTile(coord); if (tile is null) break; + var origBase1 = tile.Base1; var origBase2 = tile.Base2; - tile.Base2 = ResolveAffinity(sa.Affinity, ctx); - TrackEffect( - new SetBaseAffinity2Effect { Affinity = new AffinityExpr { Fixed = origBase2 } }, - $"tile:{coord.X},{coord.Y}", - duration, ctx); + var newAff = ResolveAffinity(sa.Affinity, ctx); + tile.Base1 = newAff; + tile.Base2 = newAff; + var tileRef = $"tile:{coord.X},{coord.Y}"; + TrackEffect(new SetBaseAffinity1Effect { Affinity = new AffinityExpr { Fixed = origBase1 } }, + tileRef, duration, ctx); + TrackEffect(new SetBaseAffinity2Effect { Affinity = new AffinityExpr { Fixed = origBase2 } }, + tileRef, duration, ctx); break; }