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 {
// For scenarios with no techs
if (gameInfo.ruleSet.technologies.isEmpty()) return "None"
if(tech.researchedTechnologies.isEmpty())
return gameInfo.ruleSet.getEras().first()
val maxEraOfTech = tech.researchedTechnologies

View File

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

View File

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