Updated attack button to actually perform stage 1 API call.

This commit is contained in:
lightheel 2025-08-03 12:39:03 -04:00
parent 266658342a
commit 2901bcf0da

View File

@ -198,7 +198,8 @@ fun BattleScreen(
activeCharacter: APIBattleCharacter? = null, activeCharacter: APIBattleCharacter? = null,
opponentCharacter: APIBattleCharacter? = null, opponentCharacter: APIBattleCharacter? = null,
onBattleComplete: (String?) -> Unit = {}, onBattleComplete: (String?) -> Unit = {},
onExitBattle: () -> Unit = {} onExitBattle: () -> Unit = {},
context: android.content.Context? = null
) { ) {
var animationProgress by remember { mutableStateOf(0f) } var animationProgress by remember { mutableStateOf(0f) }
@ -266,7 +267,9 @@ fun BattleScreen(
// Apply damage after animation // Apply damage after animation
battleSystem.applyDamage(false, 20f) // Opponent takes damage battleSystem.applyDamage(false, 20f) // Opponent takes damage
}, },
activeCharacter = activeCharacter activeCharacter = activeCharacter,
context = context,
opponent = opponentCharacter
) )
} }
1 -> { 1 -> {
@ -301,7 +304,9 @@ fun PlayerBattleView(
playerName: String, playerName: String,
attackAnimationProgress: Float, attackAnimationProgress: Float,
onAttackClick: () -> Unit, onAttackClick: () -> Unit,
activeCharacter: APIBattleCharacter? = null activeCharacter: APIBattleCharacter? = null,
context: android.content.Context? = null,
opponent: APIBattleCharacter? = null
) { ) {
Column( Column(
modifier = Modifier modifier = Modifier
@ -347,8 +352,10 @@ fun PlayerBattleView(
// Player character with attack animation // Player character with attack animation
Box( Box(
modifier = Modifier.size(80.dp), modifier = Modifier
contentAlignment = Alignment.Center .fillMaxWidth()
.size(80.dp),
contentAlignment = Alignment.CenterStart
) { ) {
SpriteImage( SpriteImage(
spriteName = "00", // The sprite number (00, 01, 02, etc.) spriteName = "00", // The sprite number (00, 01, 02, etc.)
@ -360,7 +367,8 @@ fun PlayerBattleView(
else -> "dim011_mon01" else -> "dim011_mon01"
}, },
modifier = Modifier modifier = Modifier
.size(80.dp), .size(80.dp)
.scale(-1f, 1f), // Flip horizontally
contentScale = ContentScale.Fit contentScale = ContentScale.Fit
) )
/* /*
@ -426,6 +434,45 @@ fun PlayerBattleView(
Button( Button(
onClick = { onClick = {
println("Attack button clicked!") println("Attack button clicked!")
// Get crit bar progress as float (0.0f to 100.0f)
val critBarProgressFloat = battleSystem.critBarProgress.toFloat()
// Determine player and opponent stages
val playerStage = when (activeCharacter?.stage) {
0 -> 0 // rookie
1 -> 1 // champion
2 -> 2 // ultimate
3 -> 3 // mega
else -> 0
}
val opponentStage = when (opponent?.stage) {
0 -> 0 // rookie
1 -> 1 // champion
2 -> 2 // ultimate
3 -> 3 // mega
else -> 0
}
// Send API call with all parameters
context?.let { ctx ->
RetrofitHelper().getPVPWinner(
ctx,
1,
2,
activeCharacter?.name ?: "Player",
playerStage,
opponentStage,
opponent?.name ?: "Opponent",
opponentStage
) { apiResult ->
// Handle API response here
println("API Result: $apiResult")
// TODO: Parse response and apply damage/hit/miss logic
}
}
onAttackClick() onAttackClick()
}, },
enabled = battleSystem.isAttackButtonEnabled, enabled = battleSystem.isAttackButtonEnabled,
@ -495,8 +542,10 @@ fun OpponentBattleView(
// Opponent character with attack animation // Opponent character with attack animation
Box( Box(
modifier = Modifier.size(80.dp), modifier = Modifier
contentAlignment = Alignment.Center .fillMaxWidth()
.size(80.dp),
contentAlignment = Alignment.CenterEnd
) { ) {
SpriteImage( SpriteImage(
spriteName = "00", // The sprite number (00, 01, 02, etc.) spriteName = "00", // The sprite number (00, 01, 02, etc.)
@ -1047,7 +1096,8 @@ fun BattlesScreen() {
}, },
onExitBattle = { onExitBattle = {
currentView = "main" currentView = "main"
} },
context = context
) )
} }