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,3 +1,4 @@
|
||||
using SVSim.BattleNode.Bridge;
|
||||
using SVSim.BattleNode.Protocol;
|
||||
using SVSim.BattleNode.Protocol.Bodies;
|
||||
|
||||
@@ -9,29 +10,32 @@ namespace SVSim.BattleNode.Lifecycle;
|
||||
/// the dispatch pushes after the player's TurnEnd. The values are templated from the TK2
|
||||
/// captures at <c>data_dumps/captures/battle-traffic_tk2_regular.ndjson</c> — anything
|
||||
/// hardcoded here came from a real prod frame, with names + provenance in
|
||||
/// <see cref="ScriptedProfiles"/>.
|
||||
/// <see cref="ScriptedProfiles"/>. The player-half of Matched/BattleStart now reads from
|
||||
/// <see cref="MatchContext"/> instead of <see cref="ScriptedProfiles"/>.
|
||||
/// </summary>
|
||||
public static class ScriptedLifecycle
|
||||
{
|
||||
/// <summary>
|
||||
/// CardId used for all 30 entries in the dummy deck. A stable neutral card that exists in
|
||||
/// every card-master version we care about, so the client can render it without
|
||||
/// triggering a card-master-mismatch error.
|
||||
/// </summary>
|
||||
public const long DummyCardId = 100011010L;
|
||||
|
||||
/// <summary>
|
||||
/// Viewer id we present as the opponent on every scripted push. Out-of-range vs. real
|
||||
/// viewer ids so it can't collide with a real account in the auth pipeline.
|
||||
/// </summary>
|
||||
public const long FakeOpponentViewerId = 999_999_999L;
|
||||
|
||||
public static MsgEnvelope BuildMatched(long playerViewerId, long opponentViewerId, string battleId) =>
|
||||
public static MsgEnvelope BuildMatched(MatchContext ctx, long playerViewerId, long opponentViewerId, string battleId) =>
|
||||
EnvelopeForPush(NetworkBattleUri.Matched,
|
||||
new MatchedBody(
|
||||
SelfInfo: ScriptedProfiles.PlayerMatchedProfile with { OppoId = opponentViewerId },
|
||||
SelfInfo: new MatchedSelfInfo(
|
||||
CountryCode: ctx.CountryCode,
|
||||
UserName: ctx.UserName,
|
||||
SleeveId: ctx.SleeveId,
|
||||
EmblemId: ctx.EmblemId,
|
||||
DegreeId: ctx.DegreeId,
|
||||
FieldId: ctx.FieldId,
|
||||
IsOfficial: ctx.IsOfficial,
|
||||
OppoId: opponentViewerId,
|
||||
Seed: ScriptedProfiles.BattleSeed),
|
||||
OppoInfo: ScriptedProfiles.OpponentMatchedProfile with { OppoId = playerViewerId },
|
||||
SelfDeck: BuildDummyDeck()),
|
||||
SelfDeck: BuildPlayerDeck(ctx.SelfDeckCardIds)),
|
||||
bid: battleId);
|
||||
|
||||
public static MsgEnvelope BuildBattleStart(long playerViewerId) =>
|
||||
@@ -104,12 +108,12 @@ public static class ScriptedLifecycle
|
||||
return list;
|
||||
}
|
||||
|
||||
private static IReadOnlyList<DeckCardRef> BuildDummyDeck()
|
||||
private static IReadOnlyList<DeckCardRef> BuildPlayerDeck(IReadOnlyList<long> cardIds)
|
||||
{
|
||||
var deck = new List<DeckCardRef>(30);
|
||||
for (var i = 1; i <= 30; i++)
|
||||
var deck = new List<DeckCardRef>(cardIds.Count);
|
||||
for (var i = 0; i < cardIds.Count; i++)
|
||||
{
|
||||
deck.Add(new DeckCardRef(Idx: i, CardId: DummyCardId));
|
||||
deck.Add(new DeckCardRef(Idx: i + 1, CardId: cardIds[i]));
|
||||
}
|
||||
return deck;
|
||||
}
|
||||
|
||||
@@ -15,18 +15,6 @@ internal static class ScriptedProfiles
|
||||
// From frame[2] (Matched).
|
||||
public const long BattleSeed = 17_548_138L;
|
||||
|
||||
// From frame[2] (Matched). OppoId is overwritten per battle from the bridge.
|
||||
public static readonly MatchedSelfInfo PlayerMatchedProfile = new(
|
||||
CountryCode: "KOR",
|
||||
UserName: "Player",
|
||||
SleeveId: "3000011",
|
||||
EmblemId: "701441011",
|
||||
DegreeId: "300003",
|
||||
FieldId: 43,
|
||||
IsOfficial: 0,
|
||||
OppoId: 0,
|
||||
Seed: BattleSeed);
|
||||
|
||||
public static readonly MatchedOppoInfo OpponentMatchedProfile = new(
|
||||
CountryCode: "JPN",
|
||||
UserName: "Opponent",
|
||||
|
||||
@@ -235,7 +235,7 @@ public sealed class BattleSession
|
||||
Phase = BattleSessionPhase.AwaitingInitBattle;
|
||||
break;
|
||||
case NetworkBattleUri.InitBattle when Phase == BattleSessionPhase.AwaitingInitBattle:
|
||||
result.Add((ScriptedLifecycle.BuildMatched(ViewerId, ScriptedLifecycle.FakeOpponentViewerId, BattleId), NoStock: false));
|
||||
result.Add((ScriptedLifecycle.BuildMatched(Context, ViewerId, ScriptedLifecycle.FakeOpponentViewerId, BattleId), NoStock: false));
|
||||
Phase = BattleSessionPhase.AwaitingLoaded;
|
||||
break;
|
||||
case NetworkBattleUri.Loaded when Phase == BattleSessionPhase.AwaitingLoaded:
|
||||
|
||||
Reference in New Issue
Block a user