Great improvements are no longer hardcoded, so new great improvements can be modded in =)

This commit is contained in:
Yair Morgenstern 2020-07-07 22:49:36 +03:00
parent ad5cf3a1ec
commit a06a4531be
5 changed files with 6 additions and 7 deletions

View file

@ -46,7 +46,6 @@ object Constants {
const val researchAgreement = "Research Agreement"
const val openBorders = "Open Borders"
const val random = "Random"
val greatImprovements = listOf("Academy", "Landmark", "Manufactory", "Customs house", "Citadel")
const val fort = "Fort"
const val citadel = "Citadel"

View file

@ -69,13 +69,12 @@ open class TileInfo {
}
fun containsGreatImprovement(): Boolean {
if (improvement in Constants.greatImprovements) return true
return false
return getTileImprovement()?.isGreatImprovement() == true
}
fun containsUnfinishedGreatImprovement(): Boolean {
if (improvementInProgress in Constants.greatImprovements) return true
return false
if(improvementInProgress==null) return false
return ruleset.tileImprovements[improvementInProgress!!]!!.isGreatImprovement()
}
fun containsUnique(unique: String): Boolean =

View file

@ -316,7 +316,7 @@ class Building : NamedStats(), IConstruction{
it.resource != null
&& requiredNearbyImprovedResources!!.contains(it.resource!!)
&& it.getOwner() == civInfo
&& (it.getTileResource().improvement == it.improvement || it.improvement in Constants.greatImprovements || it.isCityCenter())
&& (it.getTileResource().improvement == it.improvement || it.getTileImprovement()?.isGreatImprovement()==true || it.isCityCenter())
}
if (!containsResourceWithImprovement) return "Nearby $requiredNearbyImprovedResources required"
}

View file

@ -70,5 +70,6 @@ class TileImprovement : NamedStats() {
}
fun hasUnique(unique: String) = uniques.contains(unique)
fun isGreatImprovement() = hasUnique("Great improvement")
}

View file

@ -535,7 +535,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
improvement.terrainsCanBeBuiltOn.isEmpty() && improvement.turnsToBuild == 0
// Allow Great Improvement but clear unbuildable terrain feature
// Allow barbarian camps, ruins and similar without clear
-> if (topTerrain.unbuildable && improvement.name in Constants.greatImprovements)
-> if (topTerrain.unbuildable && improvement.isGreatImprovement())
tileInfo.terrainFeature = null
topTerrain.unbuildable
-> tileInfo.improvement = null // forbid on unbuildable feature