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:
29
SVSim.BattleNode/Bridge/CardClass.cs
Normal file
29
SVSim.BattleNode/Bridge/CardClass.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
namespace SVSim.BattleNode.Bridge;
|
||||
|
||||
/// <summary>
|
||||
/// A Shadowverse class (craft). The wire carries it as the stringified ordinal (<c>"1".."8"</c> on
|
||||
/// the <c>classId</c> field); this enum replaces that stringly-typed value on
|
||||
/// <see cref="MatchContext.ClassId"/> so the legal set lives in the type, not a trailing comment.
|
||||
/// <see cref="None"/> covers an unset / placeholder context. Use <see cref="CardClassWire.ToWireValue"/>
|
||||
/// to render the wire string.
|
||||
/// </summary>
|
||||
public enum CardClass
|
||||
{
|
||||
None = 0,
|
||||
Forestcraft = 1,
|
||||
Swordcraft = 2,
|
||||
Runecraft = 3,
|
||||
Dragoncraft = 4,
|
||||
Shadowcraft = 5,
|
||||
Bloodcraft = 6,
|
||||
Havencraft = 7,
|
||||
Portalcraft = 8,
|
||||
}
|
||||
|
||||
/// <summary>Wire rendering for <see cref="CardClass"/>.</summary>
|
||||
public static class CardClassWire
|
||||
{
|
||||
/// <summary>The <c>classId</c> wire value — the class ordinal as a string (<c>"1".."8"</c>,
|
||||
/// <c>"0"</c> for <see cref="CardClass.None"/>), matching what the client sends/expects.</summary>
|
||||
public static string ToWireValue(this CardClass cardClass) => ((int)cardClass).ToString();
|
||||
}
|
||||
13
SVSim.BattleNode/Bridge/CountryCodes.cs
Normal file
13
SVSim.BattleNode/Bridge/CountryCodes.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace SVSim.BattleNode.Bridge;
|
||||
|
||||
/// <summary>
|
||||
/// Known values for <see cref="MatchContext.CountryCode"/>. NOT a closed set — the field is the
|
||||
/// account's region code copied verbatim from viewer data (any value, possibly empty), and the node
|
||||
/// never branches on it. These constants just name the values seen in the prod captures so test
|
||||
/// fixtures and docs aren't sprinkled with bare <c>"KOR"</c>/<c>"JPN"</c> literals.
|
||||
/// </summary>
|
||||
public static class CountryCodes
|
||||
{
|
||||
public const string Korea = "KOR";
|
||||
public const string Japan = "JPN";
|
||||
}
|
||||
@@ -12,12 +12,25 @@ public sealed record MatchContext(
|
||||
IReadOnlyList<long> SelfDeckCardIds,
|
||||
|
||||
// Player class + leader (BattleStartSelfInfo)
|
||||
string ClassId, // "1".."8"
|
||||
string CharaId, // "1".."8" — equals ClassId when no leader skin chosen
|
||||
|
||||
/// <summary>The player's class. Rendered onto the wire <c>classId</c> as <c>"1".."8"</c> via
|
||||
/// <see cref="CardClassWire.ToWireValue"/>; a closed set, so it's typed, not stringly.</summary>
|
||||
CardClass ClassId,
|
||||
|
||||
/// <summary>Leader/skin id on the wire <c>charaId</c>. FREE-FORM, not a class enum: it's the
|
||||
/// equipped leader-skin id (e.g. <c>"5000123"</c>) when one is chosen, else the class ordinal
|
||||
/// (<c>"1".."8"</c>). Passed through verbatim — the node never interprets it.</summary>
|
||||
string CharaId,
|
||||
|
||||
string CardMasterName, // current card-master, e.g. "card_master_node_10015"
|
||||
|
||||
// Player cosmetics (MatchedSelfInfo)
|
||||
string CountryCode, // "KOR", "JPN", ...
|
||||
|
||||
/// <summary>Account region code, wire <c>country_code</c>. OPEN-ENDED account data (any value,
|
||||
/// possibly empty); the node never branches on it. <see cref="CountryCodes"/> names the values
|
||||
/// seen in captures.</summary>
|
||||
string CountryCode,
|
||||
|
||||
string UserName,
|
||||
string SleeveId,
|
||||
string EmblemId,
|
||||
|
||||
@@ -59,7 +59,7 @@ public static class ServerBattleFrames
|
||||
SelfInfo: new BattleStartSelfInfo(
|
||||
Rank: BattleFrameDefaults.PlayerRank,
|
||||
BattlePoint: BattleFrameDefaults.PlayerBattlePoint,
|
||||
ClassId: selfCtx.ClassId,
|
||||
ClassId: selfCtx.ClassId.ToWireValue(),
|
||||
CharaId: selfCtx.CharaId,
|
||||
CardMasterName: selfCtx.CardMasterName),
|
||||
OppoInfo: new BattleStartOppoInfo(
|
||||
@@ -69,7 +69,7 @@ public static class ServerBattleFrames
|
||||
IsMasterRank: "0",
|
||||
BattlePoint: 0,
|
||||
MasterPoint: "0",
|
||||
ClassId: oppoCtx.ClassId,
|
||||
ClassId: oppoCtx.ClassId.ToWireValue(),
|
||||
CharaId: oppoCtx.CharaId,
|
||||
CardMasterName: oppoCtx.CardMasterName)));
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public sealed class NoOpBotParticipant : IBattleParticipant
|
||||
public long ViewerId => ServerBattleFrames.FakeOpponentViewerId;
|
||||
public MatchContext Context { get; } = new(
|
||||
SelfDeckCardIds: Array.Empty<long>(),
|
||||
ClassId: "0", CharaId: "0", CardMasterName: BotCardMasterName,
|
||||
ClassId: CardClass.None, CharaId: "0", CardMasterName: BotCardMasterName,
|
||||
CountryCode: "", UserName: "Bot", SleeveId: "0",
|
||||
EmblemId: "0", DegreeId: "0", FieldId: 0, IsOfficial: 0,
|
||||
BattleModeId: 0);
|
||||
|
||||
@@ -183,7 +183,7 @@ public sealed class RankBattleController : ControllerBase
|
||||
Seed = seed,
|
||||
Rank = 0,
|
||||
BattlePoint = 0,
|
||||
ClassId = int.TryParse(selfCtx.ClassId, out var cId) ? cId : -1,
|
||||
ClassId = (int)selfCtx.ClassId,
|
||||
CharaId = int.TryParse(selfCtx.CharaId, out var chId) ? chId : -1,
|
||||
IsMasterRank = 0,
|
||||
MasterPoint = 0,
|
||||
|
||||
@@ -54,7 +54,7 @@ public class MatchContextBuilder : IMatchContextBuilder
|
||||
|
||||
return new MatchContext(
|
||||
SelfDeckCardIds: deck,
|
||||
ClassId: run.ClassId.ToString(),
|
||||
ClassId: (CardClass)run.ClassId,
|
||||
CharaId: charaId,
|
||||
// Hardcoded v1; see spec §Deferred plumbing.
|
||||
CardMasterName: "card_master_node_10015",
|
||||
@@ -104,7 +104,7 @@ public class MatchContextBuilder : IMatchContextBuilder
|
||||
|
||||
return new MatchContext(
|
||||
SelfDeckCardIds: deckCardIds,
|
||||
ClassId: deck.Class.Id.ToString(),
|
||||
ClassId: (CardClass)deck.Class.Id,
|
||||
CharaId: charaId,
|
||||
CardMasterName: "card_master_node_10015",
|
||||
CountryCode: viewer.Info.CountryCode ?? string.Empty,
|
||||
|
||||
@@ -93,8 +93,8 @@ public class MatchingBridgeTests
|
||||
|
||||
private static MatchContext FixtureCtx() => new(
|
||||
SelfDeckCardIds: Enumerable.Range(1, 30).Select(i => 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);
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ public class WaitingRoomTests
|
||||
var ws = new TestWebSocket();
|
||||
var ctx = new MatchContext(
|
||||
SelfDeckCardIds: Array.Empty<long>(),
|
||||
ClassId: "1", CharaId: "1", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: "KOR", UserName: "Player", SleeveId: "0",
|
||||
ClassId: CardClass.Forestcraft, CharaId: "1", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: CountryCodes.Korea, UserName: "Player", SleeveId: "0",
|
||||
EmblemId: "0", DegreeId: "0", FieldId: 0, IsOfficial: 0,
|
||||
BattleModeId: BattleModes.TakeTwo);
|
||||
return new RealParticipant(ws, viewerId, ctx, NullLogger<RealParticipant>.Instance);
|
||||
|
||||
@@ -23,8 +23,8 @@ public class BattleNodeFlowTests
|
||||
|
||||
internal static MatchContext FixtureCtx(IReadOnlyList<long>? deck = null) => new(
|
||||
SelfDeckCardIds: deck ?? Enumerable.Range(1, 30).Select(i => 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);
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ServerBattleFramesTests
|
||||
{
|
||||
var ctx = FixtureCtx() with
|
||||
{
|
||||
ClassId = "7", CharaId = "5000123",
|
||||
ClassId = CardClass.Havencraft, CharaId = "5000123",
|
||||
CardMasterName = "card_master_test_v2",
|
||||
BattleModeId = 42,
|
||||
};
|
||||
@@ -168,8 +168,8 @@ public class ServerBattleFramesTests
|
||||
|
||||
private static MatchContext FixtureCtx(IReadOnlyList<long>? deck = null) => new(
|
||||
SelfDeckCardIds: deck ?? Enumerable.Range(1, 30).Select(i => 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);
|
||||
|
||||
@@ -177,8 +177,8 @@ public class ServerBattleFramesTests
|
||||
// helpers read from for the oppo half.
|
||||
private static MatchContext FakeOpponentCtx() => new(
|
||||
SelfDeckCardIds: Enumerable.Range(1, 30).Select(_ => 0L).ToList(),
|
||||
ClassId: "8", CharaId: "8", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: "JPN", UserName: "Opponent", SleeveId: "704141010",
|
||||
ClassId: CardClass.Portalcraft, CharaId: "8", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: CountryCodes.Japan, UserName: "Opponent", SleeveId: "704141010",
|
||||
EmblemId: "400001100", DegreeId: "120027", FieldId: 5, IsOfficial: 0,
|
||||
BattleModeId: 0);
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ public class TypedBodyWireShapeTests
|
||||
/// </summary>
|
||||
private static MatchContext FixtureCtx() => 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);
|
||||
|
||||
@@ -166,8 +166,8 @@ public class TypedBodyWireShapeTests
|
||||
// signature change.
|
||||
private static MatchContext FakeOpponentCtx() => new(
|
||||
SelfDeckCardIds: Enumerable.Range(1, 30).Select(_ => 0L).ToList(),
|
||||
ClassId: "8", CharaId: "8", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: "JPN", UserName: "Opponent", SleeveId: "704141010",
|
||||
ClassId: CardClass.Portalcraft, CharaId: "8", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: CountryCodes.Japan, UserName: "Opponent", SleeveId: "704141010",
|
||||
EmblemId: "400001100", DegreeId: "120027", FieldId: 5, IsOfficial: 0,
|
||||
BattleModeId: 0);
|
||||
}
|
||||
|
||||
@@ -62,14 +62,14 @@ public class BattleSessionDispatchConcurrencyTests
|
||||
|
||||
private static MatchContext CtxA() => new(
|
||||
SelfDeckCardIds: Enumerable.Range(1, 30).Select(_ => 100_011_010L).ToList(),
|
||||
ClassId: "3", CharaId: "3", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: "KOR", UserName: "PlayerA", SleeveId: "3000011",
|
||||
ClassId: CardClass.Runecraft, CharaId: "3", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: CountryCodes.Korea, UserName: "PlayerA", SleeveId: "3000011",
|
||||
EmblemId: "701441011", DegreeId: "300003", FieldId: 43, IsOfficial: 0, BattleModeId: BattleModes.TakeTwo);
|
||||
|
||||
private static MatchContext CtxB() => new(
|
||||
SelfDeckCardIds: Enumerable.Range(1, 30).Select(_ => 200_011_010L).ToList(),
|
||||
ClassId: "5", CharaId: "5", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: "JPN", UserName: "PlayerB", SleeveId: "3000022",
|
||||
ClassId: CardClass.Shadowcraft, CharaId: "5", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: CountryCodes.Japan, UserName: "PlayerB", SleeveId: "3000022",
|
||||
EmblemId: "701441022", DegreeId: "300004", FieldId: 44, IsOfficial: 0, BattleModeId: BattleModes.TakeTwo);
|
||||
|
||||
/// <summary>Tracks the peak number of dispatches in flight at once. Records the count under a
|
||||
|
||||
@@ -892,7 +892,7 @@ public class BattleSessionDispatchTests
|
||||
|
||||
private static MatchContext NoOpBotContext() => new(
|
||||
SelfDeckCardIds: Array.Empty<long>(),
|
||||
ClassId: "0", CharaId: "0", CardMasterName: "card_master_node_10015",
|
||||
ClassId: CardClass.None, CharaId: "0", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: "", UserName: "Bot", SleeveId: "0",
|
||||
EmblemId: "0", DegreeId: "0", FieldId: 0, IsOfficial: 0, BattleModeId: 0);
|
||||
|
||||
@@ -1048,22 +1048,22 @@ public class BattleSessionDispatchTests
|
||||
|
||||
private static MatchContext PlayerACtx() => new(
|
||||
SelfDeckCardIds: Enumerable.Range(1, 30).Select(_ => 100_011_010L).ToList(),
|
||||
ClassId: "3", CharaId: "3", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: "KOR", UserName: "PlayerA", SleeveId: "3000011",
|
||||
ClassId: CardClass.Runecraft, CharaId: "3", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: CountryCodes.Korea, UserName: "PlayerA", SleeveId: "3000011",
|
||||
EmblemId: "701441011", DegreeId: "300003", FieldId: 43, IsOfficial: 0,
|
||||
BattleModeId: BattleModes.TakeTwo);
|
||||
|
||||
private static MatchContext PlayerBCtx() => new(
|
||||
SelfDeckCardIds: Enumerable.Range(1, 30).Select(_ => 200_011_010L).ToList(),
|
||||
ClassId: "5", CharaId: "5", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: "JPN", UserName: "PlayerB", SleeveId: "3000022",
|
||||
ClassId: CardClass.Shadowcraft, CharaId: "5", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: CountryCodes.Japan, UserName: "PlayerB", SleeveId: "3000022",
|
||||
EmblemId: "701441022", DegreeId: "300004", FieldId: 44, IsOfficial: 0,
|
||||
BattleModeId: BattleModes.TakeTwo);
|
||||
|
||||
private static MatchContext FixtureCtx() => 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);
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ public class BattleSessionStateTests
|
||||
}
|
||||
|
||||
private static MatchContext Ctx(params long[] deck) => new(
|
||||
SelfDeckCardIds: deck, ClassId: "1", CharaId: "1", CardMasterName: "cm",
|
||||
CountryCode: "KOR", UserName: "P", SleeveId: "0", EmblemId: "0", DegreeId: "0",
|
||||
SelfDeckCardIds: deck, ClassId: CardClass.Forestcraft, CharaId: "1", CardMasterName: "cm",
|
||||
CountryCode: CountryCodes.Korea, UserName: "P", SleeveId: "0", EmblemId: "0", DegreeId: "0",
|
||||
FieldId: 0, IsOfficial: 0, BattleModeId: BattleModes.TakeTwo);
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -52,7 +52,7 @@ public class BattleSessionTerminateCascadeTests
|
||||
|
||||
private static MatchContext MakeFakeContext() => new(
|
||||
SelfDeckCardIds: Array.Empty<long>(),
|
||||
ClassId: "1", CharaId: "1", CardMasterName: "card_master_node_10015",
|
||||
ClassId: CardClass.Forestcraft, CharaId: "1", CardMasterName: "card_master_node_10015",
|
||||
CountryCode: "JP", UserName: "Test", SleeveId: "0",
|
||||
EmblemId: "0", DegreeId: "0", FieldId: 0, IsOfficial: 0, BattleModeId: BattleModes.TakeTwo);
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ public class InMemoryBattleSessionStoreTests
|
||||
|
||||
private static MatchContext FixtureCtx() => new(
|
||||
SelfDeckCardIds: Enumerable.Range(1, 30).Select(i => 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);
|
||||
}
|
||||
|
||||
@@ -147,8 +147,8 @@ public class RealParticipantHandEventTests
|
||||
|
||||
private static MatchContext FixtureCtx() => 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);
|
||||
}
|
||||
|
||||
@@ -171,8 +171,8 @@ public class RealParticipantTests
|
||||
|
||||
private static MatchContext FixtureCtx() => 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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -57,7 +57,7 @@ public class MatchContextBuilderTests
|
||||
var ctx = await builder.BuildForTwoPickAsync(vid);
|
||||
|
||||
Assert.That(ctx.SelfDeckCardIds, Is.EqualTo(deck));
|
||||
Assert.That(ctx.ClassId, Is.EqualTo("5"));
|
||||
Assert.That(ctx.ClassId, Is.EqualTo(CardClass.Shadowcraft));
|
||||
Assert.That(ctx.CharaId, Is.EqualTo("5000001")); // LeaderSkinId set
|
||||
Assert.That(ctx.CountryCode, Is.EqualTo("KOR"));
|
||||
Assert.That(ctx.UserName, Is.EqualTo("Drafter"));
|
||||
@@ -132,7 +132,7 @@ public class MatchContextBuilderTests
|
||||
|
||||
Assert.That(ctx.UserName, Is.EqualTo("Ranker"));
|
||||
Assert.That(ctx.BattleModeId, Is.EqualTo(BattleModes.TakeTwo), "rank-battle carries the same mode id as TK2 on the wire.");
|
||||
Assert.That(ctx.ClassId, Is.Not.Null.And.Not.Empty, "ClassId from the selected deck's class.");
|
||||
Assert.That(ctx.ClassId, Is.Not.EqualTo(CardClass.None), "ClassId from the selected deck's class.");
|
||||
Assert.That(ctx.CardMasterName, Is.EqualTo("card_master_node_10015"));
|
||||
Assert.That(ctx.FieldId, Is.EqualTo(43));
|
||||
}
|
||||
@@ -198,8 +198,8 @@ public class MatchContextBuilderTests
|
||||
var deck1Ctx = await builder.BuildForRankBattleAsync(viewerId, Format.Unlimited, deckNo: 1);
|
||||
var deck5Ctx = await builder.BuildForRankBattleAsync(viewerId, Format.Unlimited, deckNo: 5);
|
||||
|
||||
Assert.That(deck1Ctx.ClassId, Is.EqualTo("1"), "deckNo=1 → class 1.");
|
||||
Assert.That(deck5Ctx.ClassId, Is.EqualTo("6"), "deckNo=5 → class 6 (the wire-bug case).");
|
||||
Assert.That(deck1Ctx.ClassId, Is.EqualTo(CardClass.Forestcraft), "deckNo=1 → class 1.");
|
||||
Assert.That(deck5Ctx.ClassId, Is.EqualTo(CardClass.Bloodcraft), "deckNo=5 → class 6 (the wire-bug case).");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user