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();
|
||||
}
|
||||
Reference in New Issue
Block a user