refactor(battlenode): type MatchContext.ClassId as CardClass enum (§C)

Behavior-preserving; full solution builds, 1013 tests green.

ClassId is the one genuinely-closed set of the three flagged stringly fields, so it
becomes a CardClass enum (1..8). Wire stays "1".."8": producer casts
(CardClass)run.ClassId, ServerBattleFrames renders via CardClassWire.ToWireValue().
RankBattleController's AI-start path drops a fragile int.TryParse(...)?:-1 for (int)cast.

CharaId (free-form leader/skin id, e.g. "5000123") and CountryCode (open-ended account
data) stay string with proper XML docs; CountryCodes.Korea/Japan name the captured values.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-05 08:04:49 -04:00
parent 9b8a7f1e37
commit 1007cf24d2
24 changed files with 114 additions and 59 deletions

View File

@@ -10,9 +10,9 @@ namespace SVSim.UnitTests.Matching;
[TestFixture]
public class BotRosterTests
{
private static MatchContext Ctx(string userName, string classId) => new(
private static MatchContext Ctx(string userName, CardClass classId) => new(
SelfDeckCardIds: Array.Empty<long>(),
ClassId: classId, CharaId: classId, CardMasterName: "card_master_node_10015",
ClassId: classId, CharaId: classId.ToWireValue(), CardMasterName: "card_master_node_10015",
CountryCode: "JP", UserName: userName, SleeveId: "0",
EmblemId: "0", DegreeId: "0", FieldId: 0, IsOfficial: 0, BattleModeId: BattleModes.TakeTwo);
@@ -30,7 +30,7 @@ public class BotRosterTests
using var factory = new SVSimTestFactory();
var roster = await NewRosterAsync(factory);
var bot = await roster.PickAsync(Ctx("PlayerA", "1"), "123456789012");
var bot = await roster.PickAsync(Ctx("PlayerA", CardClass.Forestcraft), "123456789012");
// 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).
@@ -44,7 +44,7 @@ public class BotRosterTests
using var factory = new SVSimTestFactory();
var roster = await NewRosterAsync(factory);
var bot = await roster.PickAsync(Ctx("PlayerA", "1"), "123456789012");
var bot = await roster.PickAsync(Ctx("PlayerA", CardClass.Forestcraft), "123456789012");
Assert.That(bot.ClassId, Is.InRange(1, 8));
Assert.That(bot.CharaId, Is.InRange(1, 8));
@@ -57,7 +57,7 @@ public class BotRosterTests
{
using var factory = new SVSimTestFactory();
var roster = await NewRosterAsync(factory);
var ctx = Ctx("PlayerA", "3");
var ctx = Ctx("PlayerA", CardClass.Runecraft);
var a = await roster.PickAsync(ctx, "999888777666");
var b = await roster.PickAsync(ctx, "999888777666");
@@ -70,7 +70,7 @@ public class BotRosterTests
{
using var factory = new SVSimTestFactory();
var roster = await NewRosterAsync(factory);
var ctx = Ctx("PlayerA", "3");
var ctx = Ctx("PlayerA", CardClass.Runecraft);
var seen = new HashSet<int>();
for (var i = 0; i < 20; i++)
@@ -91,7 +91,7 @@ public class BotRosterTests
var globals = scope.ServiceProvider.GetRequiredService<IGlobalsRepository>();
var roster = new BotRoster(globals);
Assert.That(async () => await roster.PickAsync(Ctx("PlayerA", "1"), "000000000001"),
Assert.That(async () => await roster.PickAsync(Ctx("PlayerA", CardClass.Forestcraft), "000000000001"),
Throws.InvalidOperationException);
}
}

View File

@@ -45,7 +45,7 @@ public class InProcessPairUpRankFallbackTests
private static BattlePlayer Player(long id) =>
new(id, new MatchContext(
SelfDeckCardIds: Array.Empty<long>(), ClassId: "0", CharaId: "0",
SelfDeckCardIds: Array.Empty<long>(), ClassId: CardClass.None, CharaId: "0",
CardMasterName: "card_master_node_10015",
CountryCode: "JP", UserName: $"P{id}", SleeveId: "0",
EmblemId: "0", DegreeId: "0", FieldId: 0, IsOfficial: 0, BattleModeId: BattleModes.TakeTwo));

View File

@@ -91,8 +91,8 @@ public class InProcessPairUpTests
private static MatchContext Ctx() => new(
SelfDeckCardIds: Enumerable.Range(1, 30).Select(_ => 100_011_010L).ToList(),
ClassId: "1", CharaId: "1", CardMasterName: "card_master_node_10015",
CountryCode: "KOR", UserName: "Player", SleeveId: "3000011",
ClassId: CardClass.Forestcraft, CharaId: "1", CardMasterName: "card_master_node_10015",
CountryCode: CountryCodes.Korea, UserName: "Player", SleeveId: "3000011",
EmblemId: "701441011", DegreeId: "300003", FieldId: 43, IsOfficial: 0,
BattleModeId: BattleModes.TakeTwo);
}

View File

@@ -28,7 +28,7 @@ public class MatchingResolverTests
private static BattlePlayer Player(long vid = 1) =>
new(vid, new MatchContext(
SelfDeckCardIds: Array.Empty<long>(), ClassId: "0", CharaId: "0",
SelfDeckCardIds: Array.Empty<long>(), ClassId: CardClass.None, CharaId: "0",
CardMasterName: "card_master_node_10015",
CountryCode: "JP", UserName: $"P{vid}", SleeveId: "0",
EmblemId: "0", DegreeId: "0", FieldId: 0, IsOfficial: 0, BattleModeId: BattleModes.TakeTwo));