mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-10 02:47:24 +07:00
Civs no longer spam settlers beyond what they can afford
This commit is contained in:
parent
d3799a0c64
commit
e267a7a6be
@ -62,12 +62,12 @@ class Automation {
|
||||
}
|
||||
|
||||
private fun trainCombatUnit(city: CityInfo) {
|
||||
val buildableUnits = city.cityConstructions.getConstructableUnits()
|
||||
val combatUnits = city.cityConstructions.getConstructableUnits().filter { it.unitType != UnitType.Civilian }
|
||||
val chosenUnit:Unit
|
||||
if(city.civInfo.cities.any { it.getCenterTile().unit==null}
|
||||
&& buildableUnits.any { it.unitType==UnitType.Archery }) // this is for city defence so get an archery unit if we can
|
||||
chosenUnit = buildableUnits.filter { it.unitType==UnitType.Archery }.maxBy { it.cost }!!
|
||||
else chosenUnit = buildableUnits.maxBy { it.cost }!!
|
||||
&& combatUnits.any { it.unitType==UnitType.Archery }) // this is for city defence so get an archery unit if we can
|
||||
chosenUnit = combatUnits.filter { it.unitType==UnitType.Archery }.maxBy { it.cost }!!
|
||||
else chosenUnit = combatUnits.maxBy { it.cost }!!
|
||||
|
||||
city.cityConstructions.currentConstruction = chosenUnit.name
|
||||
}
|
||||
|
@ -86,7 +86,8 @@ class MapUnit {
|
||||
|
||||
fun moveToTile(otherTile: TileInfo) {
|
||||
val distanceToTiles = getDistanceToTiles()
|
||||
if (!distanceToTiles.containsKey(otherTile)) throw Exception("You can't get there from here!")
|
||||
if (!distanceToTiles.containsKey(otherTile))
|
||||
throw Exception("You can't get there from here!")
|
||||
if (otherTile.unit != null ) throw Exception("Tile already contains a unit!")
|
||||
|
||||
currentMovement -= distanceToTiles[otherTile]!!
|
||||
@ -113,4 +114,8 @@ class MapUnit {
|
||||
}
|
||||
|
||||
fun movementAlgs() = UnitMovementAlgorithms(this)
|
||||
|
||||
override fun toString(): String {
|
||||
return name +" - "+owner
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user