feat(battle-node): reveal choice/Discover tokens to opponent
Choice/Discover-into-hand fanfares add a candidates-only token to hand; the
chosen cardId rides keyAction.selectCard on the generating play, not the
orderList add op. Record idx->chosenCardId at generation (candidate-membership
join) so the later play reveals the real identity via the existing
BuildPlayedCard path; forward {type,cardId} to the opponent and strip
selectCard for hidden (open:0) picks (pass through for open:1, provisional).
- KnownListBuilder.MineChoicePicks + StripKeyActionForOpponent (pure)
- BattleSessionState.RecordChoicePicksFrom (reuses IdxToCardId, no new state)
- PlayActionsBroadcastBody.keyAction + KeyActionEntry/SelectCardEntry
- PlayActionsHandler wires both; EchoHandler unchanged (picks ride the send)
Tests (TDD red->green): 8 KnownListBuilder + 2 dispatch + 2 conformance
(shape-locked to tk2_regular L151 generation / L193 reveal). Full suite 976/0.
Spec: docs/superpowers/specs/2026-06-04-battle-node-choice-token-reveal-design.md
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -350,6 +350,104 @@ public class BattleSessionDispatchTests
|
||||
Assert.That(pb.KnownList[0].To, Is.EqualTo(20));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pvp_PlayActions_choice_token_records_pick_and_strips_selectCard()
|
||||
{
|
||||
var (s, a, b) = NewPvpSession();
|
||||
DriveToAfterReady(s, a);
|
||||
DriveToAfterReady(s, b);
|
||||
|
||||
// A plays a generating deck card (idx 3) whose fanfare is a hidden draw-to-hand choice: a
|
||||
// choiceAdd lands a token at idx 31 (candidates only), the move pulls it limbo->hand, and
|
||||
// keyAction.selectCard names the chosen cardId with open:0 (hidden).
|
||||
var gen = new Dictionary<string, object?>
|
||||
{
|
||||
["playIdx"] = 3L,
|
||||
["type"] = 30L,
|
||||
["orderList"] = new List<object?>
|
||||
{
|
||||
new Dictionary<string, object?> { ["move"] = new Dictionary<string, object?>
|
||||
{ ["idx"] = new List<object?> { 3L }, ["isSelf"] = 1L, ["from"] = 10L, ["to"] = 30L } },
|
||||
new Dictionary<string, object?> { ["add"] = new Dictionary<string, object?>
|
||||
{ ["idx"] = new List<object?> { 31L }, ["isSelf"] = 1L,
|
||||
["card"] = new Dictionary<string, object?>
|
||||
{ ["candidates"] = new List<object?> { 810041260L, 101041020L } },
|
||||
["isChoice"] = "1" } },
|
||||
new Dictionary<string, object?> { ["move"] = new Dictionary<string, object?>
|
||||
{ ["idx"] = new List<object?> { 31L }, ["isSelf"] = 1L, ["from"] = 50L, ["to"] = 10L } },
|
||||
},
|
||||
["keyAction"] = new List<object?>
|
||||
{
|
||||
new Dictionary<string, object?>
|
||||
{
|
||||
["type"] = 1L, ["cardId"] = 100_011_010L,
|
||||
["selectCard"] = new Dictionary<string, object?>
|
||||
{ ["cardId"] = new List<object?> { 810041260L }, ["open"] = 0L },
|
||||
}
|
||||
},
|
||||
};
|
||||
var routes = s.ComputeFrames(a, EnvWith(NetworkBattleUri.PlayActions, gen));
|
||||
|
||||
Assert.That(routes.Count, Is.EqualTo(1));
|
||||
Assert.That(routes[0].Target, Is.SameAs(b));
|
||||
var pb = (PlayActionsBroadcastBody)routes[0].Frame.Body;
|
||||
// The generating deck card reveals from A's deck map (idx 3).
|
||||
Assert.That(pb.KnownList!.Single().CardId, Is.EqualTo(100_011_010L), "generating deck card revealed");
|
||||
// keyAction forwarded as {type,cardId}; selectCard stripped for the hidden choice.
|
||||
Assert.That(pb.KeyAction, Is.Not.Null);
|
||||
Assert.That(pb.KeyAction!.Single().Type, Is.EqualTo(1));
|
||||
Assert.That(pb.KeyAction.Single().CardId, Is.EqualTo(100_011_010L));
|
||||
Assert.That(pb.KeyAction.Single().SelectCard, Is.Null, "the pick stays hidden for open:0");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pvp_PlayActions_reveals_choice_token_when_chosen_card_is_played()
|
||||
{
|
||||
var (s, a, b) = NewPvpSession();
|
||||
DriveToAfterReady(s, a);
|
||||
DriveToAfterReady(s, b);
|
||||
|
||||
// Generation frame: records idx 31 -> chosen cardId 810041260 into A's map (from selectCard).
|
||||
var gen = new Dictionary<string, object?>
|
||||
{
|
||||
["playIdx"] = 3L,
|
||||
["type"] = 30L,
|
||||
["orderList"] = new List<object?>
|
||||
{
|
||||
new Dictionary<string, object?> { ["move"] = new Dictionary<string, object?>
|
||||
{ ["idx"] = new List<object?> { 3L }, ["isSelf"] = 1L, ["from"] = 10L, ["to"] = 30L } },
|
||||
new Dictionary<string, object?> { ["add"] = new Dictionary<string, object?>
|
||||
{ ["idx"] = new List<object?> { 31L }, ["isSelf"] = 1L,
|
||||
["card"] = new Dictionary<string, object?>
|
||||
{ ["candidates"] = new List<object?> { 810041260L, 101041020L } },
|
||||
["isChoice"] = "1" } },
|
||||
},
|
||||
["keyAction"] = new List<object?>
|
||||
{
|
||||
new Dictionary<string, object?>
|
||||
{
|
||||
["type"] = 1L, ["cardId"] = 100_011_010L,
|
||||
["selectCard"] = new Dictionary<string, object?>
|
||||
{ ["cardId"] = new List<object?> { 810041260L }, ["open"] = 0L },
|
||||
}
|
||||
},
|
||||
};
|
||||
s.ComputeFrames(a, EnvWith(NetworkBattleUri.PlayActions, gen));
|
||||
|
||||
// Later A plays the chosen token idx 31 (hand 10 -> field 20). B must see its real identity.
|
||||
var play = MoveOrderList(idx: 31, from: 10, to: 20);
|
||||
play["playIdx"] = 31L;
|
||||
play["type"] = 30L;
|
||||
var routes = s.ComputeFrames(a, EnvWith(NetworkBattleUri.PlayActions, play));
|
||||
|
||||
var pb = (PlayActionsBroadcastBody)routes[0].Frame.Body;
|
||||
Assert.That(pb.PlayIdx, Is.EqualTo(31));
|
||||
Assert.That(pb.KnownList, Is.Not.Null, "the choice pick was recorded at generation");
|
||||
Assert.That(pb.KnownList!.Single().Idx, Is.EqualTo(31));
|
||||
Assert.That(pb.KnownList[0].CardId, Is.EqualTo(810041260L), "the chosen cardId surfaces on play");
|
||||
Assert.That(pb.KnownList[0].To, Is.EqualTo(20));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pvp_PlayActions_when_B_still_AwaitingSwap_drops()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user