mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
Fix free units with a build limit not spawning (#10091)
* Fix free units with a build limit not spawning * Flip the amount when at the limit * Unrelated linting
This commit is contained in:
parent
fbb516f90f
commit
2061b2cc03
@ -61,7 +61,7 @@ object UniqueTriggerActivation {
|
||||
|
||||
val limit = unit.getMatchingUniques(UniqueType.MaxNumberBuildable)
|
||||
.map { it.params[0].toInt() }.minOrNull()
|
||||
if (limit!=null && limit <= civInfo.units.getCivUnits().count { it.name==unitName })
|
||||
if (limit != null && limit <= civInfo.units.getCivUnits().count { it.name == unitName })
|
||||
return false
|
||||
|
||||
val placedUnit = if (city != null || tile == null)
|
||||
@ -88,10 +88,13 @@ object UniqueTriggerActivation {
|
||||
|
||||
val limit = unit.getMatchingUniques(UniqueType.MaxNumberBuildable)
|
||||
.map { it.params[0].toInt() }.minOrNull()
|
||||
val unitCount = civInfo.units.getCivUnits().count { it.name == unitName }
|
||||
val amountFromTriggerable = unique.params[0].toInt()
|
||||
val actualAmount =
|
||||
if (limit==null) amountFromTriggerable
|
||||
else civInfo.units.getCivUnits().count { it.name==unitName } - limit
|
||||
val actualAmount = when {
|
||||
limit == null -> amountFromTriggerable
|
||||
amountFromTriggerable + unitCount > limit -> limit - unitCount
|
||||
else -> amountFromTriggerable
|
||||
}
|
||||
|
||||
if (actualAmount <= 0) return false
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user