mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 14:24:43 -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)
|
val limit = unit.getMatchingUniques(UniqueType.MaxNumberBuildable)
|
||||||
.map { it.params[0].toInt() }.minOrNull()
|
.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
|
return false
|
||||||
|
|
||||||
val placedUnit = if (city != null || tile == null)
|
val placedUnit = if (city != null || tile == null)
|
||||||
@ -88,10 +88,13 @@ object UniqueTriggerActivation {
|
|||||||
|
|
||||||
val limit = unit.getMatchingUniques(UniqueType.MaxNumberBuildable)
|
val limit = unit.getMatchingUniques(UniqueType.MaxNumberBuildable)
|
||||||
.map { it.params[0].toInt() }.minOrNull()
|
.map { it.params[0].toInt() }.minOrNull()
|
||||||
|
val unitCount = civInfo.units.getCivUnits().count { it.name == unitName }
|
||||||
val amountFromTriggerable = unique.params[0].toInt()
|
val amountFromTriggerable = unique.params[0].toInt()
|
||||||
val actualAmount =
|
val actualAmount = when {
|
||||||
if (limit==null) amountFromTriggerable
|
limit == null -> amountFromTriggerable
|
||||||
else civInfo.units.getCivUnits().count { it.name==unitName } - limit
|
amountFromTriggerable + unitCount > limit -> limit - unitCount
|
||||||
|
else -> amountFromTriggerable
|
||||||
|
}
|
||||||
|
|
||||||
if (actualAmount <= 0) return false
|
if (actualAmount <= 0) return false
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user