feat(battle-node): emit real spin per-frame on forwarded PlayActions

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-04 15:13:47 -04:00
parent 63cb3248b4
commit 617714ebea
3 changed files with 110 additions and 4 deletions

View File

@@ -48,6 +48,17 @@ internal sealed class PlayActionsHandler : IFrameHandler
// knownList in the same frame (capture line 75).
var uList = KnownListBuilder.RelayUList(entries.GetValueOrDefault("uList"));
// Hidden shared-RNG draws (a random deck→hand fetch the opponent can't reproduce) advance the
// sender's shared _stableRandom; the receiver doesn't re-run them, so it needs a spin crank to
// stay aligned for later visible randoms. Per-frame delivery (real-spin design §3.2): the count
// rides THIS PlayActions. A fetch we relay with an identity (uList cardId present) is already
// known to the opponent — exclude its idxs so it isn't counted. 0 → null (omitted; client
// assumes spin:0).
var revealed = uList is null
? (IReadOnlySet<int>)new HashSet<int>()
: uList.Where(u => u.CardId is not null).SelectMany(u => u.IdxList).ToHashSet();
var spin = KnownListBuilder.CountHiddenDraws(orderList, playIdx, revealed);
var body = new PlayActionsBroadcastBody(
PlayIdx: playIdx,
Type: type,
@@ -56,7 +67,8 @@ internal sealed class PlayActionsHandler : IFrameHandler
UList: uList,
// {type,cardId} forwarded so the opponent renders the choice token; selectCard dropped
// when open==0 (hidden draw-to-hand pick). Null for a vanilla play (no keyAction).
KeyAction: KnownListBuilder.StripKeyActionForOpponent(keyAction));
KeyAction: KnownListBuilder.StripKeyActionForOpponent(keyAction),
Spin: spin > 0 ? spin : null);
var frame = ctx.Env with { Body = body };
return new[] { new DispatchRoute(ctx.Other, frame, false) };