feat(battle-node): BuildBattleStart consumes MatchContext for player half
ClassId/CharaId/CardMasterName/BattleType flow from ctx. PlayerBattleStart Profile removed; Rank/BattlePoint remain as standalone consts pending real per-viewer rank tracker. One test updated, one new test added. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -38,12 +38,17 @@ public static class ScriptedLifecycle
|
|||||||
SelfDeck: BuildPlayerDeck(ctx.SelfDeckCardIds)),
|
SelfDeck: BuildPlayerDeck(ctx.SelfDeckCardIds)),
|
||||||
bid: battleId);
|
bid: battleId);
|
||||||
|
|
||||||
public static MsgEnvelope BuildBattleStart(long playerViewerId) =>
|
public static MsgEnvelope BuildBattleStart(MatchContext ctx, long playerViewerId) =>
|
||||||
EnvelopeForPush(NetworkBattleUri.BattleStart,
|
EnvelopeForPush(NetworkBattleUri.BattleStart,
|
||||||
new BattleStartBody(
|
new BattleStartBody(
|
||||||
TurnState: 0, // player goes first
|
TurnState: 0, // player goes first
|
||||||
BattleType: 11, // TK2 NetworkBattleType
|
BattleType: ctx.BattleType,
|
||||||
SelfInfo: ScriptedProfiles.PlayerBattleStartProfile,
|
SelfInfo: new BattleStartSelfInfo(
|
||||||
|
Rank: ScriptedProfiles.PlayerRank,
|
||||||
|
BattlePoint: ScriptedProfiles.PlayerBattlePoint,
|
||||||
|
ClassId: ctx.ClassId,
|
||||||
|
CharaId: ctx.CharaId,
|
||||||
|
CardMasterName: ctx.CardMasterName),
|
||||||
OppoInfo: ScriptedProfiles.OpponentBattleStartProfile));
|
OppoInfo: ScriptedProfiles.OpponentBattleStartProfile));
|
||||||
|
|
||||||
public static MsgEnvelope BuildDeal() =>
|
public static MsgEnvelope BuildDeal() =>
|
||||||
|
|||||||
@@ -27,13 +27,10 @@ internal static class ScriptedProfiles
|
|||||||
Seed: BattleSeed,
|
Seed: BattleSeed,
|
||||||
OppoDeckCount: 30);
|
OppoDeckCount: 30);
|
||||||
|
|
||||||
// From frame[5] (BattleStart).
|
// From frame[5] (BattleStart). Hardcoded; see spec §Deferred plumbing — sourcing these
|
||||||
public static readonly BattleStartSelfInfo PlayerBattleStartProfile = new(
|
// from real per-viewer state needs a TK2 rank/battle-point tracker.
|
||||||
Rank: "10",
|
public const string PlayerRank = "10";
|
||||||
BattlePoint: "6270",
|
public const string PlayerBattlePoint = "6270";
|
||||||
ClassId: "1",
|
|
||||||
CharaId: "1",
|
|
||||||
CardMasterName: "card_master_node_10015");
|
|
||||||
|
|
||||||
public static readonly BattleStartOppoInfo OpponentBattleStartProfile = new(
|
public static readonly BattleStartOppoInfo OpponentBattleStartProfile = new(
|
||||||
Rank: "1",
|
Rank: "1",
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ public sealed class BattleSession
|
|||||||
Phase = BattleSessionPhase.AwaitingLoaded;
|
Phase = BattleSessionPhase.AwaitingLoaded;
|
||||||
break;
|
break;
|
||||||
case NetworkBattleUri.Loaded when Phase == BattleSessionPhase.AwaitingLoaded:
|
case NetworkBattleUri.Loaded when Phase == BattleSessionPhase.AwaitingLoaded:
|
||||||
result.Add((ScriptedLifecycle.BuildBattleStart(ViewerId), NoStock: false));
|
result.Add((ScriptedLifecycle.BuildBattleStart(Context, ViewerId), NoStock: false));
|
||||||
result.Add((ScriptedLifecycle.BuildDeal(), NoStock: false));
|
result.Add((ScriptedLifecycle.BuildDeal(), NoStock: false));
|
||||||
Phase = BattleSessionPhase.AwaitingSwap;
|
Phase = BattleSessionPhase.AwaitingSwap;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -68,14 +68,33 @@ public class ScriptedLifecycleTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void BuildBattleStart_HasTurnStateZeroAndBattleTypeEleven()
|
public void BuildBattleStart_HasTurnStateZero_AndUsesContextBattleType()
|
||||||
{
|
{
|
||||||
var env = ScriptedLifecycle.BuildBattleStart(playerViewerId: 1);
|
var env = ScriptedLifecycle.BuildBattleStart(FixtureCtx(), playerViewerId: 1);
|
||||||
var body = (BattleStartBody)env.Body;
|
var body = (BattleStartBody)env.Body;
|
||||||
Assert.That(body.TurnState, Is.EqualTo(0));
|
Assert.That(body.TurnState, Is.EqualTo(0));
|
||||||
Assert.That(body.BattleType, Is.EqualTo(11));
|
Assert.That(body.BattleType, Is.EqualTo(11));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void BuildBattleStart_class_chara_cardMaster_battleType_flow_from_context()
|
||||||
|
{
|
||||||
|
var ctx = FixtureCtx() with
|
||||||
|
{
|
||||||
|
ClassId = "7", CharaId = "5000123",
|
||||||
|
CardMasterName = "card_master_test_v2",
|
||||||
|
BattleType = 42,
|
||||||
|
};
|
||||||
|
|
||||||
|
var env = ScriptedLifecycle.BuildBattleStart(ctx, playerViewerId: 1);
|
||||||
|
var body = (BattleStartBody)env.Body;
|
||||||
|
|
||||||
|
Assert.That(body.SelfInfo.ClassId, Is.EqualTo("7"));
|
||||||
|
Assert.That(body.SelfInfo.CharaId, Is.EqualTo("5000123"));
|
||||||
|
Assert.That(body.SelfInfo.CardMasterName, Is.EqualTo("card_master_test_v2"));
|
||||||
|
Assert.That(body.BattleType, Is.EqualTo(42));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void BuildDeal_HasThreeSelfAndThreeOppoEntries()
|
public void BuildDeal_HasThreeSelfAndThreeOppoEntries()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class TypedBodyWireShapeTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void BuildBattleStart_SerializesAllWireKeysAndPreservesBattlePointAsymmetry()
|
public void BuildBattleStart_SerializesAllWireKeysAndPreservesBattlePointAsymmetry()
|
||||||
{
|
{
|
||||||
var env = ScriptedLifecycle.BuildBattleStart(playerViewerId: 906243102);
|
var env = ScriptedLifecycle.BuildBattleStart(FixtureCtx(), playerViewerId: 906243102);
|
||||||
|
|
||||||
var json = MsgEnvelope.ToJson(env);
|
var json = MsgEnvelope.ToJson(env);
|
||||||
var node = JsonNode.Parse(json)!.AsObject();
|
var node = JsonNode.Parse(json)!.AsObject();
|
||||||
|
|||||||
Reference in New Issue
Block a user