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

@@ -207,11 +207,19 @@ public sealed class BattleSession
break;
case NetworkBattleUri.Loaded when phaseFrom?.Phase == BattleSessionPhase.AwaitingLoaded:
{
// Exactly one side goes first. A goes first deterministically: in Scripted that's
// the real player (constructed as A); in PvP that's the first arriver. No Type
// check — the rule is correct in both modes, and Bot/AINetwork never reaches this
// arm (its silent Loaded arm above wins the match). A per-battle coin-flip is a
// follow-up (see plan § Out of scope).
var turnState = ReferenceEquals(from, A) ? 0 : 1;
result.Add((from, ScriptedLifecycle.BuildBattleStart(
from.Context, other.Context, from.ViewerId), false));
from.Context, other.Context, from.ViewerId, turnState), false));
result.Add((from, ScriptedLifecycle.BuildDeal(), false));
phaseFrom!.Phase = BattleSessionPhase.AwaitingSwap;
break;
}
case NetworkBattleUri.Swap when phaseFrom?.Phase == BattleSessionPhase.AwaitingSwap:
{