mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 15:27:50 +07:00
changed hill to terrain Feature (#3707)
* changed hill to terrain Feature * Update Terrains.json * Update Terrains.json * Snow with capital S * Fixed tests failing * Added check for ruleset supports hill as terrain feature
This commit is contained in:
@ -60,16 +60,6 @@
|
||||
"RGB": [ 123, 202, 226],
|
||||
"uniques": ["Fresh water"]
|
||||
},
|
||||
{
|
||||
"name": "Hill",
|
||||
"type": "Land",
|
||||
"production": 2,
|
||||
"movementCost": 2,
|
||||
"overrideStats": true,
|
||||
"defenceBonus": 0.25,
|
||||
"RGB": [105,125,72],
|
||||
"uniques": ["Rough terrain"]
|
||||
},
|
||||
{
|
||||
"name": "Mountain",
|
||||
"type": "Land",
|
||||
@ -86,6 +76,17 @@
|
||||
},
|
||||
|
||||
// Terrain features
|
||||
{
|
||||
"name": "Hill",
|
||||
"type": "TerrainFeature",
|
||||
"production": 2,
|
||||
"movementCost": 2,
|
||||
"overrideStats": true,
|
||||
"defenceBonus": 0.25,
|
||||
"RGB": [105,125,72],
|
||||
"occursOn": ["Tundra","Plains","Grassland","Desert","Snow"],
|
||||
"uniques": ["Rough terrain"]
|
||||
},
|
||||
{
|
||||
"name": "Forest",
|
||||
"type": "TerrainFeature",
|
||||
|
@ -74,7 +74,7 @@ open class TileInfo {
|
||||
var roadStatus = RoadStatus.None
|
||||
var turnsToImprovement: Int = 0
|
||||
|
||||
fun isHill() = baseTerrain == Constants.hill || terrainFeatures.contains(Constants.hill)
|
||||
fun isHill() = terrainFeatures.contains(Constants.hill)
|
||||
|
||||
var hasBottomRightRiver = false
|
||||
var hasBottomRiver = false
|
||||
@ -560,6 +560,7 @@ open class TileInfo {
|
||||
|
||||
fun setTerrainTransients() {
|
||||
convertTerrainFeatureToArray()
|
||||
convertHillToTerrainFeature()
|
||||
if (!ruleset.terrains.containsKey(baseTerrain))
|
||||
throw Exception()
|
||||
baseTerrainObject = ruleset.terrains[baseTerrain]!!
|
||||
@ -658,5 +659,17 @@ open class TileInfo {
|
||||
improvement = improvementObject.name
|
||||
}
|
||||
|
||||
private fun convertHillToTerrainFeature(){
|
||||
if (baseTerrain == Constants.hill &&
|
||||
ruleset.terrains[Constants.hill]?.type == TerrainType.TerrainFeature){
|
||||
baseTerrain = Constants.grassland
|
||||
//We have to add hill as first terrain feature
|
||||
val copy = terrainFeatures.toTypedArray()
|
||||
terrainFeatures.clear()
|
||||
terrainFeatures.add(Constants.hill)
|
||||
terrainFeatures.addAll(copy)
|
||||
}
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ class MapGenerator(val ruleset: Ruleset) {
|
||||
|
||||
when {
|
||||
elevation <= 0.5 -> tile.baseTerrain = Constants.plains
|
||||
elevation <= 0.7 -> tile.baseTerrain = Constants.hill
|
||||
elevation <= 0.7 -> tile.terrainFeatures.add(Constants.hill)
|
||||
elevation <= 1.0 -> tile.baseTerrain = Constants.mountain
|
||||
}
|
||||
tile.setTerrainTransients()
|
||||
@ -258,12 +258,13 @@ class MapGenerator(val ruleset: Ruleset) {
|
||||
private fun spawnVegetation(tileMap: TileMap) {
|
||||
val vegetationSeed = randomness.RNG.nextInt().toDouble()
|
||||
val candidateTerrains = Constants.vegetation.flatMap{ ruleset.terrains[it]!!.occursOn }
|
||||
for (tile in tileMap.values.asSequence().filter { it.baseTerrain in candidateTerrains && it.terrainFeatures.isEmpty()
|
||||
&& (!it.isHill() || Constants.hill in candidateTerrains) }) {
|
||||
//Checking it.baseTerrain in candidateTerrains to make sure forest does not spawn on desert hill
|
||||
for (tile in tileMap.values.asSequence().filter { it.baseTerrain in candidateTerrains
|
||||
&& it.getLastTerrain().name in candidateTerrains }) {
|
||||
val vegetation = (randomness.getPerlinNoise(tile, vegetationSeed, scale = 3.0, nOctaves = 1) + 1.0) / 2.0
|
||||
|
||||
if (vegetation <= tileMap.mapParameters.vegetationRichness)
|
||||
tile.terrainFeatures.add(Constants.vegetation.filter { ruleset.terrains[it]!!.occursOn.contains(tile.baseTerrain) }.random(randomness.RNG))
|
||||
tile.terrainFeatures.add(Constants.vegetation.filter { ruleset.terrains[it]!!.occursOn.contains(tile.getLastTerrain().name) }.random(randomness.RNG))
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -40,6 +40,7 @@ class TileImprovementConstructionTests {
|
||||
for (improvement in ruleSet.tileImprovements.values) {
|
||||
val terrain = improvement.terrainsCanBeBuiltOn.firstOrNull() ?: continue
|
||||
tile.baseTerrain = terrain
|
||||
tile.terrainFeatures.clear()
|
||||
tile.setTransients()
|
||||
if (improvement.uniqueTo != null) civInfo.civName = improvement.uniqueTo!!
|
||||
val canBeBuilt = tile.canBuildImprovement(improvement, civInfo)
|
||||
|
@ -44,6 +44,7 @@ class UnitMovementAlgorithmsTests {
|
||||
fun canPassThroughPassableTerrains() {
|
||||
for (terrain in ruleSet.terrains.values) {
|
||||
tile.baseTerrain = terrain.name
|
||||
tile.terrainFeatures.clear()
|
||||
tile.setTransients()
|
||||
|
||||
unit.baseUnit = BaseUnit().apply { unitType = UnitType.Melee }
|
||||
|
Reference in New Issue
Block a user