Close the two generated-token gaps that desynced PvP live test #3 (the Forestcraft Fairy), both sourced from the 2026-06-03 decomp-validation table. - MineAddOps now returns (idx, cardId, isSelf) and no longer drops isSelf:0. isSelf is the sender's perspective tag on CardObj.IsPlayer (RegisterToken.cs:22) and a card has one CardObj.Index, so an isSelf:0 add is the opponent's card. - New shared BattleSessionState.RecordTokensFrom routes isSelf:1 -> sender, isSelf:0 -> opponent (the gift lives in the recipient's map, consulted when they play it). PlayActionsHandler delegates to it. - EchoHandler now mines via the same helper but still returns no routes. An Echo's orderList carries the same add-op shape as a send (MakeEchoData -> MakeCommonSendAndEchoCardData), so MineAddOps applies verbatim; mining != relaying. Choice/copy/private-group adds stay skipped (no concrete cardId). Full solution 963/963 green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
2.1 KiB
C#
43 lines
2.1 KiB
C#
using SVSim.BattleNode.Protocol;
|
|
using SVSim.BattleNode.Protocol.Bodies;
|
|
|
|
namespace SVSim.BattleNode.Sessions.Dispatch.Handlers;
|
|
|
|
/// <summary>PvP PlayActions translator (vanilla deck-card slice). Synthesizes the opponent-facing
|
|
/// knownList from the sender's idx->cardId map + the orderList move op, renames targetList ->
|
|
/// oppoTargetList, drops orderList, consumes keyAction.
|
|
/// Token plays resolve their cardId from add ops mined on earlier frames; an un-generated token
|
|
/// idx still degrades to {playIdx,type} (no knownList). Bot drop (no rule).</summary>
|
|
internal sealed class PlayActionsHandler : IFrameHandler
|
|
{
|
|
public IReadOnlyList<DispatchRoute> Handle(FrameDispatchContext ctx)
|
|
{
|
|
if (ctx.Type != BattleType.Pvp || !ctx.BothAfterReady())
|
|
return Array.Empty<DispatchRoute>();
|
|
|
|
var entries = (ctx.Env.Body as RawBody)?.Entries ?? new Dictionary<string, object?>();
|
|
var playIdx = (int)KnownListBuilder.AsLong(entries.GetValueOrDefault("playIdx"));
|
|
var type = (int)KnownListBuilder.AsLong(entries.GetValueOrDefault("type"));
|
|
|
|
var orderList = entries.GetValueOrDefault("orderList");
|
|
|
|
// Mine generated-token identities from this frame's add ops into the right side's idx->cardId
|
|
// map (isSelf:1 → sender; isSelf:0 → opponent, a cross-side gift), so a token played in a LATER
|
|
// frame resolves its cardId — by whichever side ends up playing it (bullet-3 audit F1).
|
|
ctx.State.RecordTokensFrom(ctx.From, ctx.Other, orderList);
|
|
|
|
var deckMap = ctx.State.GetOrSeedDeckMap(ctx.From);
|
|
var played = KnownListBuilder.BuildPlayedCard(deckMap, playIdx, orderList);
|
|
var oppoTargets = KnownListBuilder.RenameTargets(entries.GetValueOrDefault("targetList"));
|
|
|
|
var body = new PlayActionsBroadcastBody(
|
|
PlayIdx: playIdx,
|
|
Type: type,
|
|
KnownList: played is null ? null : new[] { played },
|
|
OppoTargetList: oppoTargets);
|
|
|
|
var frame = ctx.Env with { Body = body };
|
|
return new[] { new DispatchRoute(ctx.Other, frame, false) };
|
|
}
|
|
}
|