feat(battle-node): client-shaped handshake builders for the scripted bot

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-03 10:49:38 -04:00
parent 633c29b44f
commit a533e9d89d
2 changed files with 52 additions and 0 deletions

View File

@@ -127,6 +127,37 @@ public static class ScriptedLifecycle
IdxChangeSeed: ScriptedProfiles.ReadyIdxChangeSeed,
Spin: ScriptedProfiles.ReadySpin));
// --- Client-shaped emissions used by ScriptedBotParticipant so the session brokers
// the bot through the same handshake arms as a human. Bodies for the parameterless
// handshake frames are ignored by the session (it reads from.Context / phase); only
// Swap's idxList is consumed (empty = keep the dealt hand).
public static MsgEnvelope BuildClientInitNetwork() => ClientFrame(NetworkBattleUri.InitNetwork, EmitCategory.General);
public static MsgEnvelope BuildClientInitBattle() => ClientFrame(NetworkBattleUri.InitBattle, EmitCategory.General);
public static MsgEnvelope BuildClientLoaded() => ClientFrame(NetworkBattleUri.Loaded, EmitCategory.General);
public static MsgEnvelope BuildClientSwap() =>
new(NetworkBattleUri.Swap,
ViewerId: FakeOpponentViewerId,
Uuid: WireConstants.ServerUuid,
Bid: null,
Try: 0,
Cat: EmitCategory.Battle,
PubSeq: null,
PlaySeq: null,
Body: new RawBody(new Dictionary<string, object?> { ["idxList"] = new List<object?>() }));
private static MsgEnvelope ClientFrame(NetworkBattleUri uri, EmitCategory cat) =>
new(uri,
ViewerId: FakeOpponentViewerId,
Uuid: WireConstants.ServerUuid,
Bid: null,
Try: 0,
Cat: cat,
PubSeq: null,
PlaySeq: null,
Body: new ResultCodeOnlyBody());
/// <summary>
/// First half of the v1.1 scripted opponent turn cycle: pushed after the player's
/// TurnEnd, transitions the client into "Opponent's turn…" state. Paired with