Grassland ad Tundra are now also constants, completing the set

This commit is contained in:
Yair Morgenstern 2019-10-20 10:48:16 +03:00
parent 384194c531
commit e2c19696c9
4 changed files with 15 additions and 14 deletions

View File

@ -776,7 +776,7 @@
German: "Untätige Einheiten anzeigen bei Rundenende"
French:"Vérifier les unités inactives"
Russian:"Найти незанятые юниты"
Korean:"
Korean:"턴이 끝나기 전에 미행동 유닛 보기"
}
"Move units with a single tap":{

View File

@ -14,6 +14,8 @@ class Constants{
const val plains = "Plains"
const val lakes = "Lakes"
const val desert = "Desert"
const val grassland = "Grassland"
const val tundra = "Tundra"
const val barbarianEncampment = "Barbarian encampment"

View File

@ -188,8 +188,8 @@ class WorkerAutomation(val unit: MapUnit) {
tile.terrainFeature == "Marsh" -> "Remove Marsh"
tile.terrainFeature == Constants.forest -> "Lumber mill"
tile.baseTerrain == Constants.hill -> "Mine"
tile.baseTerrain in listOf("Grassland",Constants.desert,Constants.plains) -> "Farm"
tile.baseTerrain == "Tundra" -> "Trading post"
tile.baseTerrain in listOf(Constants.grassland,Constants.desert,Constants.plains) -> "Farm"
tile.baseTerrain == Constants.tundra -> "Trading post"
else -> throw Exception("No improvement found for "+tile.baseTerrain)
}
if (improvementString == null) return null

View File

@ -200,15 +200,15 @@ class CelluarAutomataRandomMapGenerator(): SeedRandomMapGenerator() {
//change grassland to desert or tundra based on y
if (abs(getLatitude(tile.position)) < maxLatitude * 0.1) {
if (terrain == "Grassland" || terrain == "Tundra")
if (terrain == Constants.grassland || terrain == Constants.tundra)
terrain = Constants.desert
} else if (abs(getLatitude(tile.position)) > maxLatitude * 0.7) {
if (terrain == "Grassland" || terrain == Constants.plains || terrain == Constants.desert || terrain == Constants.ocean) {
terrain = "Tundra"
if (terrain == Constants.grassland || terrain == Constants.plains || terrain == Constants.desert || terrain == Constants.ocean) {
terrain = Constants.tundra
}
} else {
if (terrain == "Tundra") terrain = Constants.plains
else if (terrain == Constants.desert) terrain = "Grassland"
if (terrain == Constants.tundra) terrain = Constants.plains
else if (terrain == Constants.desert) terrain = Constants.grassland
}
val area = Area(terrain)
@ -282,10 +282,9 @@ class AlexanderRandomMapGenerator:RandomMapGenerator(){
map[vector] = null
val sparkList = ArrayList<Vector2>()
val grassland = "Grassland"
for(i in 0..distance*distance/6){
val location = map.filter { it.value==null }.map { it.key }.random()
map[location] = TileInfo().apply { baseTerrain= grassland}
map[location] = TileInfo().apply { baseTerrain= Constants.grassland}
sparkList.add(location)
}
@ -293,9 +292,9 @@ class AlexanderRandomMapGenerator:RandomMapGenerator(){
val currentSpark = sparkList.random()
val emptyTilesAroundSpark = HexMath().getAdjacentVectors(currentSpark)
.filter { map.containsKey(it) && map[it]==null }
if(map[currentSpark]!!.baseTerrain==grassland){
if(map[currentSpark]!!.baseTerrain==Constants.grassland){
for(tile in emptyTilesAroundSpark){
if(Math.random()<landExpansionChance) map[tile]=TileInfo().apply { baseTerrain=grassland }
if(Math.random()<landExpansionChance) map[tile]=TileInfo().apply { baseTerrain=Constants.grassland }
else map[tile]=TileInfo().apply { baseTerrain=Constants.ocean }
}
}
@ -311,8 +310,8 @@ class AlexanderRandomMapGenerator:RandomMapGenerator(){
for(entry in map){
entry.value!!.position = entry.key
if(entry.value!!.baseTerrain==Constants.ocean
&& HexMath().getAdjacentVectors(entry.key).all { !map.containsKey(it) || map[it]!!.baseTerrain==grassland })
entry.value!!.baseTerrain=grassland
&& HexMath().getAdjacentVectors(entry.key).all { !map.containsKey(it) || map[it]!!.baseTerrain==Constants.grassland })
entry.value!!.baseTerrain=Constants.grassland
newmap[entry.key.toString()] = entry.value!!
}