Intercept damage bonus (from promotions) treated as a unique

This commit is contained in:
Yair Morgenstern 2020-09-06 20:19:20 +03:00
parent 588aa7a177
commit 9034729dfd

View File

@ -73,8 +73,6 @@ class MapUnit {
private const val ANCIENT_RUIN_MAP_REVEAL_OFFSET = 4
private const val ANCIENT_RUIN_MAP_REVEAL_RANGE = 4
private const val ANCIENT_RUIN_MAP_REVEAL_CHANCE = 0.8f
const val BONUS_WHEN_INTERCEPTING = "Bonus when intercepting"
const val CHANCE_TO_INTERCEPT_AIR_ATTACKS = " chance to intercept air attacks"
}
//region pure functions
@ -125,9 +123,7 @@ class MapUnit {
// will not get counted twice!
@Transient var tempUniques= ArrayList<Unique>()
fun getUniques(): ArrayList<Unique> {
return tempUniques
}
fun getUniques(): ArrayList<Unique> = tempUniques
fun getMatchingUniques(placeholderText:String): Sequence<Unique>
= tempUniques.asSequence().filter { it.placeholderText == placeholderText }
@ -190,9 +186,7 @@ class MapUnit {
return action!!.split(" ")[1].toInt()
}
override fun toString(): String {
return "$name - $owner"
}
override fun toString() = "$name - $owner"
fun isIdle(): Boolean {
@ -287,9 +281,7 @@ class MapUnit {
fun fortifyUntilHealed() { action = "Fortify 0 until healed" }
fun fortifyIfCan() {
if (canFortify()) {
fortify()
}
if (canFortify()) fortify()
}
private fun adjacentHealingBonus():Int{
@ -436,8 +428,7 @@ class MapUnit {
if (hasUnique("This unit and all others in adjacent tiles heal 5 additional HP. This unit heals 5 additional HP outside of friendly territory.")
&& !isFriendlyTerritory
// Additional healing from medic is only applied when the unit is able to heal
&& healing > 0)
&& healing > 0)// Additional healing from medic is only applied when the unit is able to heal
healing += 5
return healing
@ -669,18 +660,14 @@ class MapUnit {
var unitCapacity = 2
unitCapacity += getUniques().count { it.text == "Can carry 1 extra air unit" }
if (currentTile.airUnits.filter { it.isTransported }.size >= unitCapacity) return false
if (currentTile.airUnits.count { it.isTransported } >= unitCapacity) return false
return true
}
fun interceptDamagePercentBonus():Int {
var sum=0
for(unique in getUniques().filter { it.text.startsWith(BONUS_WHEN_INTERCEPTING) }){
val percent = Regex("\\d+").find(unique.text)!!.value.toInt()
sum += percent
}
return sum
return getUniques().filter { it.placeholderText == "Bonus when intercepting []%" }
.sumBy { it.params[0].toInt() }
}
private fun getCitadelDamage() {