mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-06-05 22:02:54 +00:00
Re-added missing exit button and health bars.
This commit is contained in:
parent
4e12962c05
commit
7af8e00e6f
@ -99,6 +99,12 @@ class ArenaBattleSystem {
|
|||||||
Log.d(TAG, "Updated HP from API: Player=$playerHP, Opponent=$opponentHP")
|
Log.d(TAG, "Updated HP from API: Player=$playerHP, Opponent=$opponentHP")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun initializeHP(playerMaxHP: Float, opponentMaxHP: Float) {
|
||||||
|
_playerHP = playerMaxHP
|
||||||
|
_opponentHP = opponentMaxHP
|
||||||
|
Log.d(TAG, "Initialized HP: Player=$playerMaxHP, Opponent=$opponentMaxHP")
|
||||||
|
}
|
||||||
|
|
||||||
fun completeAttackAnimation(playerDamage: Float = 0f, opponentDamage: Float = 0f) {
|
fun completeAttackAnimation(playerDamage: Float = 0f, opponentDamage: Float = 0f) {
|
||||||
if (playerDamage > 0f) {
|
if (playerDamage > 0f) {
|
||||||
applyDamage(true, playerDamage)
|
applyDamage(true, playerDamage)
|
||||||
|
|||||||
@ -62,6 +62,13 @@ fun BattleScreen(
|
|||||||
) {
|
) {
|
||||||
val battleSystem = remember { ArenaBattleSystem() }
|
val battleSystem = remember { ArenaBattleSystem() }
|
||||||
|
|
||||||
|
// Initialize HP when battle starts
|
||||||
|
LaunchedEffect(activeCharacter, opponentCharacter) {
|
||||||
|
val playerMaxHP = activeCharacter?.baseHp?.toFloat() ?: 100f
|
||||||
|
val opponentMaxHP = opponentCharacter?.baseHp?.toFloat() ?: 100f
|
||||||
|
battleSystem.initializeHP(playerMaxHP, opponentMaxHP)
|
||||||
|
}
|
||||||
|
|
||||||
// Pending damage state for API integration
|
// Pending damage state for API integration
|
||||||
var pendingPlayerDamage by remember { mutableStateOf(0f) }
|
var pendingPlayerDamage by remember { mutableStateOf(0f) }
|
||||||
var pendingOpponentDamage by remember { mutableStateOf(0f) }
|
var pendingOpponentDamage by remember { mutableStateOf(0f) }
|
||||||
@ -197,13 +204,29 @@ fun PlayerBattleView(
|
|||||||
opponent: APIBattleCharacter?,
|
opponent: APIBattleCharacter?,
|
||||||
onSetPendingDamage: (Float, Float) -> Unit
|
onSetPendingDamage: (Float, Float) -> Unit
|
||||||
) {
|
) {
|
||||||
Column(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxSize()
|
||||||
.fillMaxSize()
|
|
||||||
.padding(16.dp),
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
|
||||||
) {
|
) {
|
||||||
// Player Digimon
|
// Exit button at the top-right
|
||||||
|
Button(
|
||||||
|
onClick = { /* TODO: Add exit functionality */ },
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.TopEnd)
|
||||||
|
.padding(16.dp),
|
||||||
|
colors = ButtonDefaults.buttonColors(containerColor = Color.Red)
|
||||||
|
) {
|
||||||
|
Text("Exit", color = Color.White, fontSize = 14.sp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main content
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(16.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.SpaceBetween
|
||||||
|
) {
|
||||||
|
// Player Digimon
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
@ -262,6 +285,46 @@ fun PlayerBattleView(
|
|||||||
trackColor = Color.Gray
|
trackColor = Color.Gray
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
// Health bar
|
||||||
|
LinearProgressIndicator(
|
||||||
|
progress = battleSystem.playerHP / (activeCharacter?.baseHp?.toFloat() ?: 100f),
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(10.dp),
|
||||||
|
color = Color.Green,
|
||||||
|
trackColor = Color.Gray
|
||||||
|
)
|
||||||
|
|
||||||
|
// Health display numbers
|
||||||
|
Text(
|
||||||
|
text = "HP: ${battleSystem.playerHP.toInt()}/${activeCharacter?.baseHp ?: 100}",
|
||||||
|
fontSize = 14.sp,
|
||||||
|
color = Color.Black
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
// Enemy HP bar
|
||||||
|
LinearProgressIndicator(
|
||||||
|
progress = battleSystem.opponentHP / (opponent?.baseHp?.toFloat() ?: 100f),
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(10.dp),
|
||||||
|
color = Color.Red,
|
||||||
|
trackColor = Color.Gray
|
||||||
|
)
|
||||||
|
|
||||||
|
// Enemy HP display numbers
|
||||||
|
Text(
|
||||||
|
text = "Enemy HP: ${battleSystem.opponentHP.toInt()}/${opponent?.baseHp ?: 100}",
|
||||||
|
fontSize = 14.sp,
|
||||||
|
color = Color.Black
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
// Attack button
|
// Attack button
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
@ -355,6 +418,9 @@ fun PlayerBattleView(
|
|||||||
) {
|
) {
|
||||||
Text("Attack", color = Color.White, fontSize = 18.sp)
|
Text("Attack", color = Color.White, fontSize = 18.sp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,6 +486,23 @@ fun OpponentBattleView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enemy HP bar
|
||||||
|
LinearProgressIndicator(
|
||||||
|
progress = battleSystem.opponentHP / (activeCharacter?.baseHp?.toFloat() ?: 100f),
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(10.dp),
|
||||||
|
color = Color.Red,
|
||||||
|
trackColor = Color.Gray
|
||||||
|
)
|
||||||
|
|
||||||
|
// Enemy HP display numbers
|
||||||
|
Text(
|
||||||
|
text = "Enemy HP: ${battleSystem.opponentHP.toInt()}/${activeCharacter?.baseHp ?: 100}",
|
||||||
|
fontSize = 14.sp,
|
||||||
|
color = Color.Black
|
||||||
|
)
|
||||||
|
|
||||||
// Spacer for layout balance
|
// Spacer for layout balance
|
||||||
Spacer(modifier = Modifier.height(120.dp))
|
Spacer(modifier = Modifier.height(120.dp))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user