mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-07 14:02:48 +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
|
val junkImprovement = tile.getTileImprovement()?.hasUnique(UniqueType.AutomatedWorkersWillReplace) == true
|
||||||
|| (tile.improvement == Constants.fort && !evaluateFortSuroundings(tile, false) && !civInfo.isHuman())
|
|| (tile.improvement == Constants.fort && !evaluateFortSuroundings(tile, false) && !civInfo.isHuman())
|
||||||
|
|
||||||
if (tile.improvement != null && junkImprovement == false
|
if (tile.improvement != null && !junkImprovement
|
||||||
&& !UncivGame.Current.settings.automatedWorkersReplaceImprovements
|
&& !UncivGame.Current.settings.automatedWorkersReplaceImprovements
|
||||||
&& unit.civ.isHuman())
|
&& unit.civ.isHuman())
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if (tile.improvement == null || junkImprovement == true) {
|
if (tile.improvement == null || junkImprovement) {
|
||||||
if (tile.improvementInProgress != null && unit.canBuildImprovement(tile.getTileImprovementInProgress()!!, tile)) return true
|
if (tile.improvementInProgress != null && unit.canBuildImprovement(tile.getTileImprovementInProgress()!!, tile)) return true
|
||||||
val chosenImprovement = chooseImprovement(unit, tile)
|
val chosenImprovement = chooseImprovement(unit, tile)
|
||||||
if (chosenImprovement != null && tile.improvementFunctions.canBuildImprovement(chosenImprovement, civInfo) && unit.canBuildImprovement(chosenImprovement, tile)) return true
|
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?,
|
city: City?,
|
||||||
cityUniqueCache: LocalUniqueCache = LocalUniqueCache(false)
|
cityUniqueCache: LocalUniqueCache = LocalUniqueCache(false)
|
||||||
): Stats {
|
): 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()
|
val stats = improvement.cloneStats()
|
||||||
if (tile.hasViewableResource(observingCiv) && tile.tileResource.isImprovedBy(improvement.name)
|
if (tile.hasViewableResource(observingCiv) && tile.tileResource.isImprovedBy(improvement.name)
|
||||||
&& tile.tileResource.improvementStats != null
|
&& 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 */
|
/** @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 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
|
/** Adds the [value] parameter to the instance value specified by [stat] in place
|
||||||
* @return `this` to allow chaining */
|
* @return `this` to allow chaining */
|
||||||
|
Loading…
Reference in New Issue
Block a user