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:
@@ -98,14 +98,23 @@ public class BattleNodeFlowTests
|
||||
var body = ((RawBody)matched.Body).Entries;
|
||||
var selfDeck = (List<object?>)body["selfDeck"]!;
|
||||
Assert.That(selfDeck.Count, Is.EqualTo(30));
|
||||
for (int i = 0; i < 30; i++)
|
||||
|
||||
// The node shuffles each deck per-battle from the master seed (see BattleSeeds /
|
||||
// BattleSessionState.GetShuffledDeck), so cardIds are no longer in drafted order. What must
|
||||
// hold: idxs are the contiguous 1..30 positions, and the set of cardIds is exactly the
|
||||
// drafted deck (a permutation — same multiset, reordered).
|
||||
var idxs = new List<long>(30);
|
||||
var cardIds = new List<long>(30);
|
||||
foreach (var e in selfDeck)
|
||||
{
|
||||
var entry = (Dictionary<string, object?>)selfDeck[i]!;
|
||||
Assert.That((long)entry["idx"]!, Is.EqualTo(i + 1L),
|
||||
$"slot {i}: idx should be 1-based position");
|
||||
Assert.That((long)entry["cardId"]!, Is.EqualTo(draftedDeck[i]),
|
||||
$"slot {i}: cardId should match the drafted card");
|
||||
var entry = (Dictionary<string, object?>)e!;
|
||||
idxs.Add((long)entry["idx"]!);
|
||||
cardIds.Add((long)entry["cardId"]!);
|
||||
}
|
||||
Assert.That(idxs, Is.EqualTo(Enumerable.Range(1, 30).Select(i => (long)i)),
|
||||
"idxs are the contiguous 1-based positions 1..30");
|
||||
Assert.That(cardIds, Is.EquivalentTo(draftedDeck),
|
||||
"selfDeck is a permutation of the drafted deck (shuffled, same multiset)");
|
||||
}
|
||||
|
||||
private static MsgEnvelope MakeEnvelopeWith(long vid, NetworkBattleUri uri, long pubSeq,
|
||||
|
||||
Reference in New Issue
Block a user