From c551d7b05eb8671c99081666359d465da36584ce Mon Sep 17 00:00:00 2001 From: gamer147 Date: Tue, 2 Jun 2026 21:17:30 -0400 Subject: [PATCH] refactor(battle-node): drop dead BattleResult.{Lose,Win,Consistency} members No dispatch arm has emitted these since the Retire/Kill rewrite to RetireWin=105 / RetireLose=106. Remove them and the docstring paragraph that explained them. Test fallout: delete BattleFinishBody_LoseAndConsistency_SerializeAsZeroAndTwo (its only purpose was locking the dead wire values), and re-point BattleFinishBody_SerializesResultAndResultCode_AsNumericWireValues at the live LifeWin=101 so it still guards the JsonNumberEnumConverter numeric-wire behavior. Co-Authored-By: Claude Opus 4.8 --- SVSim.BattleNode/Protocol/BattleResult.cs | 21 ------------------- .../Protocol/Bodies/SmallBodiesTests.cs | 20 +++++------------- 2 files changed, 5 insertions(+), 36 deletions(-) diff --git a/SVSim.BattleNode/Protocol/BattleResult.cs b/SVSim.BattleNode/Protocol/BattleResult.cs index 022f151..d7b3f72 100644 --- a/SVSim.BattleNode/Protocol/BattleResult.cs +++ b/SVSim.BattleNode/Protocol/BattleResult.cs @@ -30,33 +30,12 @@ namespace SVSim.BattleNode.Protocol; /// reproduction that exposed the inversion. /// /// -/// The legacy Lose = 0 / Win = 1 / Consistency = 2 values -/// (client RESULT_CODE.NotFinish / NoContest / Invalid) are -/// no longer emitted by any dispatch arm: the Retire/Kill flow now ships the -/// proper RetireWin / RetireLose codes, and the involuntary-drop -/// cascade ships DisconnectWin. They survive only as wire-constant -/// references in serialization tests and can be deleted once those are dropped. -/// (Historically Win = 1 was shipped on Retire and rendered client-side -/// as "battle ended in no contest" — the wrong text — which is why it was -/// replaced.) -/// -/// /// Always serialize as the int value, not the name; see the /// JsonNumberEnumConverter on . /// /// public enum BattleResult { - /// Pre-2026-06-02 value, kept for the existing Retire/Kill Scripted flow. - /// Wire-equivalent of RESULT_CODE.NotFinish = 0. Don't use for new code. - Lose = 0, - /// Pre-2026-06-02 value, kept for the existing Retire/Kill Scripted flow. - /// Wire-equivalent of RESULT_CODE.NoContest = 1. Don't use for new code. - Win = 1, - /// Pre-2026-06-02 value, kept for the existing Retire/Kill Scripted flow. - /// Wire-equivalent of RESULT_CODE.Invalid = 2. Don't use for new code. - Consistency = 2, - /// Player won by reducing opponent's life to 0. Pushed to the winner /// on TurnEndFinal. Routes through the client switch to /// InitiateGameEndSequence(hasWon: true). diff --git a/SVSim.UnitTests/BattleNode/Protocol/Bodies/SmallBodiesTests.cs b/SVSim.UnitTests/BattleNode/Protocol/Bodies/SmallBodiesTests.cs index e51c8ed..449985d 100644 --- a/SVSim.UnitTests/BattleNode/Protocol/Bodies/SmallBodiesTests.cs +++ b/SVSim.UnitTests/BattleNode/Protocol/Bodies/SmallBodiesTests.cs @@ -34,27 +34,17 @@ public class SmallBodiesTests [Test] public void BattleFinishBody_SerializesResultAndResultCode_AsNumericWireValues() { - // The wire field is the int code (Win=1); BattleResult uses JsonNumberEnumConverter - // to override the default JsonStringEnumConverter (which would emit "Win" instead). - var body = new BattleFinishBody(Result: BattleResult.Win); + // The wire field is the int RESULT_CODE (LifeWin=101); BattleResult uses + // JsonNumberEnumConverter to override the default JsonStringEnumConverter (which + // would emit "LifeWin" instead). + var body = new BattleFinishBody(Result: BattleResult.LifeWin); var node = (JsonObject)JsonSerializer.SerializeToNode(body)!; - Assert.That(node["result"]!.GetValue(), Is.EqualTo(1)); + Assert.That(node["result"]!.GetValue(), Is.EqualTo(101)); Assert.That(node["resultCode"]!.GetValue(), Is.EqualTo(1)); } - [Test] - public void BattleFinishBody_LoseAndConsistency_SerializeAsZeroAndTwo() - { - // Lock the wire values per BattleFinishResponsProcessing's switch (0=LOSE, 2=CONSISTENCY). - var lose = (JsonObject)JsonSerializer.SerializeToNode(new BattleFinishBody(BattleResult.Lose))!; - var consistency = (JsonObject)JsonSerializer.SerializeToNode(new BattleFinishBody(BattleResult.Consistency))!; - - Assert.That(lose["result"]!.GetValue(), Is.EqualTo(0)); - Assert.That(consistency["result"]!.GetValue(), Is.EqualTo(2)); - } - [Test] public void AlivePushBody_SerializesScsAndOcs_AndDoesNotIncludeResultCode() {