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:
gamer147
2026-06-03 20:15:48 -04:00
parent 8085119439
commit f21ab7a38c
21 changed files with 49 additions and 395 deletions

View File

@@ -12,18 +12,24 @@ namespace SVSim.UnitTests.Controllers;
public class ArenaTwoPickBattleControllerTests
{
[Test]
public async Task DoMatching_AuthenticatedViewer_Returns3004WithBattleIdAndNodeUrl()
public async Task DoMatching_joiner_Returns3004WithBattleIdAndNodeUrlAndCardMaster()
{
using var factory = new SVSimTestFactory();
var viewerId = await factory.SeedViewerAsync();
await SeedCompleteTwoPickRunAsync(factory, viewerId);
var vidA = await factory.SeedViewerAsync(steamId: 76_561_198_000_000_021UL);
var vidB = await factory.SeedViewerAsync(steamId: 76_561_198_000_000_022UL);
await SeedCompleteTwoPickRunAsync(factory, vidA);
await SeedCompleteTwoPickRunAsync(factory, vidB);
using var clientA = factory.CreateAuthenticatedClient(vidA);
using var clientB = factory.CreateAuthenticatedClient(vidB);
using var client = factory.CreateAuthenticatedClient(viewerId);
var req = new {
deck_no = 1L, need_init = 1, log = 1, excluded_field_id_list = new long[] { }, use_stage_select = 1, is_default_skin = 0,
viewer_id = "0", steam_id = 0, steam_session_ticket = "",
};
var resp = await client.PostAsync("/arena_two_pick_battle/do_matching?scripted=1", JsonContent.Create(req));
// A parks first; B triggers the pair and gets the 3004 joiner response.
await clientA.PostAsync("/arena_two_pick_battle/do_matching", JsonContent.Create(req));
var resp = await clientB.PostAsync("/arena_two_pick_battle/do_matching", JsonContent.Create(req));
Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK));
var body = await resp.Content.ReadAsStringAsync();
@@ -72,29 +78,6 @@ public class ArenaTwoPickBattleControllerTests
Assert.That(root.GetProperty("node_server_url").GetString(), Is.EqualTo(""));
}
[Test]
public async Task DoMatching_with_scripted_flag_returns_3004_Scripted_match_immediately()
{
using var factory = new SVSimTestFactory();
var vid = await factory.SeedViewerAsync();
await SeedCompleteTwoPickRunAsync(factory, vid);
using var client = factory.CreateAuthenticatedClient(vid);
var req = new {
deck_no = 1L, need_init = 1, log = 1, excluded_field_id_list = new long[] { }, use_stage_select = 1, is_default_skin = 0,
viewer_id = "0", steam_id = 0, steam_session_ticket = "",
};
var resp = await client.PostAsync("/arena_two_pick_battle/do_matching?scripted=1", JsonContent.Create(req));
Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK));
var body = await resp.Content.ReadAsStringAsync();
using var doc = JsonDocument.Parse(body);
var root = doc.RootElement;
Assert.That(root.GetProperty("matching_state").GetInt32(), Is.EqualTo(3004));
Assert.That(root.GetProperty("battle_id").GetString(), Is.Not.Null.And.Not.Empty);
}
[Test]
public async Task DoMatching_two_pollers_get_3004_joiner_and_3007_owner_with_same_BattleId()
{
@@ -137,35 +120,6 @@ public class ArenaTwoPickBattleControllerTests
"Owner and joiner must see the same node_server_url.");
}
[Test]
public async Task DoMatching_SoloDefaultsToScripted_flag_makes_solo_poll_return_3004_without_query_param()
{
using var factory = new SVSimTestFactory();
// BattleNodeOptions is a singleton in DI; flipping it before the request takes
// effect immediately for this factory. Real deployments toggle it via the
// "BattleNode:SoloDefaultsToScripted" key in appsettings*.json.
factory.Services.GetRequiredService<BattleNodeOptions>().SoloDefaultsToScripted = true;
var vid = await factory.SeedViewerAsync();
await SeedCompleteTwoPickRunAsync(factory, vid);
using var client = factory.CreateAuthenticatedClient(vid);
var req = new {
deck_no = 1L, need_init = 1, log = 1, excluded_field_id_list = new long[] { }, use_stage_select = 1, is_default_skin = 0,
viewer_id = "0", steam_id = 0, steam_session_ticket = "",
};
// No ?scripted=1 — the flag alone should drive the Scripted branch.
var resp = await client.PostAsync("/arena_two_pick_battle/do_matching", JsonContent.Create(req));
Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK));
using var doc = JsonDocument.Parse(await resp.Content.ReadAsStringAsync());
var root = doc.RootElement;
Assert.That(root.GetProperty("matching_state").GetInt32(), Is.EqualTo(3004),
"SoloDefaultsToScripted=true should bypass pair-up and return a Scripted 3004 SUCCEEDED.");
Assert.That(root.GetProperty("battle_id").GetString(), Is.Not.Null.And.Not.Empty);
Assert.That(root.GetProperty("node_server_url").GetString(), Does.Contain("/socket.io/"));
}
[Test]
public async Task DoMatching_NoActiveRun_Returns400WithErrorCode()