diff --git a/core/src/com/unciv/logic/automation/BarbarianAutomation.kt b/core/src/com/unciv/logic/automation/BarbarianAutomation.kt index f5a6316f..4058a566 100644 --- a/core/src/com/unciv/logic/automation/BarbarianAutomation.kt +++ b/core/src/com/unciv/logic/automation/BarbarianAutomation.kt @@ -83,10 +83,7 @@ class BarbarianAutomation(val civInfo: CivilizationInfo) { if (UnitAutomation().tryPillageImprovement(unit, unitDistanceToTiles)) return // 5 - heal the unit if needed - if (unit.health < 100) { - UnitAutomation().tryHealUnit(unit, unitDistanceToTiles) - return - } + if (unit.health < 100 && UnitAutomation().tryHealUnit(unit, unitDistanceToTiles)) return // 6 - wander UnitAutomation().wander(unit, unitDistanceToTiles) @@ -114,10 +111,7 @@ class BarbarianAutomation(val civInfo: CivilizationInfo) { if (UnitAutomation().tryPillageImprovement(unit, unitDistanceToTiles)) return // 4 - heal the unit if needed - if (unit.health < 100) { - UnitAutomation().tryHealUnit(unit, unitDistanceToTiles) - return - } + if (unit.health < 100 && UnitAutomation().tryHealUnit(unit, unitDistanceToTiles)) return // 5 - wander UnitAutomation().wander(unit, unitDistanceToTiles) diff --git a/core/src/com/unciv/logic/automation/UnitAutomation.kt b/core/src/com/unciv/logic/automation/UnitAutomation.kt index 79b6191d..2288025d 100644 --- a/core/src/com/unciv/logic/automation/UnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/UnitAutomation.kt @@ -362,40 +362,25 @@ class UnitAutomation { } internal fun tryExplore(unit: MapUnit, unitDistanceToTiles: PathsToTilesWithinTurn): Boolean { - if (tryGoToRuin(unit, unitDistanceToTiles)) { - if (unit.currentMovement == 0f) return true - } + if (tryGoToRuin(unit, unitDistanceToTiles) && unit.currentMovement == 0f) return true - for (tile in unit.currentTile.getTilesInDistance(5)) + for (tile in unit.currentTile.getTilesInDistance(10)) if (unit.movement.canMoveTo(tile) && tile.position !in unit.civInfo.exploredTiles - && unit.movement.canReach(tile)) { + && unit.movement.canReach(tile) + && (tile.getOwner()==null || !tile.getOwner()!!.isCityState())) { unit.movement.headTowards(tile) return true } return false } + /** This is what a unit with the 'explore' action does. + It also explores, but also has other functions, like healing if necessary. */ fun automatedExplore(unit: MapUnit) { val unitDistanceToTiles = unit.movement.getDistanceToTiles() if (tryGoToRuin(unit, unitDistanceToTiles) && unit.currentMovement == 0f) return - - if (unit.health < 80) { - tryHealUnit(unit, unitDistanceToTiles) - return - } - - for (i in 1..10) { - val unexploredTilesAtDistance = unit.getTile().getTilesAtDistance(i) - .filter { - unit.movement.canMoveTo(it) && it.position !in unit.civInfo.exploredTiles - && unit.movement.canReach(it) - && (it.getOwner()==null || !it.getOwner()!!.isCityState()) - } - if (unexploredTilesAtDistance.isNotEmpty()) { - unit.movement.headTowards(unexploredTilesAtDistance.random()) - return - } - } + if (unit.health < 80 && tryHealUnit(unit, unitDistanceToTiles)) return + if (tryExplore(unit, unit.movement.getDistanceToTiles())) return unit.civInfo.addNotification("[${unit.name}] finished exploring.", unit.currentTile.position, Color.GRAY) } diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index 51aa407f..8a13eed3 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -379,8 +379,9 @@ class CityInfo { val oldCiv = civInfo // must be before moving the city to the conquering civ, - // so the sum of population isn't 0 when conquering the last city of a civ + // so the repercussions are properly checked diplomaticRepercussionsForConqueringCity(oldCiv, conqueringCiv) + moveToCiv(conqueringCiv) Battle.destroyIfDefeated(oldCiv, conqueringCiv)