feat(battle-node): BuildReady overload carrying the opponent's hand

Adds BuildReady(selfHand, oppoHand) for the mulligan barrier; the single-arg
overload keeps the InitialHand placeholder for non-interactive opponents.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-03 10:48:43 -04:00
parent ae11fe0957
commit 633c29b44f
2 changed files with 30 additions and 3 deletions

View File

@@ -113,11 +113,17 @@ public static class ScriptedLifecycle
EnvelopeForPush(NetworkBattleUri.Swap,
new SwapResponseBody(Self: BuildPosIdxList(hand)));
public static MsgEnvelope BuildReady(IReadOnlyList<long> hand) =>
/// <summary>Non-interactive opponent (scripted single / AINetwork): oppo is the
/// placeholder <see cref="InitialHand"/> (v1 behaviour).</summary>
public static MsgEnvelope BuildReady(IReadOnlyList<long> hand) => BuildReady(hand, InitialHand);
/// <summary>Both hands known (the mulligan barrier supplies the opponent's
/// post-mulligan hand).</summary>
public static MsgEnvelope BuildReady(IReadOnlyList<long> selfHand, IReadOnlyList<long> oppoHand) =>
EnvelopeForPush(NetworkBattleUri.Ready,
new ReadyBody(
Self: BuildPosIdxList(hand),
Oppo: BuildPosIdxList(InitialHand),
Self: BuildPosIdxList(selfHand),
Oppo: BuildPosIdxList(oppoHand),
IdxChangeSeed: ScriptedProfiles.ReadyIdxChangeSeed,
Spin: ScriptedProfiles.ReadySpin));

View File

@@ -145,6 +145,27 @@ public class ScriptedLifecycleTests
Assert.That(body.Self[1].Idx, Is.EqualTo(4));
}
[Test]
public void BuildReady_two_arg_sets_oppo_to_supplied_hand()
{
var env = ScriptedLifecycle.BuildReady(new long[] { 1, 4, 3 }, new long[] { 1, 2, 6 });
var body = (ReadyBody)env.Body;
Assert.That(body.Self.Select(p => p.Idx), Is.EqualTo(new[] { 1, 4, 3 }));
Assert.That(body.Oppo.Select(p => p.Idx), Is.EqualTo(new[] { 1, 2, 6 }),
"oppo must reflect the opponent's post-mulligan hand, not the placeholder InitialHand.");
}
[Test]
public void BuildReady_one_arg_defaults_oppo_to_InitialHand()
{
var env = ScriptedLifecycle.BuildReady(new long[] { 1, 4, 3 });
var body = (ReadyBody)env.Body;
Assert.That(body.Oppo.Select(p => p.Idx), Is.EqualTo(new[] { 1, 2, 3 }),
"single-arg overload (non-interactive opponent) keeps the placeholder hand.");
}
[Test]
public void BuildOpponentTurnStart_HasUriTurnStartAndSpin()
{