Add uniques to remove tile resources and improvements (#13390)

* Add unique to remove tile resources and improvements

* Remove the unneeded RoadStatus import

* Add resourceFilter and improvementFilter to the remove tiles

* Use removeImprovement() and removeRoad()

* Clean up the code
This commit is contained in:
Rob Loach 2025-06-07 16:29:53 -04:00 committed by GitHub
parent 6cf6a99653
commit 2bbd2e6f1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 45 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import com.unciv.logic.civilization.managers.ReligionState
import com.unciv.logic.map.mapgenerator.NaturalWonderGenerator
import com.unciv.logic.map.mapgenerator.RiverGenerator
import com.unciv.logic.map.mapunit.MapUnit
import com.unciv.logic.map.tile.RoadStatus
import com.unciv.logic.map.tile.Tile
import com.unciv.logic.map.tile.TileNormalizer
import com.unciv.models.UpgradeUnitAction
@ -1073,6 +1074,38 @@ object UniqueTriggerActivation {
}
}
UniqueType.OneTimeRemoveResourcesFromTile -> {
if (tile == null) return null
if (tile.resource == null) return null
val resourceFilter = unique.params[0]
if (!tile.tileResource.matchesFilter(resourceFilter)) return null
return {
tile.resource = null
tile.resourceAmount = 0
true
}
}
UniqueType.OneTimeRemoveImprovementsFromTile -> {
if (tile == null) return null
val tileImprovement = tile.getTileImprovement()
if (tileImprovement == null) return null
val improvementFilter = unique.params[0]
if (!tileImprovement.matchesFilter(improvementFilter)) return null
return {
// Don't remove the improvement if we're just removing the roads
if (improvementFilter != "All Road") {
tile.removeImprovement()
}
// Remove the roads if desired
if (improvementFilter == "All" || improvementFilter == "All Road") {
tile.removeRoad()
}
true
}
}
UniqueType.OneTimeChangeTerrain -> {
if (tile == null) return null
val terrain = ruleset.terrains[unique.params[0]] ?: return null

View File

@ -865,6 +865,8 @@ enum class UniqueType(
OneTimeChangeTerrain("Turn this tile into a [terrainName] tile", UniqueTarget.Triggerable),
OneTimeRemoveResourcesFromTile("Remove [resourceFilter] resources from this tile", UniqueTarget.Triggerable),
OneTimeRemoveImprovementsFromTile("Remove [improvementFilter] improvements from this tile", UniqueTarget.Triggerable),
UnitsGainPromotion("[mapUnitFilter] units gain the [promotion] promotion", UniqueTarget.Triggerable,
docDescription = "Works only with promotions that are valid for the unit's type - or for promotions that do not specify any."), // Not used in Vanilla

View File

@ -176,6 +176,16 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: Triggerable
??? example "Remove [resourceFilter] resources from this tile"
Example: "Remove [Strategic] resources from this tile"
Applicable to: Triggerable
??? example "Remove [improvementFilter] improvements from this tile"
Example: "Remove [All Road] improvements from this tile"
Applicable to: Triggerable
??? example "[mapUnitFilter] units gain the [promotion] promotion"
Works only with promotions that are valid for the unit's type - or for promotions that do not specify any.
Example: "[Wounded] units gain the [Shock I] promotion"