mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-06-05 13:52:54 +00:00
Removed attack bar and button from player view.
This commit is contained in:
parent
bb1c29bbb4
commit
ba03be808e
@ -1398,141 +1398,7 @@ fun PlayerBattleView(
|
||||
}
|
||||
}
|
||||
|
||||
// Bottom section: Critical bar and Attack button
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp)
|
||||
.align(Alignment.BottomCenter),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
// Critical bar
|
||||
LinearProgressIndicator(
|
||||
progress = battleSystem.critBarProgress / 100f,
|
||||
modifier = getLandscapeModifier(),
|
||||
color = Color.Yellow,
|
||||
trackColor = Color.Gray
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
// Attack button
|
||||
Button(
|
||||
onClick = {
|
||||
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 ->
|
||||
// Start player attack animation
|
||||
battleSystem.startPlayerAttack()
|
||||
|
||||
RetrofitHelper().getPVPWinner(
|
||||
ctx,
|
||||
1,
|
||||
2,
|
||||
activeCharacter?.name ?: "Player",
|
||||
playerStage,
|
||||
opponentStage,
|
||||
opponent?.name ?: "Opponent",
|
||||
opponentStage
|
||||
) { apiResult ->
|
||||
// Handle API response here
|
||||
println("API Result: $apiResult")
|
||||
lastApiResult = apiResult // Store for debug display
|
||||
|
||||
// Update HP based on API response
|
||||
when (apiResult.state) {
|
||||
1 -> {
|
||||
// Match is still ongoing - update HP and continue
|
||||
println("Round ${apiResult.currentRound}: Player HP=${apiResult.playerHP}, Opponent HP=${apiResult.opponentHP}")
|
||||
|
||||
// Set pending damage based on API result
|
||||
if (apiResult.playerAttackDamage > 0) {
|
||||
// Player attack hit - enemy takes damage at end of player animation
|
||||
println("Player attack hit! Enemy will take ${apiResult.playerAttackDamage} damage")
|
||||
onSetPendingDamage(0f, apiResult.playerAttackDamage.toFloat()) // Opponent takes damage
|
||||
battleSystem.setAttackHitState(true)
|
||||
|
||||
// Also check if enemy counter-attacks and hits
|
||||
if (apiResult.opponentAttackDamage > 0) {
|
||||
println("Enemy counter-attack hits! Player takes ${apiResult.opponentAttackDamage} damage")
|
||||
onSetPendingDamage(apiResult.opponentAttackDamage.toFloat(), apiResult.playerAttackDamage.toFloat()) // Both take damage
|
||||
}
|
||||
} else {
|
||||
// Player attack missed - enemy counter-attacks
|
||||
println("Player attack missed! Enemy counter-attacks")
|
||||
battleSystem.setAttackHitState(false)
|
||||
// Set up counter-attack - determine if it hits based on API result
|
||||
val counterAttackHits = apiResult.opponentAttackDamage > 0
|
||||
println("Setting up counter-attack: counterAttackHits=$counterAttackHits, opponentAttackDamage=${apiResult.opponentAttackDamage}")
|
||||
println("Full API response: status=${apiResult.status}, state=${apiResult.state}, playerAttackHit=${apiResult.playerAttackHit}, playerAttackDamage=${apiResult.playerAttackDamage}, opponentAttackDamage=${apiResult.opponentAttackDamage}, playerHP=${apiResult.playerHP}, opponentHP=${apiResult.opponentHP}")
|
||||
println("DEBUG: Using playerAttackDamage > 0 instead of playerAttackHit for hit detection")
|
||||
|
||||
// Use opponentAttackDamage to determine counter-attack hit
|
||||
val finalCounterAttackHits = counterAttackHits
|
||||
println("Using opponentAttackDamage > 0 for counter-attack: $finalCounterAttackHits")
|
||||
|
||||
if (finalCounterAttackHits) {
|
||||
println("Counter-attack hits! Player takes ${apiResult.opponentAttackDamage} damage")
|
||||
onSetPendingDamage(apiResult.opponentAttackDamage.toFloat(), 0f) // Player takes damage
|
||||
} else {
|
||||
println("Counter-attack misses! Player dodges")
|
||||
onSetPendingDamage(0f, 0f) // No damage
|
||||
}
|
||||
battleSystem.setupCounterAttack(finalCounterAttackHits)
|
||||
// Set the opponent attack hit state for Phase 3
|
||||
battleSystem.handleOpponentAttackResult(finalCounterAttackHits)
|
||||
}
|
||||
}
|
||||
2 -> {
|
||||
// Match is over - transition to results screen
|
||||
println("Match is over! Winner: ${apiResult.winner}")
|
||||
battleSystem.updateHPFromAPI(apiResult.playerHP.toFloat(), apiResult.opponentHP.toFloat())
|
||||
onAttackClick() // This will transition to battle-results screen
|
||||
}
|
||||
-1 -> {
|
||||
// Error occurred
|
||||
println("API Error: ${apiResult.status}")
|
||||
battleSystem.resetAttackState()
|
||||
battleSystem.enableAttackButton()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
enabled = battleSystem.isAttackButtonEnabled,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(50.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Color.Red,
|
||||
disabledContainerColor = Color.Gray
|
||||
),
|
||||
shape = RoundedCornerShape(8.dp)
|
||||
) {
|
||||
Text("Attack", color = Color.White, fontSize = 18.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user