mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-11 16:29:48 +07:00
More bug fixes (#4370)
* Fixed Air Targetting not having icon * Fixed the huns not having battering ram unique unit * Plundering with multiple levels of coastal raider no longer creates multiple notifications * Implemented requested changes
This commit is contained in:
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
@ -273,7 +273,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Battering Ram",
|
"name": "Battering Ram",
|
||||||
"replaces": "Spearman",
|
"replaces": "Spearman",
|
||||||
"uniqueTo": "Huns",
|
"uniqueTo": "The Huns",
|
||||||
"unitType": "Melee",
|
"unitType": "Melee",
|
||||||
"movement": 2,
|
"movement": 2,
|
||||||
"strength": 10,
|
"strength": 10,
|
||||||
|
@ -12,6 +12,7 @@ import com.unciv.models.AttackableTile
|
|||||||
import com.unciv.models.ruleset.Unique
|
import com.unciv.models.ruleset.Unique
|
||||||
import com.unciv.models.ruleset.unit.UnitType
|
import com.unciv.models.ruleset.unit.UnitType
|
||||||
import com.unciv.models.stats.Stat
|
import com.unciv.models.stats.Stat
|
||||||
|
import com.unciv.models.stats.Stats
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
|
||||||
@ -186,20 +187,30 @@ object Battle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun plunderFromDamage(plunderingUnit: ICombatant, plunderedUnit: ICombatant, damageDealt: Int) {
|
private fun plunderFromDamage(plunderingUnit: ICombatant, plunderedUnit: ICombatant, damageDealt: Int) {
|
||||||
if (plunderingUnit is MapUnitCombatant) {
|
val plunderedGoods = Stats()
|
||||||
|
if (plunderingUnit !is MapUnitCombatant) return
|
||||||
|
|
||||||
for (unique in plunderingUnit.unit.getMatchingUniques("Earn []% of the damage done to [] units as []")) {
|
for (unique in plunderingUnit.unit.getMatchingUniques("Earn []% of the damage done to [] units as []")) {
|
||||||
if (plunderedUnit.matchesCategory(unique.params[1])) {
|
if (plunderedUnit.matchesCategory(unique.params[1])) {
|
||||||
val resourcesPlundered =
|
val resourcesPlundered =
|
||||||
(unique.params[0].toFloat() / 100f * damageDealt).toInt()
|
unique.params[0].toFloat() / 100f * damageDealt
|
||||||
plunderingUnit.getCivInfo().addStat(Stat.valueOf(unique.params[2]), resourcesPlundered)
|
plunderedGoods.add(Stat.valueOf(unique.params[2]), resourcesPlundered)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val plunderableStats = listOf("Gold", "Science", "Culture", "Faith").map { Stat.valueOf(it) }
|
||||||
|
for (stat in plunderableStats) {
|
||||||
|
val resourcesPlundered = plunderedGoods.get(stat)
|
||||||
|
if (resourcesPlundered == 0f) continue
|
||||||
|
plunderingUnit.getCivInfo().addStat(stat, resourcesPlundered.toInt())
|
||||||
plunderingUnit.getCivInfo()
|
plunderingUnit.getCivInfo()
|
||||||
.addNotification(
|
.addNotification(
|
||||||
"Your [${plunderingUnit.getName()}] plundered [${resourcesPlundered}] [${unique.params[2]}] from [${plunderedUnit.getName()}]",
|
"Your [${plunderingUnit.getName()}] plundered [${resourcesPlundered}] [${stat.name}] from [${plunderedUnit.getName()}]",
|
||||||
plunderedUnit.getTile().position,
|
plunderedUnit.getTile().position,
|
||||||
NotificationIcon.War
|
NotificationIcon.War
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user