refactor(battle-node): generalise BuildMatched/BuildBattleStart for PvP
Both helpers now take the opponent's MatchContext + an explicit seed instead of pulling ScriptedProfiles.OpponentMatchedProfile / OpponentBattleStartProfile internally. ScriptedBotParticipant.Context fixture absorbs the cosmetic fields previously hardcoded in ScriptedProfiles so Scripted's wire bytes stay identical - verified by integration tests still green. Phase 2 prep: PvP arms will call the same helpers with the real opponent participant's Context. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -12,8 +12,9 @@ public class ScriptedLifecycleTests
|
||||
[Test]
|
||||
public void BuildMatched_PutsOppoIdInSelfInfoEqualToTheRealOpponentVid()
|
||||
{
|
||||
var env = ScriptedLifecycle.BuildMatched(FixtureCtx(),
|
||||
playerViewerId: 906243102, opponentViewerId: 847666884, battleId: "b");
|
||||
var env = ScriptedLifecycle.BuildMatched(FixtureCtx(), ScriptedBotCtx(),
|
||||
selfViewerId: 906243102, oppoViewerId: 847666884,
|
||||
battleId: "b", seed: ScriptedProfiles.BattleSeed);
|
||||
|
||||
Assert.That(env.Uri, Is.EqualTo(NetworkBattleUri.Matched));
|
||||
var body = (MatchedBody)env.Body;
|
||||
@@ -25,7 +26,7 @@ public class ScriptedLifecycleTests
|
||||
[Test]
|
||||
public void BuildMatched_ContainsThirtyCardSelfDeck()
|
||||
{
|
||||
var env = ScriptedLifecycle.BuildMatched(FixtureCtx(), 1, 2, "b");
|
||||
var env = ScriptedLifecycle.BuildMatched(FixtureCtx(), ScriptedBotCtx(), 1, 2, "b", ScriptedProfiles.BattleSeed);
|
||||
var body = (MatchedBody)env.Body;
|
||||
Assert.That(body.SelfDeck.Count, Is.EqualTo(30));
|
||||
}
|
||||
@@ -34,7 +35,7 @@ public class ScriptedLifecycleTests
|
||||
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 env = ScriptedLifecycle.BuildMatched(FixtureCtx(draftedDeck), ScriptedBotCtx(), 1, 2, "b", ScriptedProfiles.BattleSeed);
|
||||
var body = (MatchedBody)env.Body;
|
||||
|
||||
for (int i = 0; i < 30; i++)
|
||||
@@ -55,7 +56,7 @@ public class ScriptedLifecycleTests
|
||||
EmblemId = "888", DegreeId = "777", FieldId = 42, IsOfficial = 1,
|
||||
};
|
||||
|
||||
var env = ScriptedLifecycle.BuildMatched(ctx, 1, 2, "b");
|
||||
var env = ScriptedLifecycle.BuildMatched(ctx, ScriptedBotCtx(), 1, 2, "b", ScriptedProfiles.BattleSeed);
|
||||
var body = (MatchedBody)env.Body;
|
||||
|
||||
Assert.That(body.SelfInfo.CountryCode, Is.EqualTo("JPN"));
|
||||
@@ -70,7 +71,7 @@ public class ScriptedLifecycleTests
|
||||
[Test]
|
||||
public void BuildBattleStart_HasTurnStateZero_AndUsesContextBattleType()
|
||||
{
|
||||
var env = ScriptedLifecycle.BuildBattleStart(FixtureCtx(), playerViewerId: 1);
|
||||
var env = ScriptedLifecycle.BuildBattleStart(FixtureCtx(), ScriptedBotCtx(), selfViewerId: 1);
|
||||
var body = (BattleStartBody)env.Body;
|
||||
Assert.That(body.TurnState, Is.EqualTo(0));
|
||||
Assert.That(body.BattleType, Is.EqualTo(11));
|
||||
@@ -86,7 +87,7 @@ public class ScriptedLifecycleTests
|
||||
BattleType = 42,
|
||||
};
|
||||
|
||||
var env = ScriptedLifecycle.BuildBattleStart(ctx, playerViewerId: 1);
|
||||
var env = ScriptedLifecycle.BuildBattleStart(ctx, ScriptedBotCtx(), selfViewerId: 1);
|
||||
var body = (BattleStartBody)env.Body;
|
||||
|
||||
Assert.That(body.SelfInfo.ClassId, Is.EqualTo("7"));
|
||||
@@ -185,4 +186,13 @@ public class ScriptedLifecycleTests
|
||||
CountryCode: "KOR", UserName: "Player", SleeveId: "3000011",
|
||||
EmblemId: "701441011", DegreeId: "300003", FieldId: 43, IsOfficial: 0,
|
||||
BattleType: 11);
|
||||
|
||||
// Mirrors ScriptedBotParticipant.Context — the scripted opponent's MatchContext fixture
|
||||
// that the new BuildMatched/BuildBattleStart helpers read from for the oppo half.
|
||||
private static MatchContext ScriptedBotCtx() => new(
|
||||
SelfDeckCardIds: Enumerable.Range(1, 30).Select(_ => 0L).ToList(),
|
||||
ClassId: "8", CharaId: "8", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: "JPN", UserName: "Opponent", SleeveId: "704141010",
|
||||
EmblemId: "400001100", DegreeId: "120027", FieldId: 5, IsOfficial: 0,
|
||||
BattleType: 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user