From 65a7ccb2219de232138d42a66a4d3c2a52fa32cb Mon Sep 17 00:00:00 2001 From: lightheel Date: Wed, 21 Jan 2026 21:27:11 -0500 Subject: [PATCH] Fixed resume battle max HP display bug. --- .../nacabaro/vbhelper/battle/PVPDataModel.kt | 4 +++- .../nacabaro/vbhelper/screens/BattlesScreen.kt | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/battle/PVPDataModel.kt b/app/src/main/java/com/github/nacabaro/vbhelper/battle/PVPDataModel.kt index c30b47e..9e0c237 100644 --- a/app/src/main/java/com/github/nacabaro/vbhelper/battle/PVPDataModel.kt +++ b/app/src/main/java/com/github/nacabaro/vbhelper/battle/PVPDataModel.kt @@ -10,5 +10,7 @@ data class PVPDataModel ( val playerAttackDamage: Int, val opponentAttackDamage: Int, val winner: String, - val opponentCharaId: String? = null // TODO: Server will add this - opponent's charaId from the match + val opponentCharaId: String? = null, // Server provides opponent's charaId from the match + val playerMaxHP: Int? = null, // Server should provide max HP for resumed matches + val opponentMaxHP: Int? = null // Server should provide max HP for resumed matches ):java.io.Serializable \ No newline at end of file diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/screens/BattlesScreen.kt b/app/src/main/java/com/github/nacabaro/vbhelper/screens/BattlesScreen.kt index 3d2cda4..fb480df 100644 --- a/app/src/main/java/com/github/nacabaro/vbhelper/screens/BattlesScreen.kt +++ b/app/src/main/java/com/github/nacabaro/vbhelper/screens/BattlesScreen.kt @@ -2502,9 +2502,14 @@ fun BattlesScreen() { println("BATTLESCREEN: Clicked opponent: ${clickedOpponent.name} (${clickedOpponent.charaId}), baseHp: ${clickedOpponent.baseHp}") // Update player character HP from API response + // Use playerMaxHP from API if available, otherwise use current HP as fallback + // NOTE: Server should provide playerMaxHP for resumed matches since DB stats use different scaling + val playerMaxHp = apiResult.playerMaxHP ?: apiResult.playerHP + println("BATTLESCREEN: Resuming match - playerMaxHP from API: ${apiResult.playerMaxHP}, using: $playerMaxHp") + activeCharacter = activeCharacter?.copy( - baseHp = apiResult.playerHP, - currentHp = apiResult.playerHP + baseHp = playerMaxHp, // Use max HP from API (or current HP as fallback) + currentHp = apiResult.playerHP // Current HP from API ) // Find the actual opponent from the match @@ -2583,9 +2588,13 @@ fun BattlesScreen() { println("BATTLESCREEN: Selected opponent for resume: ${actualOpponent.name} (${actualOpponent.charaId}), baseHp: ${actualOpponent.baseHp}, currentHp: ${apiResult.opponentHP}") // Update opponent with correct HP from match - // Use the actual baseHp from the opponent, but set currentHp to the match HP + // Use opponentMaxHP from API if available, otherwise use opponent's baseHp from opponentsList + // NOTE: Server should provide opponentMaxHP for resumed matches since DB stats use different scaling + val opponentMaxHp = apiResult.opponentMaxHP ?: actualOpponent.baseHp + println("BATTLESCREEN: Resuming match - opponentMaxHP from API: ${apiResult.opponentMaxHP}, using: $opponentMaxHp") + selectedOpponent = actualOpponent.copy( - baseHp = actualOpponent.baseHp, // Keep original baseHp + baseHp = opponentMaxHp, // Use max HP from API (or opponent's baseHp as fallback) currentHp = apiResult.opponentHP // Use current HP from match )