mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
Remove "Camp" hardcoding and allow mods to do similar things (#2417)
This commit is contained in:
parent
2594777b52
commit
048ce0d3c3
@ -39,6 +39,7 @@
|
||||
// Resource-specific
|
||||
{
|
||||
"name": "Camp",
|
||||
"resourceTerrainAllow": ["Forest"],
|
||||
"turnsToBuild": 7,
|
||||
"techRequired": "Trapping",
|
||||
"improvingTech": "Economics",
|
||||
|
@ -177,10 +177,10 @@ class WorkerAutomation(val unit: MapUnit) {
|
||||
private fun chooseImprovement(tile: TileInfo, civInfo: CivilizationInfo): TileImprovement? {
|
||||
val improvementStringForResource : String ?= when {
|
||||
tile.resource == null || !tile.hasViewableResource(civInfo) -> null
|
||||
tile.terrainFeature == "Marsh" -> "Remove Marsh"
|
||||
tile.terrainFeature == "Fallout" -> "Remove Fallout"
|
||||
tile.terrainFeature == Constants.jungle -> "Remove Jungle"
|
||||
tile.terrainFeature == Constants.forest && tile.getTileResource().improvement!="Camp" -> "Remove Forest"
|
||||
tile.terrainFeature == "Marsh" && !isImprovementOnFeatureAllowed(tile,civInfo) -> "Remove Marsh"
|
||||
tile.terrainFeature == "Fallout" && !isImprovementOnFeatureAllowed(tile,civInfo) -> "Remove Fallout" // for really mad modders
|
||||
tile.terrainFeature == Constants.jungle && !isImprovementOnFeatureAllowed(tile,civInfo) -> "Remove Jungle"
|
||||
tile.terrainFeature == Constants.forest && !isImprovementOnFeatureAllowed(tile,civInfo) -> "Remove Forest"
|
||||
else -> tile.getTileResource().improvement
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ class WorkerAutomation(val unit: MapUnit) {
|
||||
evaluateFortPlacement(tile,civInfo) -> "Fort"
|
||||
// I think we can assume that the unique improvement is better
|
||||
uniqueImprovement!=null && tile.canBuildImprovement(uniqueImprovement,civInfo) -> uniqueImprovement.name
|
||||
|
||||
|
||||
tile.terrainFeature == "Fallout" -> "Remove Fallout"
|
||||
tile.terrainFeature == "Marsh" -> "Remove Marsh"
|
||||
tile.terrainFeature == Constants.jungle -> "Trading post"
|
||||
@ -211,6 +211,17 @@ class WorkerAutomation(val unit: MapUnit) {
|
||||
if (improvementString == null) return null
|
||||
return unit.civInfo.gameInfo.ruleSet.tileImprovements[improvementString]!!
|
||||
}
|
||||
private fun isImprovementOnFeatureAllowed(tile: TileInfo, civInfo: CivilizationInfo): Boolean {
|
||||
// Old hardcoded logic amounts to:
|
||||
//return tile.terrainFeature == Constants.forest && tile.getTileResource().improvement == "Camp"
|
||||
|
||||
// routine assumes the caller ensured that terrainFeature and resource are both present
|
||||
val resourceImprovementName = tile.getTileResource().improvement
|
||||
?: return false
|
||||
val resourceImprovement = civInfo.gameInfo.ruleSet.tileImprovements[resourceImprovementName]
|
||||
?: return false
|
||||
return resourceImprovement.resourceTerrainAllow.contains(tile.terrainFeature!!)
|
||||
}
|
||||
|
||||
private fun isAcceptableTileForFort(tile: TileInfo, civInfo: CivilizationInfo): Boolean
|
||||
{
|
||||
|
@ -281,7 +281,7 @@ open class TileInfo {
|
||||
improvement.name == "Remove Road" && this.roadStatus == RoadStatus.Road -> true
|
||||
improvement.name == "Remove Railroad" && this.roadStatus == RoadStatus.Railroad -> true
|
||||
improvement.name == Constants.cancelImprovementOrder && this.improvementInProgress != null -> true
|
||||
topTerrain.unbuildable && !(topTerrain.name == Constants.forest && improvement.name == "Camp") -> false
|
||||
topTerrain.unbuildable && (topTerrain.name !in improvement.resourceTerrainAllow) -> false
|
||||
"Can only be built on Coastal tiles" in improvement.uniques && isCoastalTile() -> true
|
||||
else -> hasViewableResource(civInfo) && getTileResource().improvement == improvement.name
|
||||
}
|
||||
|
@ -11,6 +11,11 @@ import kotlin.math.roundToInt
|
||||
class TileImprovement : NamedStats() {
|
||||
|
||||
var terrainsCanBeBuiltOn: Collection<String> = ArrayList()
|
||||
|
||||
// Used only for Camp - but avoid hardcoded comparison and *allow modding*
|
||||
// Terrain Features that need not be cleared if the improvement enables a resource
|
||||
var resourceTerrainAllow: Collection<String> = ArrayList()
|
||||
|
||||
var techRequired: String? = null
|
||||
|
||||
var improvingTech: String? = null
|
||||
|
Loading…
x
Reference in New Issue
Block a user