mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-06-05 22:02:54 +00:00
Fixed HP desync with battle.
This commit is contained in:
parent
61daad459b
commit
0875b114d5
@ -1649,10 +1649,24 @@ fun BattlesScreen() {
|
|||||||
// Format as "dim" + cardId + "_mon" + (charaIndex + 1)
|
// Format as "dim" + cardId + "_mon" + (charaIndex + 1)
|
||||||
val formattedCardId = String.format("dim%03d_mon%02d", cardId, charaIndex + 1)
|
val formattedCardId = String.format("dim%03d_mon%02d", cardId, charaIndex + 1)
|
||||||
|
|
||||||
|
// Create APIBattleCharacter from database character
|
||||||
|
val playerCharacter = APIBattleCharacter(
|
||||||
|
name = "Player Digimon", // We could get this from the database if needed
|
||||||
|
namekey = "player_digimon", // Name key for the character
|
||||||
|
charaId = formattedCardId, // Use the formatted card ID for sprite loading
|
||||||
|
stage = characterData.stage,
|
||||||
|
attribute = characterData.attribute.ordinal, // Convert enum to int
|
||||||
|
baseHp = 1000, // Default values - API will provide correct values
|
||||||
|
currentHp = 1000,
|
||||||
|
baseBp = 1000.0f,
|
||||||
|
baseAp = 1000.0f
|
||||||
|
)
|
||||||
|
|
||||||
// Update UI state on main thread
|
// Update UI state on main thread
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
activeUserCharacter = activeChar
|
activeUserCharacter = activeChar
|
||||||
activeCardId = formattedCardId
|
activeCardId = formattedCardId
|
||||||
|
activeCharacter = playerCharacter // Set the active character for battle
|
||||||
}
|
}
|
||||||
|
|
||||||
println("BATTLESCREEN: Loaded active character from database:")
|
println("BATTLESCREEN: Loaded active character from database:")
|
||||||
@ -2076,6 +2090,11 @@ fun BattlesScreen() {
|
|||||||
// Randomly select background set (0, 1, or 2)
|
// Randomly select background set (0, 1, or 2)
|
||||||
selectedBackgroundSet = kotlin.random.Random.nextInt(3)
|
selectedBackgroundSet = kotlin.random.Random.nextInt(3)
|
||||||
RetrofitHelper().getPVPWinner(context, 0, 2, cardId, 0, 0, opponent.charaId, 0) { apiResult ->
|
RetrofitHelper().getPVPWinner(context, 0, 2, cardId, 0, 0, opponent.charaId, 0) { apiResult ->
|
||||||
|
// Update player character HP from API response
|
||||||
|
activeCharacter = activeCharacter?.copy(
|
||||||
|
baseHp = apiResult.playerHP,
|
||||||
|
currentHp = apiResult.playerHP
|
||||||
|
)
|
||||||
currentView = "battle-main"
|
currentView = "battle-main"
|
||||||
}
|
}
|
||||||
} ?: run {
|
} ?: run {
|
||||||
@ -2132,6 +2151,11 @@ fun BattlesScreen() {
|
|||||||
// Randomly select background set (0, 1, or 2)
|
// Randomly select background set (0, 1, or 2)
|
||||||
selectedBackgroundSet = kotlin.random.Random.nextInt(3)
|
selectedBackgroundSet = kotlin.random.Random.nextInt(3)
|
||||||
RetrofitHelper().getPVPWinner(context, 0, 2, cardId, 1, 0, opponent.charaId, 1) { apiResult ->
|
RetrofitHelper().getPVPWinner(context, 0, 2, cardId, 1, 0, opponent.charaId, 1) { apiResult ->
|
||||||
|
// Update player character HP from API response
|
||||||
|
activeCharacter = activeCharacter?.copy(
|
||||||
|
baseHp = apiResult.playerHP,
|
||||||
|
currentHp = apiResult.playerHP
|
||||||
|
)
|
||||||
currentView = "battle-main"
|
currentView = "battle-main"
|
||||||
}
|
}
|
||||||
} ?: run {
|
} ?: run {
|
||||||
@ -2188,6 +2212,11 @@ fun BattlesScreen() {
|
|||||||
// Randomly select background set (0, 1, or 2)
|
// Randomly select background set (0, 1, or 2)
|
||||||
selectedBackgroundSet = kotlin.random.Random.nextInt(3)
|
selectedBackgroundSet = kotlin.random.Random.nextInt(3)
|
||||||
RetrofitHelper().getPVPWinner(context, 0, 2, cardId, 2, 0, opponent.charaId, 2) { apiResult ->
|
RetrofitHelper().getPVPWinner(context, 0, 2, cardId, 2, 0, opponent.charaId, 2) { apiResult ->
|
||||||
|
// Update player character HP from API response
|
||||||
|
activeCharacter = activeCharacter?.copy(
|
||||||
|
baseHp = apiResult.playerHP,
|
||||||
|
currentHp = apiResult.playerHP
|
||||||
|
)
|
||||||
currentView = "battle-main"
|
currentView = "battle-main"
|
||||||
}
|
}
|
||||||
} ?: run {
|
} ?: run {
|
||||||
@ -2244,6 +2273,11 @@ fun BattlesScreen() {
|
|||||||
// Randomly select background set (0, 1, or 2)
|
// Randomly select background set (0, 1, or 2)
|
||||||
selectedBackgroundSet = kotlin.random.Random.nextInt(3)
|
selectedBackgroundSet = kotlin.random.Random.nextInt(3)
|
||||||
RetrofitHelper().getPVPWinner(context, 0, 2, cardId, 3, 0, opponent.charaId, 3) { apiResult ->
|
RetrofitHelper().getPVPWinner(context, 0, 2, cardId, 3, 0, opponent.charaId, 3) { apiResult ->
|
||||||
|
// Update player character HP from API response
|
||||||
|
activeCharacter = activeCharacter?.copy(
|
||||||
|
baseHp = apiResult.playerHP,
|
||||||
|
currentHp = apiResult.playerHP
|
||||||
|
)
|
||||||
currentView = "battle-main"
|
currentView = "battle-main"
|
||||||
}
|
}
|
||||||
} ?: run {
|
} ?: run {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user