feat(battle-node): derive Matched.seed + Ready.idxChangeSeed from master seed
InitBattle now emits Stable(master) as the shared effect seed and the master- shuffled deck as selfDeck; Swap emits each recipient's per-side IdxChange seed. BattleSession exposes + logs the master seed per battle for future replay. Updated lifecycle/dispatch/integration tests (deck assertions now permutation- based since selfDeck is shuffled). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,7 @@ public static class ServerBattleFrames
|
||||
public static MsgEnvelope BuildMatched(
|
||||
MatchContext selfCtx, MatchContext oppoCtx,
|
||||
long selfViewerId, long oppoViewerId,
|
||||
string battleId, long seed) =>
|
||||
string battleId, long seed, IReadOnlyList<long> selfDeckOrder) =>
|
||||
EnvelopeForPush(NetworkBattleUri.Matched,
|
||||
new MatchedBody(
|
||||
SelfInfo: new MatchedSelfInfo(
|
||||
@@ -47,7 +47,7 @@ public static class ServerBattleFrames
|
||||
OppoId: selfViewerId,
|
||||
Seed: seed,
|
||||
OppoDeckCount: oppoCtx.SelfDeckCardIds.Count),
|
||||
SelfDeck: BuildPlayerDeck(selfCtx.SelfDeckCardIds)),
|
||||
SelfDeck: BuildPlayerDeck(selfDeckOrder)),
|
||||
bid: battleId);
|
||||
|
||||
public static MsgEnvelope BuildBattleStart(
|
||||
@@ -113,16 +113,17 @@ public static class ServerBattleFrames
|
||||
|
||||
/// <summary>Non-interactive opponent (Bot/AI): oppo is the placeholder
|
||||
/// <see cref="InitialHand"/>.</summary>
|
||||
public static MsgEnvelope BuildReady(IReadOnlyList<long> hand) => BuildReady(hand, InitialHand);
|
||||
public static MsgEnvelope BuildReady(IReadOnlyList<long> hand, int idxChangeSeed) =>
|
||||
BuildReady(hand, InitialHand, idxChangeSeed);
|
||||
|
||||
/// <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) =>
|
||||
public static MsgEnvelope BuildReady(IReadOnlyList<long> selfHand, IReadOnlyList<long> oppoHand, int idxChangeSeed) =>
|
||||
EnvelopeForPush(NetworkBattleUri.Ready,
|
||||
new ReadyBody(
|
||||
Self: BuildPosIdxList(selfHand),
|
||||
Oppo: BuildPosIdxList(oppoHand),
|
||||
IdxChangeSeed: BattleFrameDefaults.ReadyIdxChangeSeed,
|
||||
IdxChangeSeed: idxChangeSeed,
|
||||
Spin: BattleFrameDefaults.ReadySpin));
|
||||
|
||||
private static IReadOnlyList<PosIdx> BuildPosIdxList(IReadOnlyList<long> hand)
|
||||
|
||||
Reference in New Issue
Block a user