fix(battle-node): assign turnState per side instead of hardcoding 0

Both PvP clients received turnState:0 ('both go first'). BuildBattleStart
now takes turnState; the Loaded arm assigns 0 to A, 1 to B — no Type check,
correct in Scripted (real player = A = first) and PvP (first arriver first).

Updated three existing BuildBattleStart callers in the test suite to pass
turnState:0 (the param is now required).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-03 10:47:56 -04:00
parent 84ed07d3af
commit ae11fe0957
5 changed files with 51 additions and 6 deletions

View File

@@ -52,6 +52,43 @@ public class BattleSessionDispatchTests
Assert.That(a.Phase, Is.EqualTo(BattleSessionPhase.AwaitingSwap));
}
[Test]
public void Pvp_Loaded_from_A_assigns_turnState_0()
{
var (s, a, _) = NewPvpSession();
s.ComputeFrames(a, NewEnvelope(NetworkBattleUri.InitNetwork));
s.ComputeFrames(a, NewEnvelope(NetworkBattleUri.InitBattle));
var routes = s.ComputeFrames(a, NewEnvelope(NetworkBattleUri.Loaded));
var bs = (BattleStartBody)routes[0].Frame.Body;
Assert.That(bs.TurnState, Is.EqualTo(0), "A (first arriver) goes first.");
}
[Test]
public void Pvp_Loaded_from_B_assigns_turnState_1()
{
var (s, _, b) = NewPvpSession();
s.ComputeFrames(b, NewEnvelope(NetworkBattleUri.InitNetwork));
s.ComputeFrames(b, NewEnvelope(NetworkBattleUri.InitBattle));
var routes = s.ComputeFrames(b, NewEnvelope(NetworkBattleUri.Loaded));
var bs = (BattleStartBody)routes[0].Frame.Body;
Assert.That(bs.TurnState, Is.EqualTo(1), "B (second arriver) goes second.");
}
[Test]
public void Scripted_Loaded_from_player_assigns_turnState_0()
{
// Real player is constructed as A in scripted sessions, so it always goes first.
var (s, a, _) = NewSession();
s.ComputeFrames(a, NewEnvelope(NetworkBattleUri.InitNetwork));
s.ComputeFrames(a, NewEnvelope(NetworkBattleUri.InitBattle));
var routes = s.ComputeFrames(a, NewEnvelope(NetworkBattleUri.Loaded));
var bs = (BattleStartBody)routes[0].Frame.Body;
Assert.That(bs.TurnState, Is.EqualTo(0));
}
[Test]
public void Swap_pushes_SwapResponse_then_Ready_to_sender()
{