Files
SVSimServer/SVSim.UnitTests/Matching/BotRosterTests.cs
gamer147 d87f9beb81 fix(rank-battle): use prod-verified bot cosmetic ids to unblock LoadOpponentAssets
The "Waiting for opponent" hang traced to BattleStartControl.IsReady never
flipping true. That's gated by SBattleLoad.LoadOpponentAssets which calls
ResourcesManager.LoadAssetGroupSync with the bot's
{rank, emblemId, degreeId, countryCode} — and our placeholder ids (1/1/1/"NONE")
don't resolve to any asset in the client's resource bundle, so the callback
never fires.

Replaced with the Scripted bot's known-good prod values:
- SleeveId: 704141010
- EmblemId: 400001100
- DegreeId: 120027
- FieldId: 5
- CountryCode: "JPN"
- IsOfficial: 0

These are the same ids ScriptedBotParticipant.Context uses, which we know
load fine because the TK2 Scripted flow has been working end-to-end since
Phase 2.

Reference for the load chain (decompiled client):
  BattleUI.WaitForSetUp → m_SBattleLoad.WaitCallBack
    → BattleStartControl.SetUp → CheckAbleToInitialize
    → SBattleLoad.LoadOpponentAssets (SBattleLoad.cs:933)
    → ResourcesManager.LoadAssetGroupSync — hangs on missing assets

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-02 11:09:20 -04:00

52 lines
1.8 KiB
C#

using NUnit.Framework;
using SVSim.BattleNode.Bridge;
using SVSim.EmulatedEntrypoint.Matching;
namespace SVSim.UnitTests.Matching;
[TestFixture]
public class BotRosterTests
{
private static MatchContext Ctx(string userName, string classId) => new(
SelfDeckCardIds: Array.Empty<long>(),
ClassId: classId, CharaId: classId, CardMasterName: "card_master_node_10015",
CountryCode: "JP", UserName: userName, SleeveId: "0",
EmblemId: "0", DegreeId: "0", FieldId: 0, IsOfficial: 0, BattleType: 11);
[Test]
public void Pick_returns_a_bot_with_valid_ai_id_from_rm_ai_setting()
{
var roster = new BotRoster();
var bot = roster.Pick(Ctx("PlayerA", "1"));
// Series-1 enemy_ai_id values from data_dumps/client-assets/rm_ai_setting.csv —
// one per class (1=Forest, 2=Sword, 3=Rune, 4=Dragon, 5=Shadow, 6=Blood, 7=Haven, 8=Portal).
// Must match a real row or the client's RankMatchAISettingList.GetSettingData() throws.
Assert.That(bot.AiId, Is.AnyOf(1111, 1121, 1131, 1141, 1151, 1161, 1171, 1181));
}
[Test]
public void Pick_returns_bot_with_class_metadata_set()
{
var roster = new BotRoster();
var bot = roster.Pick(Ctx("PlayerA", "1"));
Assert.That(bot.ClassId, Is.InRange(1, 8));
Assert.That(bot.CharaId, Is.InRange(1, 8));
Assert.That(bot.UserName, Is.Not.Null.And.Not.Empty);
Assert.That(bot.CountryCode, Is.Not.Null.And.Not.Empty);
}
[Test]
public void Pick_is_deterministic_per_match_context()
{
var roster = new BotRoster();
var ctx = Ctx("PlayerA", "3");
var a = roster.Pick(ctx);
var b = roster.Pick(ctx);
Assert.That(a, Is.EqualTo(b), "Same ctx → same bot, so mid-flight retries get the same opponent.");
}
}