mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-14 17:59:11 +07:00
AI: Better rules to not build unit-carrying units
This commit is contained in:
@ -159,7 +159,9 @@ object Automation {
|
||||
val totalCarriableUnits =
|
||||
civInfo.units.getCivUnits().count { it.matchesFilter(carryFilter) }
|
||||
val totalCarryingSlots = civInfo.units.getCivUnits().sumOf { getCarryAmount(it) }
|
||||
return totalCarriableUnits < totalCarryingSlots
|
||||
val currentUnitCarryingSlots = carryUnique.params[0].toInt()
|
||||
|
||||
return totalCarriableUnits < totalCarryingSlots + currentUnitCarryingSlots
|
||||
}
|
||||
|
||||
fun chooseMilitaryUnit(city: City, availableUnits: Sequence<BaseUnit>): String? {
|
||||
@ -197,7 +199,7 @@ object Automation {
|
||||
.filter { allowSpendingResource(city.civ, it) }
|
||||
.filterNot {
|
||||
// filter out carrier-type units that can't attack if we don't need them
|
||||
(it.hasUnique(UniqueType.CarryAirUnits) && it.hasUnique(UniqueType.CannotAttack))
|
||||
it.hasUnique(UniqueType.CarryAirUnits)
|
||||
&& providesUnneededCarryingSlots(it, city.civ)
|
||||
}
|
||||
// Only now do we filter out the constructable units because that's a heavier check
|
||||
|
Reference in New Issue
Block a user