Nuclear weapons setting moved to a per-game parameter
This commit is contained in:
parent
567a9446ad
commit
dffd377510
6 changed files with 18 additions and 21 deletions
|
@ -166,7 +166,7 @@ class CivilizationInfo {
|
|||
/**
|
||||
* Returns a dictionary of ALL resource names, and the amount that the civ has of each
|
||||
*/
|
||||
fun getCivResourcesByName():HashMap<String,Int>{
|
||||
fun getCivResourcesByName():HashMap<String,Int> {
|
||||
val hashMap = HashMap<String,Int>()
|
||||
for(resource in gameInfo.ruleSet.tileResources.keys) hashMap[resource]=0
|
||||
for(entry in getCivResources())
|
||||
|
@ -353,9 +353,9 @@ class CivilizationInfo {
|
|||
tech.civInfo = this
|
||||
tech.setTransients()
|
||||
|
||||
diplomacy.values.forEach {
|
||||
it.civInfo=this
|
||||
it.updateHasOpenBorders()
|
||||
for (diplomacyManager in diplomacy.values) {
|
||||
diplomacyManager.civInfo=this
|
||||
diplomacyManager.updateHasOpenBorders()
|
||||
}
|
||||
|
||||
victoryManager.civInfo=this
|
||||
|
|
|
@ -15,6 +15,7 @@ class GameParameters { // Default values are the default new game
|
|||
|
||||
var noBarbarians = false
|
||||
var oneCityChallenge = false
|
||||
var nuclearWeaponsEnabled = true
|
||||
|
||||
var victoryTypes: ArrayList<VictoryType> = VictoryType.values().toCollection(ArrayList()) // By default, all victory types
|
||||
var startingEra = TechEra.Ancient
|
||||
|
|
|
@ -74,7 +74,7 @@ class Technology {
|
|||
val replacedBuildings = enabledBuildings.mapNotNull { it.replaces }
|
||||
enabledBuildings = enabledBuildings.filter { it.name !in replacedBuildings }
|
||||
|
||||
if (!UncivGame.Current.settings.nuclearWeaponEnabled)
|
||||
if (civInfo.gameInfo.gameParameters.nuclearWeaponsEnabled)
|
||||
enabledBuildings=enabledBuildings.filterNot { it.name=="Manhattan Project" }
|
||||
|
||||
return enabledBuildings
|
||||
|
@ -88,9 +88,8 @@ class Technology {
|
|||
val replacedUnits = enabledUnits.mapNotNull { it.replaces }
|
||||
enabledUnits = enabledUnits.filter { it.name !in replacedUnits }
|
||||
|
||||
if (!UncivGame.Current.settings.nuclearWeaponEnabled)
|
||||
enabledUnits=enabledUnits.filterNot { it.uniques.contains("Requires Manhattan Project") }
|
||||
|
||||
if (!civInfo.gameInfo.gameParameters.nuclearWeaponsEnabled)
|
||||
enabledUnits = enabledUnits.filterNot { it.uniques.contains("Requires Manhattan Project") }
|
||||
|
||||
return enabledUnits
|
||||
}
|
||||
|
|
|
@ -137,8 +137,8 @@ class BaseUnit : INamed, IConstruction {
|
|||
if (obsoleteTech!=null && civInfo.tech.isResearched(obsoleteTech!!)) return "Obsolete by $obsoleteTech"
|
||||
if (uniqueTo!=null && uniqueTo!=civInfo.civName) return "Unique to $uniqueTo"
|
||||
if (civInfo.gameInfo.ruleSet.units.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return "Our unique unit replaces this"
|
||||
if (!UncivGame.Current.settings.nuclearWeaponEnabled
|
||||
&& (name == "Manhattan Project" || uniques.contains("Requires Manhattan Project"))) return "Disabled by setting"
|
||||
if (!civInfo.gameInfo.gameParameters.nuclearWeaponsEnabled
|
||||
&& uniques.contains("Requires Manhattan Project")) return "Disabled by setting"
|
||||
if (uniques.contains("Requires Manhattan Project") && !civInfo.containsBuildingUnique("Enables nuclear weapon"))
|
||||
return "Requires Manhattan Project"
|
||||
if (requiredResource!=null && !civInfo.hasResource(requiredResource!!)) return "Consumes 1 [$requiredResource]"
|
||||
|
|
|
@ -41,6 +41,7 @@ class NewGameScreenOptionsTable(val newGameScreen: NewGameScreen, val updatePlay
|
|||
addVictoryTypeCheckboxes()
|
||||
addBarbariansCheckbox()
|
||||
addOneCityChallengeCheckbox()
|
||||
addNuclearWeaponsCheckbox()
|
||||
addIsOnlineMultiplayerCheckbox()
|
||||
addModCheckboxes()
|
||||
|
||||
|
@ -101,15 +102,18 @@ class NewGameScreenOptionsTable(val newGameScreen: NewGameScreen, val updatePlay
|
|||
add(checkbox).colspan(2).row()
|
||||
}
|
||||
|
||||
private fun addBarbariansCheckbox() {
|
||||
private fun addBarbariansCheckbox() =
|
||||
addCheckbox("No barbarians", newGameParameters.noBarbarians)
|
||||
{ newGameParameters.noBarbarians = it }
|
||||
}
|
||||
|
||||
private fun addOneCityChallengeCheckbox() {
|
||||
private fun addOneCityChallengeCheckbox() =
|
||||
addCheckbox("One City Challenge", newGameParameters.oneCityChallenge)
|
||||
{ newGameParameters.oneCityChallenge = it }
|
||||
}
|
||||
|
||||
private fun addNuclearWeaponsCheckbox() =
|
||||
addCheckbox("Enable nuclear weapons", newGameParameters.nuclearWeaponsEnabled)
|
||||
{ newGameParameters.nuclearWeaponsEnabled = it }
|
||||
|
||||
|
||||
private fun addIsOnlineMultiplayerCheckbox() {
|
||||
|
||||
|
|
|
@ -122,13 +122,6 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen)
|
|||
update()
|
||||
}
|
||||
|
||||
|
||||
innerTable.add("Enable nuclear weapons".toLabel())
|
||||
addButton(innerTable, if (settings.nuclearWeaponEnabled) "Yes" else "No") {
|
||||
settings.nuclearWeaponEnabled = !settings.nuclearWeaponEnabled
|
||||
update()
|
||||
}
|
||||
|
||||
addAutosaveTurnsSelectBox(innerTable)
|
||||
|
||||
// at the moment the notification service only exists on Android
|
||||
|
|
Loading…
Reference in a new issue