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:
@@ -22,35 +22,58 @@ public static class ScriptedLifecycle
|
||||
/// </summary>
|
||||
public const long FakeOpponentViewerId = 999_999_999L;
|
||||
|
||||
public static MsgEnvelope BuildMatched(MatchContext ctx, long playerViewerId, long opponentViewerId, string battleId) =>
|
||||
public static MsgEnvelope BuildMatched(
|
||||
MatchContext selfCtx, MatchContext oppoCtx,
|
||||
long selfViewerId, long oppoViewerId,
|
||||
string battleId, long seed) =>
|
||||
EnvelopeForPush(NetworkBattleUri.Matched,
|
||||
new MatchedBody(
|
||||
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: BuildPlayerDeck(ctx.SelfDeckCardIds)),
|
||||
CountryCode: selfCtx.CountryCode,
|
||||
UserName: selfCtx.UserName,
|
||||
SleeveId: selfCtx.SleeveId,
|
||||
EmblemId: selfCtx.EmblemId,
|
||||
DegreeId: selfCtx.DegreeId,
|
||||
FieldId: selfCtx.FieldId,
|
||||
IsOfficial: selfCtx.IsOfficial,
|
||||
OppoId: oppoViewerId,
|
||||
Seed: seed),
|
||||
OppoInfo: new MatchedOppoInfo(
|
||||
CountryCode: oppoCtx.CountryCode,
|
||||
UserName: oppoCtx.UserName,
|
||||
SleeveId: oppoCtx.SleeveId,
|
||||
EmblemId: oppoCtx.EmblemId,
|
||||
DegreeId: oppoCtx.DegreeId,
|
||||
FieldId: oppoCtx.FieldId,
|
||||
IsOfficial: oppoCtx.IsOfficial,
|
||||
OppoId: selfViewerId,
|
||||
Seed: seed,
|
||||
OppoDeckCount: oppoCtx.SelfDeckCardIds.Count),
|
||||
SelfDeck: BuildPlayerDeck(selfCtx.SelfDeckCardIds)),
|
||||
bid: battleId);
|
||||
|
||||
public static MsgEnvelope BuildBattleStart(MatchContext ctx, long playerViewerId) =>
|
||||
public static MsgEnvelope BuildBattleStart(
|
||||
MatchContext selfCtx, MatchContext oppoCtx, long selfViewerId) =>
|
||||
EnvelopeForPush(NetworkBattleUri.BattleStart,
|
||||
new BattleStartBody(
|
||||
TurnState: 0, // player goes first
|
||||
BattleType: ctx.BattleType,
|
||||
BattleType: selfCtx.BattleType,
|
||||
SelfInfo: new BattleStartSelfInfo(
|
||||
Rank: ScriptedProfiles.PlayerRank,
|
||||
BattlePoint: ScriptedProfiles.PlayerBattlePoint,
|
||||
ClassId: ctx.ClassId,
|
||||
CharaId: ctx.CharaId,
|
||||
CardMasterName: ctx.CardMasterName),
|
||||
OppoInfo: ScriptedProfiles.OpponentBattleStartProfile));
|
||||
ClassId: selfCtx.ClassId,
|
||||
CharaId: selfCtx.CharaId,
|
||||
CardMasterName: selfCtx.CardMasterName),
|
||||
OppoInfo: new BattleStartOppoInfo(
|
||||
// Rank/IsMasterRank/BattlePoint/MasterPoint stay hardcoded —
|
||||
// PvP rank tracking is deferred (per spec § Out of scope).
|
||||
Rank: "1",
|
||||
IsMasterRank: "0",
|
||||
BattlePoint: 0,
|
||||
MasterPoint: "0",
|
||||
ClassId: oppoCtx.ClassId,
|
||||
CharaId: oppoCtx.CharaId,
|
||||
CardMasterName: oppoCtx.CardMasterName)));
|
||||
|
||||
public static MsgEnvelope BuildDeal() =>
|
||||
EnvelopeForPush(NetworkBattleUri.Deal,
|
||||
|
||||
Reference in New Issue
Block a user