mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-19 20:28:56 +07:00
Deprecate "Can only be built on coastal tiles" unique (#4581)
* Deprecate "Can only be built on Coastal tiles" * Deprecate "Cannot be built on bonus resource" * Deprecate "Can only be built on Coastal tiles" - bump 'as of'
This commit is contained in:
@ -206,7 +206,7 @@
|
|||||||
"uniqueTo": "Polynesia",
|
"uniqueTo": "Polynesia",
|
||||||
"culture": 1,
|
"culture": 1,
|
||||||
"turnsToBuild": 4,
|
"turnsToBuild": 4,
|
||||||
"uniques": ["[+1 Culture] for each adjacent [Moai]", "Can only be built on Coastal tiles", "[+1 Gold] once [Flight] is discovered"],
|
"uniques": ["[+1 Culture] for each adjacent [Moai]", "Can only be built on [Coastal] tiles", "[+1 Gold] once [Flight] is discovered"],
|
||||||
"techRequired": "Construction",
|
"techRequired": "Construction",
|
||||||
"shortcutKey": "M"
|
"shortcutKey": "M"
|
||||||
},
|
},
|
||||||
@ -216,7 +216,7 @@
|
|||||||
"terrainsCanBeBuiltOn": ["Hill"],
|
"terrainsCanBeBuiltOn": ["Hill"],
|
||||||
"food": 1,
|
"food": 1,
|
||||||
"turnsToBuild": 7,
|
"turnsToBuild": 7,
|
||||||
"uniques": ["[+1 Food] for each adjacent [Mountain]", "Cannot be built on bonus resource",
|
"uniques": ["[+1 Food] for each adjacent [Mountain]", "Cannot be built on [Bonus resource] tiles",
|
||||||
"[+1 Food] on [Fresh water] tiles once [Civil Service] is discovered",
|
"[+1 Food] on [Fresh water] tiles once [Civil Service] is discovered",
|
||||||
"[+1 Food] on [non-fresh water] tiles once [Fertilizer] is discovered"],
|
"[+1 Food] on [non-fresh water] tiles once [Fertilizer] is discovered"],
|
||||||
"techRequired": "Construction",
|
"techRequired": "Construction",
|
||||||
|
@ -397,8 +397,10 @@ open class TileInfo {
|
|||||||
return when {
|
return when {
|
||||||
improvement.name == this.improvement -> false
|
improvement.name == this.improvement -> false
|
||||||
isCityCenter() -> false
|
isCityCenter() -> false
|
||||||
"Cannot be built on bonus resource" in improvement.uniques && resource != null
|
// deprecated as of 3.15.15
|
||||||
|
"Cannot be built on bonus resource" in improvement.uniques && resource != null
|
||||||
&& getTileResource().resourceType == ResourceType.Bonus -> false
|
&& getTileResource().resourceType == ResourceType.Bonus -> false
|
||||||
|
//
|
||||||
improvement.uniqueObjects.filter { it.placeholderText == "Cannot be built on [] tiles" }.any {
|
improvement.uniqueObjects.filter { it.placeholderText == "Cannot be built on [] tiles" }.any {
|
||||||
unique -> matchesTerrainFilter(unique.params[0])
|
unique -> matchesTerrainFilter(unique.params[0])
|
||||||
} -> false
|
} -> false
|
||||||
@ -425,10 +427,12 @@ open class TileInfo {
|
|||||||
topTerrain.unbuildable && !improvement.isAllowedOnFeature(topTerrain.name) -> false
|
topTerrain.unbuildable && !improvement.isAllowedOnFeature(topTerrain.name) -> false
|
||||||
// DO NOT reverse this &&. isAdjacentToFreshwater() is a lazy which calls a function, and reversing it breaks the tests.
|
// DO NOT reverse this &&. isAdjacentToFreshwater() is a lazy which calls a function, and reversing it breaks the tests.
|
||||||
improvement.hasUnique("Can also be built on tiles adjacent to fresh water") && isAdjacentToFreshwater -> true
|
improvement.hasUnique("Can also be built on tiles adjacent to fresh water") && isAdjacentToFreshwater -> true
|
||||||
"Can only be built on Coastal tiles" in improvement.uniques && isCoastalTile() -> true
|
// deprecated as of 3.15.15
|
||||||
improvement.uniqueObjects.filter { it.placeholderText == "Can only be built on [] tiles" }.any {
|
"Can only be built on Coastal tiles" in improvement.uniques && isCoastalTile() -> true
|
||||||
unique -> !matchesTerrainFilter(unique.params[0])
|
//
|
||||||
} -> false
|
improvement.uniqueObjects.filter { it.placeholderText == "Can only be built on [] tiles" }.all {
|
||||||
|
unique -> matchesTerrainFilter(unique.params[0])
|
||||||
|
} -> true
|
||||||
else -> resourceIsVisible && getTileResource().improvement == improvement.name
|
else -> resourceIsVisible && getTileResource().improvement == improvement.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -462,11 +466,16 @@ open class TileInfo {
|
|||||||
else -> {
|
else -> {
|
||||||
if (terrainFeatures.contains(filter)) return true
|
if (terrainFeatures.contains(filter)) return true
|
||||||
if (hasUnique(filter)) return true
|
if (hasUnique(filter)) return true
|
||||||
|
// Resource type check is last - cannot succeed if no resource here
|
||||||
|
if (resource == null) return false
|
||||||
// Checks 'luxury resource', 'strategic resource' and 'bonus resource' - only those that are visible of course
|
// Checks 'luxury resource', 'strategic resource' and 'bonus resource' - only those that are visible of course
|
||||||
if (observingCiv != null && hasViewableResource(observingCiv)
|
// not using hasViewableResource as observingCiv is often not passed in,
|
||||||
&& getTileResource().resourceType.name + " resource" == filter)
|
// and we want to be able to at least test for non-strategic in that case.
|
||||||
return true
|
val resourceObject = getTileResource()
|
||||||
return false
|
if (resourceObject.resourceType.name + " resource" != filter) return false // filter match
|
||||||
|
if (resourceObject.revealedBy == null) return true // no need for tech
|
||||||
|
if (observingCiv == null) return false // can't check tech
|
||||||
|
return observingCiv.tech.isResearched(resourceObject.revealedBy!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ class TileImprovementConstructionTests {
|
|||||||
map.tileMatrix.add(arrayListOf(tile, otherTile))
|
map.tileMatrix.add(arrayListOf(tile, otherTile))
|
||||||
|
|
||||||
for (improvement in ruleSet.tileImprovements.values) {
|
for (improvement in ruleSet.tileImprovements.values) {
|
||||||
if (!improvement.uniques.contains("Can only be built on Coastal tiles")) continue
|
if (!improvement.uniques.contains("Can only be built on [Coastal] tiles")) continue
|
||||||
civInfo.civName = improvement.uniqueTo ?: "OtherCiv"
|
civInfo.civName = improvement.uniqueTo ?: "OtherCiv"
|
||||||
val canBeBuilt = tile.canBuildImprovement(improvement, civInfo)
|
val canBeBuilt = tile.canBuildImprovement(improvement, civInfo)
|
||||||
Assert.assertTrue(improvement.name, canBeBuilt)
|
Assert.assertTrue(improvement.name, canBeBuilt)
|
||||||
@ -100,4 +100,19 @@ class TileImprovementConstructionTests {
|
|||||||
Assert.assertFalse(improvement.name, canBeBuilt)
|
Assert.assertFalse(improvement.name, canBeBuilt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun terraceFarmCanNOTBeBuiltOnBonus() {
|
||||||
|
tile.baseTerrain = "Plains"
|
||||||
|
tile.terrainFeatures.add("Hill")
|
||||||
|
tile.resource = "Sheep"
|
||||||
|
tile.setTransients()
|
||||||
|
civInfo.civName = "Inca"
|
||||||
|
|
||||||
|
for (improvement in ruleSet.tileImprovements.values) {
|
||||||
|
if (!improvement.uniques.contains("Cannot be built on [Bonus resource] tiles")) continue
|
||||||
|
val canBeBuilt = tile.canBuildImprovement(improvement, civInfo)
|
||||||
|
Assert.assertFalse(improvement.name, canBeBuilt)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user