mirror of
https://github.com/yairm210/Unciv.git
synced 2025-10-02 16:31:15 -04:00
Fixed bug where embarked automated workers with no workable tiles around, would try to work the water tile they were on (thanks Pommerbot X for sending the game data, this was pretty niche!)
This commit is contained in:
parent
566e555447
commit
8186db0a17
@ -133,7 +133,9 @@ class UnitAutomation{
|
|||||||
}
|
}
|
||||||
val tileCombatant = Battle(unit.civInfo.gameInfo).getMapCombatantOfTile(tile)
|
val tileCombatant = Battle(unit.civInfo.gameInfo).getMapCombatantOfTile(tile)
|
||||||
if(tileCombatant==null) return false
|
if(tileCombatant==null) return false
|
||||||
return tileCombatant.getCivilization()!=unit.civInfo && unit.civInfo.isAtWarWith(tileCombatant.getCivilization())
|
if(tileCombatant.getCivilization()==unit.civInfo ) return false
|
||||||
|
if(!unit.civInfo.isAtWarWith(tileCombatant.getCivilization())) return false
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
class AttackableTile(val tileToAttackFrom:TileInfo, val tileToAttack:TileInfo)
|
class AttackableTile(val tileToAttackFrom:TileInfo, val tileToAttack:TileInfo)
|
||||||
|
@ -30,7 +30,7 @@ class WorkerAutomation(val unit: MapUnit) {
|
|||||||
if(reachedTile!=tile) unit.doPreTurnAction() // otherwise, we get a situation where the worker is automated, so it tries to move but doesn't, then tries to automate, then move, etc, forever. Stack overflow exception!
|
if(reachedTile!=tile) unit.doPreTurnAction() // otherwise, we get a situation where the worker is automated, so it tries to move but doesn't, then tries to automate, then move, etc, forever. Stack overflow exception!
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (tile.improvementInProgress == null) {
|
if (tile.improvementInProgress == null && tile.getBaseTerrain().type==TerrainType.Land) {
|
||||||
val improvement = chooseImprovement(tile)
|
val improvement = chooseImprovement(tile)
|
||||||
if (tile.canBuildImprovement(improvement, unit.civInfo)) {
|
if (tile.canBuildImprovement(improvement, unit.civInfo)) {
|
||||||
// What if we're stuck on this tile but can't build there?
|
// What if we're stuck on this tile but can't build there?
|
||||||
@ -74,6 +74,9 @@ class WorkerAutomation(val unit: MapUnit) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current tile if no tile to work was found
|
||||||
|
*/
|
||||||
private fun findTileToWork(): TileInfo {
|
private fun findTileToWork(): TileInfo {
|
||||||
val currentTile=unit.getTile()
|
val currentTile=unit.getTile()
|
||||||
val workableTiles = currentTile.getTilesInDistance(4)
|
val workableTiles = currentTile.getTilesInDistance(4)
|
||||||
@ -124,7 +127,7 @@ class WorkerAutomation(val unit: MapUnit) {
|
|||||||
tile.baseTerrain == "Hill" -> "Mine"
|
tile.baseTerrain == "Hill" -> "Mine"
|
||||||
tile.baseTerrain in listOf("Grassland","Desert","Plains") -> "Farm"
|
tile.baseTerrain in listOf("Grassland","Desert","Plains") -> "Farm"
|
||||||
tile.baseTerrain == "Tundra" -> "Trading post"
|
tile.baseTerrain == "Tundra" -> "Trading post"
|
||||||
else -> null
|
else -> throw Exception("No improvement found for "+tile.baseTerrain)
|
||||||
}
|
}
|
||||||
return GameBasics.TileImprovements[improvementString]!!
|
return GameBasics.TileImprovements[improvementString]!!
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user