Fix ability targeting gaps: multi-target, UpTo, ChooseOne, LinearOnly, RequiresLos
- AbilityTarget: add BranchIndex for ChooseOne branch selection - Action: add ChooseOne? property; when set the action is a branch selector - AbilitySystem: ExecuteSingleAction handles ChooseOne — reads BranchIndex from client targets, executes chosen branch actions (auto-resolved) - game_screen.gd: count.N > 1 — input handler now accumulates targets until N collected before advancing to next action - game_screen.gd: count.UpTo — show "Done Selecting" confirm button so player can finish with fewer than N targets - game_screen.gd: ChooseOne — detect chooseone key in action dict, show branch panel with labelled buttons, record branchIndex in target payload - game_screen.gd: LinearOnly — _is_linear() filter applied to both tile and unit highlights when ability range has linearonly=true - game_screen.gd: RequiresLos — _client_has_los() supercover DDA (matches server LineOfSight.HasLos) applied to highlights when requireslos=true 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:
@@ -466,6 +466,18 @@ public static class AbilitySystem
|
||||
HashSet<string>? restrictTargets = null,
|
||||
DurationModel? forceDuration = null)
|
||||
{
|
||||
// ChooseOne branch selector: execute the client-chosen branch's actions instead.
|
||||
if (action.ChooseOne is { Branches.Length: > 0 })
|
||||
{
|
||||
var branchIdx = clientTargets?
|
||||
.FirstOrDefault(t => t.ActionIndex == actionIndex)?.BranchIndex ?? 0;
|
||||
branchIdx = Math.Clamp(branchIdx, 0, action.ChooseOne.Branches.Length - 1);
|
||||
ExecuteActions(action.ChooseOne.Branches[branchIdx].Actions, ctx,
|
||||
clientTargets: null, requireClientTargets: false,
|
||||
forceDuration: forceDuration);
|
||||
return;
|
||||
}
|
||||
|
||||
// Source-level conditions (Subject != "Target"): gate the whole action.
|
||||
if (action.Conditions is { Length: > 0 })
|
||||
foreach (var cond in action.Conditions)
|
||||
|
||||
@@ -71,6 +71,14 @@ public sealed class Action
|
||||
public Condition[]? Conditions { get; set; }
|
||||
public Effect[] Effects { get; set; } = [];
|
||||
public DurationModel? Duration { get; set; }
|
||||
/// <summary>
|
||||
/// When non-null this Action is a branch selector — <see cref="Effects"/> are ignored.
|
||||
/// The controlling player picks one <see cref="Branch"/>; its <see cref="Branch.Actions"/>
|
||||
/// execute instead. Set <see cref="AbilityTarget.BranchIndex"/> in the client payload
|
||||
/// to indicate which branch was chosen (0-based; defaults to 0 if absent).
|
||||
/// Branch sub-actions are auto-resolved (no nested client targeting required).
|
||||
/// </summary>
|
||||
public ChooseOne? ChooseOne { get; set; }
|
||||
}
|
||||
|
||||
// ── ChooseOne ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -748,6 +748,8 @@ public sealed record AbilityTarget(
|
||||
/// <summary>0-based index of the ability action this target satisfies.</summary>
|
||||
int ActionIndex,
|
||||
/// <summary>Set for unit/card targets.</summary>
|
||||
string? InstanceId = null,
|
||||
string? InstanceId = null,
|
||||
/// <summary>Set for tile targets.</summary>
|
||||
CoordDto? Coord = null);
|
||||
CoordDto? Coord = null,
|
||||
/// <summary>Set for ChooseOne actions: the 0-based index of the chosen branch.</summary>
|
||||
int? BranchIndex = null);
|
||||
|
||||
Reference in New Issue
Block a user