feat(battle-node): BuildOpponentTurnEnd builder for v1.1 turn loop
Pairs with BuildOpponentTurnStart. Wire shape from prod capture (turnState=0, resultCode=1). Single test locks uri, ViewerId, Cat, and body shape.
This commit is contained in:
@@ -107,6 +107,15 @@ public static class ScriptedLifecycle
|
|||||||
EnvelopeForPush(NetworkBattleUri.TurnStart,
|
EnvelopeForPush(NetworkBattleUri.TurnStart,
|
||||||
new OpponentTurnStartBody(Spin: ScriptedProfiles.OpponentTurnStartSpin));
|
new OpponentTurnStartBody(Spin: ScriptedProfiles.OpponentTurnStartSpin));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Server-pushed TurnEnd transition that closes the opponent's turn and hands control
|
||||||
|
/// back to the player. Paired with <see cref="BuildOpponentTurnStart"/> in the v1.1 loop.
|
||||||
|
/// Wire shape from prod capture battle-traffic_tk2_regular.ndjson L18:
|
||||||
|
/// <c>{"uri":"TurnEnd","turnState":0,"resultCode":1,"playSeq":N}</c>.
|
||||||
|
/// </summary>
|
||||||
|
public static MsgEnvelope BuildOpponentTurnEnd() =>
|
||||||
|
EnvelopeForPush(NetworkBattleUri.TurnEnd, new TurnEndBody(TurnState: 0));
|
||||||
|
|
||||||
private static IReadOnlyList<PosIdx> BuildPosIdxList(IReadOnlyList<long> hand)
|
private static IReadOnlyList<PosIdx> BuildPosIdxList(IReadOnlyList<long> hand)
|
||||||
{
|
{
|
||||||
var list = new List<PosIdx>(hand.Count);
|
var list = new List<PosIdx>(hand.Count);
|
||||||
|
|||||||
@@ -153,6 +153,19 @@ public class ScriptedLifecycleTests
|
|||||||
Assert.That(body.Spin, Is.EqualTo(100));
|
Assert.That(body.Spin, Is.EqualTo(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void BuildOpponentTurnEnd_emits_TurnEnd_uri_with_turn_state_zero()
|
||||||
|
{
|
||||||
|
var env = ScriptedLifecycle.BuildOpponentTurnEnd();
|
||||||
|
|
||||||
|
Assert.That(env.Uri, Is.EqualTo(NetworkBattleUri.TurnEnd));
|
||||||
|
Assert.That(env.ViewerId, Is.EqualTo(ScriptedLifecycle.FakeOpponentViewerId));
|
||||||
|
Assert.That(env.Cat, Is.EqualTo(EmitCategory.Battle));
|
||||||
|
var body = (TurnEndBody)env.Body;
|
||||||
|
Assert.That(body.TurnState, Is.EqualTo(0));
|
||||||
|
Assert.That(body.ResultCode, Is.EqualTo(1));
|
||||||
|
}
|
||||||
|
|
||||||
private static MatchContext FixtureCtx(IReadOnlyList<long>? deck = null) => new(
|
private static MatchContext FixtureCtx(IReadOnlyList<long>? deck = null) => new(
|
||||||
SelfDeckCardIds: deck ?? Enumerable.Range(1, 30).Select(i => 100_011_010L).ToList(),
|
SelfDeckCardIds: deck ?? Enumerable.Range(1, 30).Select(i => 100_011_010L).ToList(),
|
||||||
ClassId: "1", CharaId: "1", CardMasterName: "card_master_node_10015",
|
ClassId: "1", CharaId: "1", CardMasterName: "card_master_node_10015",
|
||||||
|
|||||||
Reference in New Issue
Block a user