mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 03:23:17 -04: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) {
|
private fun trainCombatUnit(city: CityInfo) {
|
||||||
val buildableUnits = city.cityConstructions.getConstructableUnits()
|
val combatUnits = city.cityConstructions.getConstructableUnits().filter { it.unitType != UnitType.Civilian }
|
||||||
val chosenUnit:Unit
|
val chosenUnit:Unit
|
||||||
if(city.civInfo.cities.any { it.getCenterTile().unit==null}
|
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
|
&& combatUnits.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 }!!
|
chosenUnit = combatUnits.filter { it.unitType==UnitType.Archery }.maxBy { it.cost }!!
|
||||||
else chosenUnit = buildableUnits.maxBy { it.cost }!!
|
else chosenUnit = combatUnits.maxBy { it.cost }!!
|
||||||
|
|
||||||
city.cityConstructions.currentConstruction = chosenUnit.name
|
city.cityConstructions.currentConstruction = chosenUnit.name
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,8 @@ class MapUnit {
|
|||||||
|
|
||||||
fun moveToTile(otherTile: TileInfo) {
|
fun moveToTile(otherTile: TileInfo) {
|
||||||
val distanceToTiles = getDistanceToTiles()
|
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!")
|
if (otherTile.unit != null ) throw Exception("Tile already contains a unit!")
|
||||||
|
|
||||||
currentMovement -= distanceToTiles[otherTile]!!
|
currentMovement -= distanceToTiles[otherTile]!!
|
||||||
@ -113,4 +114,8 @@ class MapUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun movementAlgs() = UnitMovementAlgorithms(this)
|
fun movementAlgs() = UnitMovementAlgorithms(this)
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return name +" - "+owner
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user