feat(battle-node): relay uList on PvP PlayActions
Forwards the sender's deck-sourced summons/fetches to the opponent (closes the spin-independent slice of direct-to-field summons). uList coexists with the synthesized knownList in the same frame. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -7,13 +7,15 @@ namespace SVSim.BattleNode.Protocol.Bodies;
|
|||||||
/// the deterministic-turn slice). <c>OppoTargetList</c> is the renamed <c>targetList</c>
|
/// the deterministic-turn slice). <c>OppoTargetList</c> is the renamed <c>targetList</c>
|
||||||
/// (independent of KnownList — a targeted hand play carries both). <c>KeyAction</c> forwards a
|
/// (independent of KnownList — a targeted hand play carries both). <c>KeyAction</c> forwards a
|
||||||
/// choice/Discover play's <c>{type,cardId}</c> so the opponent renders the choice-token generation;
|
/// choice/Discover play's <c>{type,cardId}</c> so the opponent renders the choice-token generation;
|
||||||
/// the pick (<c>selectCard</c>) is stripped for a hidden (open:0) draw-to-hand choice. All three are
|
/// the pick (<c>selectCard</c>) is stripped for a hidden (open:0) draw-to-hand choice. <c>UList</c>
|
||||||
|
/// forwards the sender's unapproved-movement list (deck-sourced summons/fetches) verbatim. All are
|
||||||
/// omitted when null via the envelope's WhenWritingNull policy (a vanilla play carries none).</summary>
|
/// omitted when null via the envelope's WhenWritingNull policy (a vanilla play carries none).</summary>
|
||||||
public sealed record PlayActionsBroadcastBody(
|
public sealed record PlayActionsBroadcastBody(
|
||||||
[property: JsonPropertyName("playIdx")] int PlayIdx,
|
[property: JsonPropertyName("playIdx")] int PlayIdx,
|
||||||
[property: JsonPropertyName("type")] int Type,
|
[property: JsonPropertyName("type")] int Type,
|
||||||
[property: JsonPropertyName("knownList")] IReadOnlyList<KnownCardEntry>? KnownList,
|
[property: JsonPropertyName("knownList")] IReadOnlyList<KnownCardEntry>? KnownList,
|
||||||
[property: JsonPropertyName("oppoTargetList")] IReadOnlyList<OppoTargetEntry>? OppoTargetList,
|
[property: JsonPropertyName("oppoTargetList")] IReadOnlyList<OppoTargetEntry>? OppoTargetList,
|
||||||
|
[property: JsonPropertyName("uList")] IReadOnlyList<UnapprovedCardEntry>? UList = null,
|
||||||
[property: JsonPropertyName("keyAction")] IReadOnlyList<KeyActionEntry>? KeyAction = null) : IMsgBody;
|
[property: JsonPropertyName("keyAction")] IReadOnlyList<KeyActionEntry>? KeyAction = null) : IMsgBody;
|
||||||
|
|
||||||
/// <summary>Opponent-facing keyAction entry for a choice/Discover play. <c>type</c>/<c>cardId</c>
|
/// <summary>Opponent-facing keyAction entry for a choice/Discover play. <c>type</c>/<c>cardId</c>
|
||||||
|
|||||||
@@ -42,11 +42,18 @@ internal sealed class PlayActionsHandler : IFrameHandler
|
|||||||
var played = KnownListBuilder.BuildPlayedCard(deckMap, playIdx, orderList);
|
var played = KnownListBuilder.BuildPlayedCard(deckMap, playIdx, orderList);
|
||||||
var oppoTargets = KnownListBuilder.RenameTargets(entries.GetValueOrDefault("targetList"));
|
var oppoTargets = KnownListBuilder.RenameTargets(entries.GetValueOrDefault("targetList"));
|
||||||
|
|
||||||
|
// Deck-sourced movements (fetch / search / summon-from-deck) ride the uList — a verbatim,
|
||||||
|
// separate receive slot the node forwards unchanged (bullet-3 audit F1). The node makes no
|
||||||
|
// reveal decision; cardId presence is the sender's call. Coexists with the synthesized
|
||||||
|
// knownList in the same frame (capture line 75).
|
||||||
|
var uList = KnownListBuilder.RelayUList(entries.GetValueOrDefault("uList"));
|
||||||
|
|
||||||
var body = new PlayActionsBroadcastBody(
|
var body = new PlayActionsBroadcastBody(
|
||||||
PlayIdx: playIdx,
|
PlayIdx: playIdx,
|
||||||
Type: type,
|
Type: type,
|
||||||
KnownList: played is null ? null : new[] { played },
|
KnownList: played is null ? null : new[] { played },
|
||||||
OppoTargetList: oppoTargets,
|
OppoTargetList: oppoTargets,
|
||||||
|
UList: uList,
|
||||||
// {type,cardId} forwarded so the opponent renders the choice token; selectCard dropped
|
// {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).
|
// when open==0 (hidden draw-to-hand pick). Null for a vanilla play (no keyAction).
|
||||||
KeyAction: KnownListBuilder.StripKeyActionForOpponent(keyAction));
|
KeyAction: KnownListBuilder.StripKeyActionForOpponent(keyAction));
|
||||||
|
|||||||
@@ -249,6 +249,58 @@ public class BattleSessionDispatchTests
|
|||||||
Assert.That(pb.OppoTargetList[0].IsSelf, Is.EqualTo(0));
|
Assert.That(pb.OppoTargetList[0].IsSelf, Is.EqualTo(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Pvp_PlayActions_relays_uList_verbatim()
|
||||||
|
{
|
||||||
|
// A deck-fetch rides the uList (battle-traffic_tk2_regular.ndjson:75); the node forwards it
|
||||||
|
// verbatim alongside the synthesized knownList for the played card.
|
||||||
|
var (s, a, b) = NewPvpSession();
|
||||||
|
DriveToAfterReady(s, a);
|
||||||
|
DriveToAfterReady(s, b);
|
||||||
|
|
||||||
|
var body = MoveOrderList(idx: 3, from: 10, to: 20);
|
||||||
|
body["playIdx"] = 3L;
|
||||||
|
body["type"] = 30L;
|
||||||
|
body["uList"] = new List<object?>
|
||||||
|
{
|
||||||
|
new Dictionary<string, object?>
|
||||||
|
{
|
||||||
|
["idxList"] = new List<object?> { 16L, 22L },
|
||||||
|
["from"] = 0L, ["to"] = 10L, ["isSelf"] = 1L, ["skill"] = "37|36|0",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
var routes = s.ComputeFrames(a, EnvWith(NetworkBattleUri.PlayActions, body));
|
||||||
|
Assert.That(routes.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(routes[0].Target, Is.SameAs(b));
|
||||||
|
var pb = (PlayActionsBroadcastBody)routes[0].Frame.Body;
|
||||||
|
|
||||||
|
Assert.That(pb.KnownList!.Count, Is.EqualTo(1), "played card still synthesized in the same frame");
|
||||||
|
Assert.That(pb.UList, Is.Not.Null);
|
||||||
|
Assert.That(pb.UList!.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(pb.UList[0].IdxList, Is.EqualTo(new[] { 16, 22 }));
|
||||||
|
Assert.That(pb.UList[0].From, Is.EqualTo(0));
|
||||||
|
Assert.That(pb.UList[0].To, Is.EqualTo(10));
|
||||||
|
Assert.That(pb.UList[0].IsSelf, Is.EqualTo(1));
|
||||||
|
Assert.That(pb.UList[0].Skill, Is.EqualTo("37|36|0"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Pvp_PlayActions_without_uList_leaves_it_null()
|
||||||
|
{
|
||||||
|
var (s, a, b) = NewPvpSession();
|
||||||
|
DriveToAfterReady(s, a);
|
||||||
|
DriveToAfterReady(s, b);
|
||||||
|
|
||||||
|
var body = MoveOrderList(idx: 3, from: 10, to: 20);
|
||||||
|
body["playIdx"] = 3L;
|
||||||
|
body["type"] = 30L;
|
||||||
|
|
||||||
|
var routes = s.ComputeFrames(a, EnvWith(NetworkBattleUri.PlayActions, body));
|
||||||
|
var pb = (PlayActionsBroadcastBody)routes[0].Frame.Body;
|
||||||
|
Assert.That(pb.UList, Is.Null);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Pvp_PlayActions_ungenerated_token_idx_degrades_to_no_knownList()
|
public void Pvp_PlayActions_ungenerated_token_idx_degrades_to_no_knownList()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user