mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-05 21:11:35 +07:00
Resolved #9871
Workers now remove fallout and similar stat-hindering terrains
This commit is contained in:
parent
ad75ad916b
commit
8de47b4a62
@ -342,12 +342,12 @@ class WorkerAutomation(
|
||||
val junkImprovement = tile.getTileImprovement()?.hasUnique(UniqueType.AutomatedWorkersWillReplace) == true
|
||||
|| (tile.improvement == Constants.fort && !evaluateFortSuroundings(tile, false) && !civInfo.isHuman())
|
||||
|
||||
if (tile.improvement != null && junkImprovement == false
|
||||
if (tile.improvement != null && !junkImprovement
|
||||
&& !UncivGame.Current.settings.automatedWorkersReplaceImprovements
|
||||
&& unit.civ.isHuman())
|
||||
return false
|
||||
|
||||
if (tile.improvement == null || junkImprovement == true) {
|
||||
if (tile.improvement == null || junkImprovement) {
|
||||
if (tile.improvementInProgress != null && unit.canBuildImprovement(tile.getTileImprovementInProgress()!!, tile)) return true
|
||||
val chosenImprovement = chooseImprovement(unit, tile)
|
||||
if (chosenImprovement != null && tile.improvementFunctions.canBuildImprovement(chosenImprovement, civInfo) && unit.canBuildImprovement(chosenImprovement, tile)) return true
|
||||
|
@ -201,6 +201,14 @@ class TileStatFunctions(val tile: Tile) {
|
||||
city: City?,
|
||||
cityUniqueCache: LocalUniqueCache = LocalUniqueCache(false)
|
||||
): Stats {
|
||||
if (improvement.name.startsWith(Constants.remove)){
|
||||
val currentTileStats = getTileStats(city, observingCiv, cityUniqueCache)
|
||||
val tileClone = tile.clone()
|
||||
tileClone.removeTerrainFeature(improvement.name.removePrefix(Constants.remove))
|
||||
val tileStatsAfterRemoval = tileClone.stats.getTileStats(city, observingCiv, cityUniqueCache)
|
||||
return tileStatsAfterRemoval.minus(currentTileStats)
|
||||
}
|
||||
|
||||
val stats = improvement.cloneStats()
|
||||
if (tile.hasViewableResource(observingCiv) && tile.tileResource.isImprovedBy(improvement.name)
|
||||
&& tile.tileResource.improvementStats != null
|
||||
|
@ -94,6 +94,7 @@ open class Stats(
|
||||
|
||||
/** @return a new [Stats] instance containing the sum of its operands value by value */
|
||||
operator fun plus(stats: Stats) = clone().apply { add(stats) }
|
||||
operator fun minus(stats: Stats) = clone().apply { add(stats.times(-1)) }
|
||||
|
||||
/** Adds the [value] parameter to the instance value specified by [stat] in place
|
||||
* @return `this` to allow chaining */
|
||||
|
Loading…
Reference in New Issue
Block a user