mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-13 19:39:34 +07:00
Avoid overflow of the health bar in the overkill situation (#3558)
This commit is contained in:
parent
68b308dd26
commit
8c0be488bc
@ -309,8 +309,9 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
||||
private fun getHealthBar(currentHealth: Int, maxHealth: Int, expectedDamage:Int): Table {
|
||||
val healthBar = Table()
|
||||
val totalWidth = 100f
|
||||
fun addHealthToBar(image: Image, amount:Int){
|
||||
healthBar.add(image).size(amount*totalWidth/maxHealth,3f)
|
||||
fun addHealthToBar(image: Image, amount:Int) {
|
||||
val width = totalWidth * amount/maxHealth
|
||||
healthBar.add(image).size(width.coerceIn(0f,totalWidth),3f)
|
||||
}
|
||||
addHealthToBar(ImageGetter.getDot(Color.BLACK), maxHealth-currentHealth)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user