mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 21:35:14 -04:00
Fixing workers dying in mountains bug for Carthage (#9665)
* Fixed workers dying in mountain tiles issue for Carthage * Accounts for all damage dealing tiles * Update WorkerAutomation.kt * Update Tile.kt * Update WorkerAutomation.kt * Update WorkerAutomation.kt
This commit is contained in:
parent
73fa87e6b4
commit
d298f85099
@ -270,7 +270,7 @@ class WorkerAutomation(
|
|||||||
.filter {
|
.filter {
|
||||||
it !in tilesToAvoid
|
it !in tilesToAvoid
|
||||||
&& (it.civilianUnit == null || it == currentTile)
|
&& (it.civilianUnit == null || it == currentTile)
|
||||||
&& (it.owningCity == null || it.getOwner()==civInfo)
|
&& (it.owningCity == null || it.getOwner() == civInfo)
|
||||||
&& getPriority(it) > 1
|
&& getPriority(it) > 1
|
||||||
&& it.getTilesInDistance(2) // don't work in range of enemy cities
|
&& it.getTilesInDistance(2) // don't work in range of enemy cities
|
||||||
.none { tile -> tile.isCityCenter() && tile.getCity()!!.civ.isAtWarWith(civInfo) }
|
.none { tile -> tile.isCityCenter() && tile.getCity()!!.civ.isAtWarWith(civInfo) }
|
||||||
@ -279,9 +279,11 @@ class WorkerAutomation(
|
|||||||
}
|
}
|
||||||
.sortedByDescending { getPriority(it) }
|
.sortedByDescending { getPriority(it) }
|
||||||
|
|
||||||
|
// Carthage can move through mountains, special case
|
||||||
|
// If there is a non-damage dealing tile available, move to that tile, otherwise move to the damage dealing tile
|
||||||
// These are the expensive calculations (tileCanBeImproved, canReach), so we only apply these filters after everything else it done.
|
// These are the expensive calculations (tileCanBeImproved, canReach), so we only apply these filters after everything else it done.
|
||||||
val selectedTile =
|
val selectedTile =
|
||||||
workableTiles.firstOrNull { unit.movement.canReach(it) && (tileCanBeImproved(unit, it) || it.isPillaged()) }
|
workableTiles.sortedByDescending { tile -> unit.getDamageFromTerrain(tile) <= 0 }.firstOrNull { unit.movement.canReach(it) && (tileCanBeImproved(unit, it) || it.isPillaged()) }
|
||||||
?: return currentTile
|
?: return currentTile
|
||||||
|
|
||||||
return if ((!tileCanBeImproved(unit, currentTile) && !currentTile.isPillaged()) // current tile is unimprovable
|
return if ((!tileCanBeImproved(unit, currentTile) && !currentTile.isPillaged()) // current tile is unimprovable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user