Civ picker adjusts to Scenarios with few civs

Map generator can handle maps with no water tiles
This commit is contained in:
Yair Morgenstern 2020-04-19 10:10:55 +03:00
parent 9b1ca770cb
commit 77b72cccf7
3 changed files with 10 additions and 3 deletions

View file

@ -33,7 +33,7 @@ class MapGenerator(val ruleset: Ruleset) {
return map
seedRNG(seed)
generateLand(map)
generateLand(map,ruleset)
raiseMountainsAndHills(map)
applyHumidityAndTemperature(map)
spawnLakesAndCoasts(map)
@ -565,7 +565,12 @@ class MapGenerator(val ruleset: Ruleset) {
companion object MapLandmassGenerator {
var RNG = Random(42)
fun generateLand(tileMap: TileMap) {
fun generateLand(tileMap: TileMap, ruleset: Ruleset) {
if(ruleset.terrains.values.none { it.type==TerrainType.Water }) {
for (tile in tileMap.values)
tile.baseTerrain = Constants.grassland
return
}
when (tileMap.mapParameters.type) {
MapType.pangaea -> createPangea(tileMap)
MapType.continents -> createTwoContinents(tileMap)

View file

@ -8,7 +8,7 @@ import com.unciv.models.ruleset.tech.TechEra
class GameParameters { // Default values are the default new game
var difficulty = "Prince"
var gameSpeed = GameSpeed.Standard
var players = ArrayList<Player>().apply {
var players = mutableListOf<Player>().apply {
add(Player().apply { playerType = PlayerType.Human })
for (i in 1..3) add(Player())
}

View file

@ -34,6 +34,8 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
val gameBasics = newGameScreen.ruleset // the mod picking changes this ruleset
reassignRemovedModReferences()
if(newGameParameters.players.size>newGameScreen.ruleset.nations.size)
newGameParameters.players=newGameParameters.players.subList(0,newGameScreen.ruleset.nations.size)
if (desiredCiv.isNotEmpty()) assignDesiredCiv(desiredCiv)
for (player in newGameParameters.players) {