Resolved #687 - can now place starting locations for specific civs in the map editor
This commit is contained in:
parent
f42cfd8b25
commit
ab7ce12a87
9 changed files with 60 additions and 18 deletions
|
@ -446,8 +446,9 @@ All the following are from [the Noun Project](https://thenounproject.com) licenc
|
|||
* [Resistance](https://thenounproject.com/term/revolution/1315305/) By HeadsOfBirds
|
||||
* [Viking Hat](https://thenounproject.com/search/?q=pillage&i=185405) By my name is mud for pillaging improvements
|
||||
* [Aim](https://thenounproject.com/search/?q=aim&i=2034920) By Kaviashri for ranged strength
|
||||
* [Capitol](https://thenounproject.com/search/?q=capitol&i=160031) By Loren Klein, US for city states
|
||||
* [Capitol](https://thenounproject.com/search/?q=capitol&i=160031) By Loren Klein for city states
|
||||
* [Aircraft](https://thenounproject.com/search/?q=aircraft&i=1629000) By Tom Fricker
|
||||
* [radar scan](https://thenounproject.com/search/?q=range&i=1500234) By icon 54
|
||||
|
||||
# Sound credits
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 999 KiB After Width: | Height: | Size: 1,000 KiB |
|
@ -838,7 +838,7 @@
|
|||
hurryCostModifier:20,
|
||||
attackSound:"shot"
|
||||
},
|
||||
|
||||
/*
|
||||
{
|
||||
name:"Triplane",
|
||||
unitType:"AirFighter",
|
||||
|
|
|
@ -108,22 +108,42 @@ class GameStarter{
|
|||
.toMutableList()
|
||||
|
||||
val startingLocations = HashMap<CivilizationInfo,TileInfo>()
|
||||
for(civ in civs){
|
||||
if(freeTiles.isEmpty()) break // we failed to get all the starting locations with this minimum distance
|
||||
var preferredTiles = freeTiles.toList()
|
||||
for(startBias in civ.getNation().startBias){
|
||||
if(startBias.startsWith("Avoid ")) {
|
||||
val tileToAvoid = startBias.removePrefix("Avoid ")
|
||||
preferredTiles = preferredTiles.filter { it.baseTerrain != tileToAvoid && it.terrainFeature != tileToAvoid}
|
||||
|
||||
val tilesWithStartingLocations = tileMap.values
|
||||
.filter { it.improvement!=null && it.improvement!!.startsWith("StartingLocation ") }
|
||||
|
||||
val civsOrderedByAvailableLocations = civs.sortedBy {civ ->
|
||||
when {
|
||||
tilesWithStartingLocations.any { it.improvement=="StartingLocation "+civ.civName } -> 1 // harshest requirements
|
||||
civ.getNation().startBias.isNotEmpty() -> 2 // less harsh
|
||||
else -> 3
|
||||
} // no requirements
|
||||
}
|
||||
|
||||
for(civ in civsOrderedByAvailableLocations){
|
||||
var startingLocation:TileInfo
|
||||
val presetStartingLocation = tilesWithStartingLocations.firstOrNull { it.improvement=="StartingLocation "+civ.civName }
|
||||
if(presetStartingLocation!=null) startingLocation = presetStartingLocation
|
||||
else {
|
||||
if (freeTiles.isEmpty()) break // we failed to get all the starting locations with this minimum distance
|
||||
var preferredTiles = freeTiles.toList()
|
||||
|
||||
for (startBias in civ.getNation().startBias) {
|
||||
if (startBias.startsWith("Avoid ")) {
|
||||
val tileToAvoid = startBias.removePrefix("Avoid ")
|
||||
preferredTiles = preferredTiles.filter { it.baseTerrain != tileToAvoid && it.terrainFeature != tileToAvoid }
|
||||
} else if (startBias == Constants.coast) preferredTiles = preferredTiles.filter { it.neighbors.any { n -> n.baseTerrain == startBias } }
|
||||
else preferredTiles = preferredTiles.filter { it.baseTerrain == startBias || it.terrainFeature == startBias }
|
||||
}
|
||||
else if(startBias==Constants.coast) preferredTiles = preferredTiles.filter { it.neighbors.any { n -> n.baseTerrain==startBias } }
|
||||
else preferredTiles = preferredTiles.filter { it.baseTerrain == startBias || it.terrainFeature==startBias }
|
||||
|
||||
startingLocation = if (preferredTiles.isNotEmpty()) preferredTiles.random() else freeTiles.random()
|
||||
}
|
||||
val randomLocation = if(preferredTiles.isNotEmpty()) preferredTiles.random() else freeTiles.random()
|
||||
startingLocations.put(civ, randomLocation)
|
||||
freeTiles.removeAll(tileMap.getTilesInDistance(randomLocation.position,minimumDistanceBetweenStartingLocations))
|
||||
startingLocations[civ] = startingLocation
|
||||
freeTiles.removeAll(tileMap.getTilesInDistance(startingLocation.position,minimumDistanceBetweenStartingLocations))
|
||||
}
|
||||
if(startingLocations.size < civs.size) continue // let's try again with less minimum distance!
|
||||
|
||||
for(tile in tilesWithStartingLocations) tile.improvement=null // get rid of the starting location improvements
|
||||
return startingLocations
|
||||
}
|
||||
throw Exception("Didn't manage to get starting locations even with distance of 1?")
|
||||
|
|
|
@ -129,6 +129,8 @@ class CivilizationInfo {
|
|||
fun isMajorCiv() = !isBarbarianCivilization() && !isCityState()
|
||||
|
||||
fun victoryType(): VictoryType {
|
||||
if(gameInfo.gameParameters.victoryTypes.size==1)
|
||||
return gameInfo.gameParameters.victoryTypes.first() // That is the most relevant one
|
||||
val victoryType = getNation().preferredVictoryType
|
||||
if(gameInfo.gameParameters.victoryTypes.contains(victoryType)) return victoryType
|
||||
else return VictoryType.Neutral
|
||||
|
|
|
@ -59,8 +59,10 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||
}
|
||||
|
||||
private fun setImprovements() {
|
||||
val improvementsTable = Table()
|
||||
|
||||
editorPickTable.clear()
|
||||
|
||||
val improvementsTable = Table()
|
||||
improvementsTable.add(getHex(Color.WHITE).apply {
|
||||
onClick {
|
||||
clearSelection()
|
||||
|
@ -79,9 +81,20 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||
}
|
||||
improvementsTable.add(improvementImage).row()
|
||||
}
|
||||
|
||||
editorPickTable.clear()
|
||||
editorPickTable.add(ScrollPane(improvementsTable)).height(mapEditorScreen.stage.height*0.7f)
|
||||
|
||||
val nationsTable = Table()
|
||||
for(nation in GameBasics.Nations.values){
|
||||
val nationImage = getHex(Color.WHITE,ImageGetter.getNationIndicator(nation,40f))
|
||||
nationImage.onClick {
|
||||
clearSelection()
|
||||
selectedImprovement=TileImprovement().apply { name="StartingLocation "+nation.name }
|
||||
setCurrentHex(getHex(Color.WHITE,ImageGetter.getNationIndicator(nation,40f)))
|
||||
}
|
||||
nationsTable.add(nationImage).row()
|
||||
}
|
||||
|
||||
editorPickTable.add(ScrollPane(nationsTable)).height(mapEditorScreen.stage.height*0.7f)
|
||||
}
|
||||
|
||||
fun setTerrainsAndResources(){
|
||||
|
|
|
@ -89,8 +89,13 @@ object ImageGetter {
|
|||
val productionCircleColor = Color.BROWN.cpy().lerp(Color.WHITE,0.5f)!!
|
||||
val goldCircleColor = Color.GOLD.cpy().lerp(Color.WHITE,0.5f)!!
|
||||
fun getImprovementIcon(improvementName:String, size:Float=20f):Actor{
|
||||
val iconGroup = getImage("ImprovementIcons/$improvementName").surroundWithCircle(size)
|
||||
if(improvementName.startsWith("StartingLocation ")){
|
||||
val nationName = improvementName.removePrefix("StartingLocation ")
|
||||
val nation = GameBasics.Nations[nationName]!!
|
||||
return getNationIndicator(nation,size)
|
||||
}
|
||||
|
||||
val iconGroup = getImage("ImprovementIcons/$improvementName").surroundWithCircle(size)
|
||||
|
||||
val improvement = GameBasics.TileImprovements[improvementName]!!
|
||||
when {
|
||||
|
|
|
@ -20,6 +20,7 @@ class WorldScreenMenuTable(val worldScreen: WorldScreen) : PopupTable(worldScree
|
|||
for(tile in tileMapClone.values){
|
||||
tile.militaryUnit=null
|
||||
tile.civilianUnit=null
|
||||
tile.airUnits=ArrayList()
|
||||
}
|
||||
UnCivGame.Current.screen = MapEditorScreen(tileMapClone)
|
||||
remove()
|
||||
|
|
Loading…
Reference in a new issue