Can now play an entire scenario with no improvements or techs defined

This commit is contained in:
Yair Morgenstern 2020-08-11 22:53:48 +03:00
parent 7382d4f8e8
commit 5084bb6f9e
3 changed files with 10 additions and 6 deletions

View File

@ -283,6 +283,8 @@ class CivilizationInfo {
} }
fun getEra(): String { fun getEra(): String {
// For scenarios with no techs
if (gameInfo.ruleSet.technologies.isEmpty()) return "None"
if(tech.researchedTechnologies.isEmpty()) if(tech.researchedTechnologies.isEmpty())
return gameInfo.ruleSet.getEras().first() return gameInfo.ruleSet.getEras().first()
val maxEraOfTech = tech.researchedTechnologies val maxEraOfTech = tech.researchedTechnologies

View File

@ -124,6 +124,7 @@ class GameOptionsTable(val previousScreen: IPreviousScreen, val updatePlayerPick
} }
private fun Table.addEraSelectBox() { private fun Table.addEraSelectBox() {
if (ruleset.technologies.isEmpty()) return // scenario with no techs
val eras = ruleset.technologies.values.map { it.era() }.distinct() val eras = ruleset.technologies.values.map { it.era() }.distinct()
addSelectBox("{Starting Era}:", eras, gameParameters.startingEra) addSelectBox("{Starting Era}:", eras, gameParameters.startingEra)
{ gameParameters.startingEra = it } { gameParameters.startingEra = it }

View File

@ -27,14 +27,15 @@ class UnitContextMenu(val tileMapHolder: WorldMapHolder, val selectedUnit: MapUn
onMoveButtonClick() onMoveButtonClick()
} }
addButton( // Basic scenarios sommetimes don't have roads
ImageGetter.getImprovementIcon("Road"), if (selectedUnit.civInfo.gameInfo.ruleSet.tileImprovements.containsKey("Road"))
"Construct road", addButton(
BuildLongRoadAction(selectedUnit, targetTile) ImageGetter.getImprovementIcon("Road"),
) "Construct road",
BuildLongRoadAction(selectedUnit, targetTile)
)
pack() pack()
} }
fun addButton(icon: Actor, label: String, action: MapUnitAction) { fun addButton(icon: Actor, label: String, action: MapUnitAction) {