mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
Fix MayWithdraw modifier calculation (#6829)
* Fix MayWithdraw modifier calculation * Readability changes Co-authored-by: OptimizedForDensity <>
This commit is contained in:
parent
8329d56131
commit
88585bcf7d
@ -77,7 +77,8 @@ object Battle {
|
|||||||
// Withdraw from melee ability
|
// Withdraw from melee ability
|
||||||
if (attacker is MapUnitCombatant && attacker.isMelee() && defender is MapUnitCombatant) {
|
if (attacker is MapUnitCombatant && attacker.isMelee() && defender is MapUnitCombatant) {
|
||||||
val withdrawUniques = defender.unit.getMatchingUniques(UniqueType.MayWithdraw)
|
val withdrawUniques = defender.unit.getMatchingUniques(UniqueType.MayWithdraw)
|
||||||
val baseWithdrawChance = 100-withdrawUniques.fold(100) { probability, unique -> probability * (100-unique.params[0].toInt()) }
|
val combinedProbabilityToStayPut = withdrawUniques.fold(100) { probabilityToStayPut, unique -> probabilityToStayPut * (100-unique.params[0].toInt()) / 100 }
|
||||||
|
val baseWithdrawChance = 100 - combinedProbabilityToStayPut
|
||||||
// If a mod allows multiple withdraw properties, they stack multiplicatively
|
// If a mod allows multiple withdraw properties, they stack multiplicatively
|
||||||
if (baseWithdrawChance != 0 && doWithdrawFromMeleeAbility(attacker, defender, baseWithdrawChance)) return
|
if (baseWithdrawChance != 0 && doWithdrawFromMeleeAbility(attacker, defender, baseWithdrawChance)) return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user