Files
SVSimServer/SVSim.UnitTests/Matching/BotRosterTests.cs
gamer147 45c4461515 fix(rank-battle): use real rm_ai_setting.csv ai_id values in BotRoster
Phase 3 shipped placeholder ai_id values 4001..4008, which the client's
RankMatchAISettingList.GetSettingData() couldn't resolve — the lookup
is .First() against the rm_ai_setting.csv master table and throws
InvalidOperationException ("Sequence contains no matching element")
when the id isn't present. Surfaced on live smoke as a Unity error
during battle load:

  Wizard.RankMatchAISettingDataSet.GetSettingData (System.Int32 enemyAiId)
  BattleUI+<WaitForSetUp>d__9.MoveNext ()

Replaced with the series-1 enemy_ai_id per class from
data_dumps/client-assets/rm_ai_setting.csv:
  1111=Forest, 1121=Sword, 1131=Rune, 1141=Dragon,
  1151=Shadow, 1161=Blood, 1171=Haven, 1181=Portal

Practice mode's AI catalog (practice_ai_setting.csv) uses a different
schema keyed by (class_id, difficulty) with no enemy_ai_id field, so
practice ids aren't reusable here.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-02 09:41:38 -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.EqualTo("NONE"));
}
[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.");
}
}