refactor(battle-node): remove ScriptedBotParticipant and dev-affordance wiring
Deletes the scripted opponent and every entry point that created a BattleType.Scripted session (the ?scripted=1 query opt-in, the SoloDefaultsToScripted toggle, the resolver short-circuit, the WS handler case, the bridge validation arm). Real two-client PvP and the Bot matchmaking-timeout fallback are untouched. ResolveAsync drops its scriptedOptIn parameter. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -8,19 +8,19 @@ namespace SVSim.UnitTests.BattleNode.Bridge;
|
||||
public class MatchingBridgeTests
|
||||
{
|
||||
[Test]
|
||||
public void RegisterBattle_Scripted_stores_pending_and_returns_node_url()
|
||||
public void RegisterBattle_Bot_stores_pending_and_returns_node_url()
|
||||
{
|
||||
var store = new InMemoryBattleSessionStore();
|
||||
var bridge = new MatchingBridge(store, new BattleNodeOptions { NodeServerUrl = "localhost:5148/socket.io/" });
|
||||
var p1 = new BattlePlayer(906243102, FixtureCtx());
|
||||
|
||||
var match = bridge.RegisterBattle(p1, p2: null, BattleType.Scripted);
|
||||
var match = bridge.RegisterBattle(p1, p2: null, BattleType.Bot);
|
||||
|
||||
Assert.That(match.NodeServerUrl, Is.EqualTo("localhost:5148/socket.io/"));
|
||||
Assert.That(match.BattleId, Is.Not.Empty);
|
||||
var pending = store.TryGetPending(match.BattleId);
|
||||
Assert.That(pending, Is.Not.Null);
|
||||
Assert.That(pending!.Type, Is.EqualTo(BattleType.Scripted));
|
||||
Assert.That(pending!.Type, Is.EqualTo(BattleType.Bot));
|
||||
Assert.That(pending.P1.ViewerId, Is.EqualTo(906243102));
|
||||
Assert.That(pending.P2, Is.Null);
|
||||
}
|
||||
@@ -30,8 +30,8 @@ public class MatchingBridgeTests
|
||||
{
|
||||
var bridge = new MatchingBridge(new InMemoryBattleSessionStore(), new BattleNodeOptions());
|
||||
|
||||
var a = bridge.RegisterBattle(new BattlePlayer(1, FixtureCtx()), null, BattleType.Scripted);
|
||||
var b = bridge.RegisterBattle(new BattlePlayer(2, FixtureCtx()), null, BattleType.Scripted);
|
||||
var a = bridge.RegisterBattle(new BattlePlayer(1, FixtureCtx()), null, BattleType.Bot);
|
||||
var b = bridge.RegisterBattle(new BattlePlayer(2, FixtureCtx()), null, BattleType.Bot);
|
||||
|
||||
Assert.That(a.BattleId, Is.Not.EqualTo(b.BattleId));
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class MatchingBridgeTests
|
||||
{
|
||||
var bridge = new MatchingBridge(new InMemoryBattleSessionStore(), new BattleNodeOptions());
|
||||
|
||||
var match = bridge.RegisterBattle(new BattlePlayer(1, FixtureCtx()), null, BattleType.Scripted);
|
||||
var match = bridge.RegisterBattle(new BattlePlayer(1, FixtureCtx()), null, BattleType.Bot);
|
||||
|
||||
Assert.That(match.BattleId, Has.Length.EqualTo(12));
|
||||
Assert.That(match.BattleId, Does.Match("^[0-9]{12}$"));
|
||||
|
||||
@@ -173,8 +173,8 @@ public class ScriptedLifecycleTests
|
||||
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.
|
||||
// A prod-captured opponent MatchContext fixture that the 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",
|
||||
|
||||
@@ -159,7 +159,7 @@ public class TypedBodyWireShapeTests
|
||||
EmblemId: "701441011", DegreeId: "300003", FieldId: 43, IsOfficial: 0,
|
||||
BattleType: 11);
|
||||
|
||||
// Mirrors ScriptedBotParticipant.Context — 30-card deck and the prod-captured opponent
|
||||
// Prod-captured opponent fixture — 30-card deck and the prod-captured opponent
|
||||
// cosmetics (ClassId/CharaId "8") so the wire bytes asserted below (oppoInfo classId/charaId,
|
||||
// oppoDeckCount=30, etc.) remain byte-identical after the BuildMatched/BuildBattleStart
|
||||
// signature change.
|
||||
|
||||
@@ -12,9 +12,8 @@ namespace SVSim.UnitTests.BattleNode.Sessions;
|
||||
/// <summary>
|
||||
/// Audit Md11 — confirms <see cref="BattleSession.RunAsync"/> drops the per-RealParticipant
|
||||
/// <see cref="SVSim.BattleNode.Reliability.OutboundSequencer"/> archive when the session
|
||||
/// terminates. The Scripted bot has no outbound archive of its own, so the test uses a
|
||||
/// Scripted session (one Real, one ScriptedBot) and asserts only the Real side's archive
|
||||
/// is cleared.
|
||||
/// terminates. The NoOp bot has no outbound archive of its own, so the test uses a Bot
|
||||
/// session (one Real, one NoOpBot) and asserts only the Real side's archive is cleared.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class BattleSessionTerminateCascadeTests
|
||||
@@ -25,7 +24,7 @@ public class BattleSessionTerminateCascadeTests
|
||||
var ws = new TestWebSocket();
|
||||
var real = new RealParticipant(
|
||||
ws, viewerId: 1, MakeFakeContext(), NullLogger<RealParticipant>.Instance);
|
||||
var bot = new ScriptedBotParticipant();
|
||||
var bot = new NoOpBotParticipant();
|
||||
|
||||
// Pre-load the archive so we can prove it was cleared (not just empty).
|
||||
real.Outbound.AssignAndArchive(MakeEnvelope(NetworkBattleUri.Matched));
|
||||
@@ -33,7 +32,7 @@ public class BattleSessionTerminateCascadeTests
|
||||
Assume.That(real.Outbound.Archive.Count, Is.EqualTo(2), "Precondition: archive populated.");
|
||||
|
||||
var session = new BattleSession(
|
||||
battleId: "test-bid", type: BattleType.Scripted,
|
||||
battleId: "test-bid", type: BattleType.Bot,
|
||||
a: real, b: bot, log: NullLogger<BattleSession>.Instance);
|
||||
|
||||
// Drive RunAsync to completion: closing the incoming side causes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework;
|
||||
using SVSim.BattleNode.Bridge;
|
||||
using SVSim.BattleNode.Sessions;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class InMemoryBattleSessionStoreTests
|
||||
[Test]
|
||||
public void RegisterThenGet_ReturnsRegisteredBattle()
|
||||
{
|
||||
var battle = new PendingBattle("bid-1", BattleType.Scripted, new BattlePlayer(906243102, FixtureCtx()), null);
|
||||
var battle = new PendingBattle("bid-1", BattleType.Bot, new BattlePlayer(906243102, FixtureCtx()), null);
|
||||
_store.RegisterPending(battle);
|
||||
|
||||
Assert.That(_store.TryGetPending("bid-1"), Is.EqualTo(battle));
|
||||
@@ -29,7 +29,7 @@ public class InMemoryBattleSessionStoreTests
|
||||
[Test]
|
||||
public void Remove_ReturnsTrueWhenPresent_FalseWhenAbsent()
|
||||
{
|
||||
_store.RegisterPending(new PendingBattle("bid", BattleType.Scripted, new BattlePlayer(1, FixtureCtx()), null));
|
||||
_store.RegisterPending(new PendingBattle("bid", BattleType.Bot, new BattlePlayer(1, FixtureCtx()), null));
|
||||
Assert.That(_store.RemovePending("bid"), Is.True);
|
||||
Assert.That(_store.RemovePending("bid"), Is.False);
|
||||
}
|
||||
@@ -37,8 +37,8 @@ public class InMemoryBattleSessionStoreTests
|
||||
[Test]
|
||||
public void Register_DuplicateBattleId_OverwritesPrior()
|
||||
{
|
||||
_store.RegisterPending(new PendingBattle("bid", BattleType.Scripted, new BattlePlayer(1, FixtureCtx()), null));
|
||||
_store.RegisterPending(new PendingBattle("bid", BattleType.Scripted, new BattlePlayer(2, FixtureCtx()), null));
|
||||
_store.RegisterPending(new PendingBattle("bid", BattleType.Bot, new BattlePlayer(1, FixtureCtx()), null));
|
||||
_store.RegisterPending(new PendingBattle("bid", BattleType.Bot, new BattlePlayer(2, FixtureCtx()), null));
|
||||
Assert.That(_store.TryGetPending("bid")!.P1.ViewerId, Is.EqualTo(2));
|
||||
}
|
||||
|
||||
@@ -49,3 +49,4 @@ public class InMemoryBattleSessionStoreTests
|
||||
EmblemId: "701441011", DegreeId: "300003", FieldId: 43, IsOfficial: 0,
|
||||
BattleType: 11);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user