namespace SVSim.BattleNode.Protocol; /// /// Wire value of result on a WS BattleFinish frame. /// /// Maps to the client's NetworkBattleReceiver.RESULT_CODE enum at /// NetworkBattleReceiver.cs:963-986. Names are from the player's perspective: /// LifeWin = "I won by life", LifeLose = "I lost by life". Verified /// end-to-end via the path /// RESULT_CODEJudgeResultReceive switch → _finishEffectType → /// FinishBattleEffectInitiateGameEndSequence(hasWon): /// /// /// LifeWin = 101_finishEffectType = LOSE → /// InitiateGameEndSequence(hasWon: true) → PLAYER WIN UI /// LifeLose = 102_finishEffectType = WIN → /// InitiateGameEndSequence(hasWon: false) → PLAYER LOSE UI /// /// /// The SettingResultUI_SpecialResultTypeText switch passes the OPPONENT's /// outcome to set the secondary "by retire/by disconnect/etc." text — that's why /// the inner switch direction looks inverted (LifeWin → LOSE param, LifeLose → WIN /// param). The actual WIN/LOSE rendering happens in FinishBattleEffect via /// the !isPlayer flip at line 1315. /// /// /// Prior docstrings on this enum had the direction backwards (claimed LifeLose /// → WIN UI from a misread of the inner switch); see /// docs/audits/battle-node-sio-events-2026-06-02.md Addendum for the live /// reproduction that exposed the inversion. /// /// /// The pre-2026-06-02 Lose = 0 / Win = 1 / Consistency = 2 /// values are kept for the existing Retire/Kill Scripted flow (which ships /// Win = 1, parsed client-side as RESULT_CODE.NoContest and /// rendered as "battle ended in no contest" — works in that the battle /// terminates, but shows the wrong text). To be removed once that flow is /// rewritten to use the proper retire codes. /// /// /// 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). LifeWin = 101, /// Player lost by their own life dropping to 0. Pushed to the loser on /// the opponent's TurnEndFinal. Prod TK2 capture at /// data_dumps/captures/battle-traffic_tk2_regular.ndjson:274 is a loss /// shown to the player from a real opponent's lethal. LifeLose = 102, /// Player won because opponent retired. Pushed to the survivor on /// Retire/Kill. Same player-perspective convention as the Life codes. RetireWin = 105, /// Player lost by retiring. Pushed to the retirer on Retire/Kill. RetireLose = 106, }