fix(battle-node): TurnEndFinal pushes LifeWin=101 (player perspective), not LifeLose=102

End-to-end trace of FinishBattleEffect proved my prior direction was
backwards. The path is:

  RESULT_CODE → JudgeResultReceive switch (NetworkBattleManagerBase:1439-1459)
              → SettingResultUI_SpecialResultTypeText
              → _finishEffectType = battleResult
  → eventually FinishBattleEffect(:1267-1316):
      bool isPlayer = false;
      switch (_finishEffectType) {
        case WIN:  isPlayer = true;  break;
        case LOSE: isPlayer = false; break;
      }
      InitiateGameEndSequence(!isPlayer);  // NEGATED
  → BattleManagerBase.InitiateGameEndSequence(hasWon):
      hasWon=true → WIN screen; hasWon=false → LOSE screen.

So LifeWin=101 (player perspective: "I won by life") → _finishEffectType=LOSE
→ isPlayer=false → hasWon=true → WIN UI. And LifeLose=102 ("I lost") → LOSE UI.

My prior misread treated the inner switch's BATTLE_RESULT_TYPE param as
the final UI render — but that param only feeds the secondary "by retire
/ by disconnect" text, not the primary WIN/LOSE. The real flip happens at
FinishBattleEffect:1315's !isPlayer negation.

User's live repro (bot HP to 0 → LOSS screen) confirmed the inversion.

The prior prod TK2 capture interpretation was also corrected: line 274
`result:102` was a LOSS capture (player lost to the opponent's attack on
line 271), not a win as I claimed earlier.

Changes:
- BattleResult.cs: docstring rewritten with the full FinishBattleEffect
  trace. Members reordered (LifeWin first since it's used by Scripted).
- BattleSession.cs:267: Scripted TurnEndFinal arm pushes LifeWin instead
  of LifeLose.
- Test updated to assert LifeWin=101 + describe the inversion lesson so
  the next reader sees the prior bug context.

177 battle-node tests passing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-02 18:11:24 -04:00
parent ee23985055
commit 1685b509c3
3 changed files with 53 additions and 33 deletions

View File

@@ -260,11 +260,12 @@ public sealed class BattleSession
}
else if (Type == BattleType.Scripted)
{
// Push BattleFinish with LifeLose=102client interprets as "opponent's
// life ran out, player WIN". DON'T forward to bot (no next turn) and DON'T
// re-fire the 3-frame burst — the game is over. Phase → Terminal so the
// Push BattleFinish with LifeWin=101names are from the player's
// perspective: "I won by life". Verified end-to-end via
// FinishBattleEffect:1289-1315 → InitiateGameEndSequence(hasWon: true) →
// WIN UI. Don't forward to bot (no next turn). Phase → Terminal so the
// RunAsync cascade doesn't synthesize a follow-up BattleFinish.
result.Add((from, BuildBattleFinish(BattleResult.LifeLose), true));
result.Add((from, BuildBattleFinish(BattleResult.LifeWin), true));
Phase = BattleSessionPhase.Terminal;
}
// Bot type: no-op (rank-battle finish is HTTP-driven via /ai_*/finish).