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:
@@ -53,10 +53,10 @@ public static class ScriptedLifecycle
|
||||
bid: battleId);
|
||||
|
||||
public static MsgEnvelope BuildBattleStart(
|
||||
MatchContext selfCtx, MatchContext oppoCtx, long selfViewerId) =>
|
||||
MatchContext selfCtx, MatchContext oppoCtx, long selfViewerId, int turnState) =>
|
||||
EnvelopeForPush(NetworkBattleUri.BattleStart,
|
||||
new BattleStartBody(
|
||||
TurnState: 0, // player goes first
|
||||
TurnState: turnState, // 0 = this side goes first, 1 = second. Caller decides.
|
||||
BattleType: selfCtx.BattleType,
|
||||
SelfInfo: new BattleStartSelfInfo(
|
||||
Rank: ScriptedProfiles.PlayerRank,
|
||||
|
||||
@@ -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:
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user