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