Implement triggered ability target prompting (Option D)
When a Triggered ability fires and any of its actions require a human target
pick, the server now pauses execution instead of auto-resolving:
Server:
- AbilitySystem.FireTrigger detects actions needing client input via
ActionNeedsClientTargets(); stores PendingTriggeredTarget in GameState and
returns early rather than executing the ability
- PushStateToPlayersAsync (GameHandlerBase) checks for PendingTriggeredTarget
after every state push and sends a game.ability.triggered_target_request push
to the owning player carrying the action definition and range
- New GameTriggeredTargetHandler (game.triggered_target) receives the player's
picks, calls AbilitySystem.ResumeTriggeredAbility, and broadcasts the result
- PendingTriggeredTarget model stored in GameState.PendingTriggeredTarget (JSONB)
Client:
- Game.gd handles the triggered_target_request push and emits a signal
- game_screen.gd connects the signal, re-uses the existing ABILITY_TARGET mode
and _start_ability_targeting() flow, then sends game.triggered_target instead
of game.activate_ability when done
- A brief banner ("Triggered: <name> — select a target") informs the player
"Warrant Cover" (OnChanneled, Owner unit pick) will now correctly prompt the
player to select which friendly unit gains +1 Defense.
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:
@@ -2,6 +2,7 @@ namespace SOR.Game.Handlers;
|
||||
|
||||
using System.Text.Json;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SOR.Game.Abilities;
|
||||
using SOR.Database.Contexts;
|
||||
using SOR.Database.Entities.Game;
|
||||
using SOR.Database.Enums;
|
||||
@@ -246,6 +247,31 @@ internal abstract class GameHandlerBase
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
}
|
||||
|
||||
// After the state update is sent to all players, check whether a triggered ability
|
||||
// is waiting for client target input and push the request to the owning player.
|
||||
if (state.PendingTriggeredTarget is { } pending)
|
||||
{
|
||||
// Build the ActionJson for the first client-pick action in the pending list.
|
||||
// We serialize only the first action that actually needs input so the client
|
||||
// gets a minimal, unambiguous definition (N=1 unit pick for "Warrant Cover", etc.)
|
||||
var firstClientPickAction = JsonSerializer
|
||||
.Deserialize<Abilities.Models.Action[]>(pending.ActionsJson)
|
||||
?.FirstOrDefault(AbilitySystem.ActionNeedsClientTargets_Public);
|
||||
|
||||
var actionJson = firstClientPickAction is not null
|
||||
? JsonSerializer.Serialize(firstClientPickAction)
|
||||
: pending.ActionsJson; // fallback: send raw actions list
|
||||
|
||||
await clientPush.PushAsync(pending.ActorId,
|
||||
ServerMessage.Push("game.ability.triggered_target_request",
|
||||
new TriggeredTargetRequestPush(
|
||||
pending.RequestId,
|
||||
pending.SourceInstanceId,
|
||||
pending.AbilityName,
|
||||
actionJson,
|
||||
pending.RangeJson)), ct);
|
||||
}
|
||||
}
|
||||
|
||||
// OP config snapshot — read from RuleSnapshotJson at finalization time.
|
||||
|
||||
Reference in New Issue
Block a user