feat(battle-node): BuildMatched consumes MatchContext for player half
selfInfo cosmetics + 30-card selfDeck now read from MatchContext. Opponent half stays in ScriptedProfiles. DummyCardId / BuildDummyDeck / PlayerMatched Profile removed. Two new tests lock the deck-idx pairing and cosmetic flow-through; TypedBodyWireShapeTests + lifecycle tests thread a fixture ctx. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using NUnit.Framework;
|
||||
using SVSim.BattleNode.Bridge;
|
||||
using SVSim.BattleNode.Lifecycle;
|
||||
using SVSim.BattleNode.Protocol;
|
||||
using SVSim.BattleNode.Protocol.Bodies;
|
||||
@@ -11,26 +12,61 @@ public class ScriptedLifecycleTests
|
||||
[Test]
|
||||
public void BuildMatched_PutsOppoIdInSelfInfoEqualToTheRealOpponentVid()
|
||||
{
|
||||
var env = ScriptedLifecycle.BuildMatched(playerViewerId: 906243102, opponentViewerId: 847666884, battleId: "b");
|
||||
var env = ScriptedLifecycle.BuildMatched(FixtureCtx(),
|
||||
playerViewerId: 906243102, opponentViewerId: 847666884, battleId: "b");
|
||||
|
||||
Assert.That(env.Uri, Is.EqualTo(NetworkBattleUri.Matched));
|
||||
var body = (MatchedBody)env.Body;
|
||||
Assert.That(body.SelfInfo.OppoId, Is.EqualTo(847666884L));
|
||||
Assert.That(body.OppoInfo.OppoId, Is.EqualTo(906243102L));
|
||||
|
||||
// Bid travels in the envelope, not the Body — protect against the reserved-keys regression.
|
||||
Assert.That(env.Bid, Is.EqualTo("b"));
|
||||
// Typed bodies can't carry an envelope-level "bid" key by construction (no such property).
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildMatched_ContainsThirtyCardSelfDeck()
|
||||
{
|
||||
var env = ScriptedLifecycle.BuildMatched(1, 2, "b");
|
||||
var env = ScriptedLifecycle.BuildMatched(FixtureCtx(), 1, 2, "b");
|
||||
var body = (MatchedBody)env.Body;
|
||||
Assert.That(body.SelfDeck.Count, Is.EqualTo(30));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildMatched_deck_idxs_pair_1to30_with_context_card_ids()
|
||||
{
|
||||
var draftedDeck = Enumerable.Range(1, 30).Select(i => 200_000_000L + i).ToList();
|
||||
var env = ScriptedLifecycle.BuildMatched(FixtureCtx(draftedDeck), 1, 2, "b");
|
||||
var body = (MatchedBody)env.Body;
|
||||
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
Assert.That(body.SelfDeck[i].Idx, Is.EqualTo(i + 1),
|
||||
$"slot {i}: idx should be 1-based position");
|
||||
Assert.That(body.SelfDeck[i].CardId, Is.EqualTo(200_000_000L + i + 1),
|
||||
$"slot {i}: cardId should be the drafted card");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildMatched_selfInfo_cosmetics_flow_from_context()
|
||||
{
|
||||
var ctx = FixtureCtx() with
|
||||
{
|
||||
CountryCode = "JPN", UserName = "Drafter", SleeveId = "999",
|
||||
EmblemId = "888", DegreeId = "777", FieldId = 42, IsOfficial = 1,
|
||||
};
|
||||
|
||||
var env = ScriptedLifecycle.BuildMatched(ctx, 1, 2, "b");
|
||||
var body = (MatchedBody)env.Body;
|
||||
|
||||
Assert.That(body.SelfInfo.CountryCode, Is.EqualTo("JPN"));
|
||||
Assert.That(body.SelfInfo.UserName, Is.EqualTo("Drafter"));
|
||||
Assert.That(body.SelfInfo.SleeveId, Is.EqualTo("999"));
|
||||
Assert.That(body.SelfInfo.EmblemId, Is.EqualTo("888"));
|
||||
Assert.That(body.SelfInfo.DegreeId, Is.EqualTo("777"));
|
||||
Assert.That(body.SelfInfo.FieldId, Is.EqualTo(42));
|
||||
Assert.That(body.SelfInfo.IsOfficial, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildBattleStart_HasTurnStateZeroAndBattleTypeEleven()
|
||||
{
|
||||
@@ -60,7 +96,6 @@ public class ScriptedLifecycleTests
|
||||
public void ComputeHandAfterSwap_SwapMiddleCard_ReplacesWithFreshDeckIdx()
|
||||
{
|
||||
var hand = ScriptedLifecycle.ComputeHandAfterSwap(new long[] { 2 });
|
||||
// pos 0 keeps idx 1; pos 1 (was idx 2) gets next deck idx (4); pos 2 keeps idx 3.
|
||||
Assert.That(hand, Is.EqualTo(new long[] { 1, 4, 3 }));
|
||||
}
|
||||
|
||||
@@ -98,4 +133,11 @@ public class ScriptedLifecycleTests
|
||||
var body = (OpponentTurnStartBody)env.Body;
|
||||
Assert.That(body.Spin, Is.EqualTo(100));
|
||||
}
|
||||
|
||||
private static MatchContext FixtureCtx(IReadOnlyList<long>? deck = null) => new(
|
||||
SelfDeckCardIds: deck ?? Enumerable.Range(1, 30).Select(i => 100_011_010L).ToList(),
|
||||
ClassId: "1", CharaId: "1", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: "KOR", UserName: "Player", SleeveId: "3000011",
|
||||
EmblemId: "701441011", DegreeId: "300003", FieldId: 43, IsOfficial: 0,
|
||||
BattleType: 11);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user