From edfc66aa2fad30d604202a5b46a08fedcc331721 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Sun, 3 Oct 2021 18:03:54 +0200 Subject: [PATCH] Sort City States, replace+deprecate Dublin and Edinburgh (#5386) --- .../assets/jsons/Civ V - Vanilla/Nations.json | 533 +++++++++--------- core/src/com/unciv/logic/GameStarter.kt | 10 +- .../unciv/models/ruleset/unique/UniqueType.kt | 23 +- .../ui/newgamescreen/GameOptionsTable.kt | 32 +- core/src/com/unciv/ui/utils/UncivSlider.kt | 13 +- 5 files changed, 332 insertions(+), 279 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Nations.json b/android/assets/jsons/Civ V - Vanilla/Nations.json index 9b92661d3e..3a705bcd67 100644 --- a/android/assets/jsons/Civ V - Vanilla/Nations.json +++ b/android/assets/jsons/Civ V - Vanilla/Nations.json @@ -865,19 +865,18 @@ }, - - //City-States + // City-States sorted by cityStateType, name { - "name": "Milan", - "adjective": ["Milanese"], + "name": "Brussels", + "adjective": ["Bruxellois"], "cityStateType": "Cultured", "declaringWar": "You leave us no choice. War it must be.", "attacked": "Very well, this shall not be forgotten.", - "defeated": "You fiend! History shall remember this!", + "defeated": "I guess you weren't here for the sprouts after all...", "outerColor": [0, 0, 0], - "innerColor": [185,132,66], - "cities": ["Milan"] + "innerColor": [153,255,51], + "cities": ["Brussels"] }, { "name": "Florence", @@ -892,106 +891,16 @@ "cities": ["Florence"] }, { - "name": "Rio de Janeiro", - "adjective": ["Carioca"], - "cityStateType": "Maritime", - "startBias": ["Coast"], - - "declaringWar": "I have to do this, for the sake of progress if nothing else. You must be opposed!", - "attacked": "You can see how fruitless this will be for you... right?", - "defeated": "May God grant me these last wishes - peace and prosperity for Brazil.", - "outerColor": [0, 0, 0], - "innerColor": [211, 220, 103], - "cities": ["Rio de Janeiro"] - }, - { - "name": "Antwerp", - "adjective": ["Antwerp"], - "cityStateType": "Mercantile", - "startBias": ["Coast"], - - "declaringWar": "You leave us no choice. War it must be.", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "They will write songs of this.... pray that they shall be in your favor.", - "outerColor": [0, 0, 0], - "innerColor": [194,97,255], - "cities": ["Antwerp"] - }, - { - "name": "Dublin", - "adjective": ["Dubliner"], - "cityStateType": "Militaristic", - - "declaringWar": "War lingers in our hearts. Why carry on with a false peace?", - "attacked": "You gormless radger! You'll dine on your own teeth before you set foot in Ireland!", - "defeated": "A lonely wind blows through the highlands today. A dirge for Ireland. Can you hear it?", - "outerColor": [0, 0, 0], - "innerColor": [211,180,113], - "cities": ["Dublin"] - }, - { - "name": "Tyre", - "adjective": ["Tyrian"], - "cityStateType": "Mercantile", - "startBias": ["Coast"], - - "declaringWar": "You leave us no choice. War it must be.", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "We never fully trusted you from the start.", - "outerColor": [0, 0, 0], - "innerColor": [255,97,255], - "cities": ["Tyre"] - }, - { - "name": "Ur", - "adjective": ["Ur"], - "cityStateType": "Maritime", - "startBias": ["Coast"], - - "declaringWar": "I will enjoy hearing your last breath as you witness the destruction of your realm!", - "attacked": "Why do we fight? Because Inanna demands it. Now, witness the power of the Sumerians!", - "defeated": "What treachery has struck us? No, what evil?", - "outerColor": [0, 0, 0], - "innerColor": [255,69,0], - "cities": ["Ur"] - }, - { - "name": "Genoa", - "adjective": ["Genoese"], - "cityStateType": "Mercantile", - "startBias": ["Coast"], - - "declaringWar": "You leave us no choice. War it must be.", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "How barbaric. Those who live by the sword shall perish by the sword.", - "outerColor": [0, 0, 0], - "innerColor": [45,255,86], - "cities": ["Genoa"] - }, - { - "name": "Venice", - "adjective": ["Venetian"], - "cityStateType": "Maritime", - "startBias": ["Coast"], - - "declaringWar": "You have revealed your purposes a bit too early, my friend...", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "A wrong calculation, on my part.", - "outerColor": [0, 0, 0], - "innerColor": [153,204,255], - "cities": ["Venice"] - }, - { - "name": "Brussels", - "adjective": ["Bruxellois"], + "name": "Hanoi", + "adjective": ["Hanoi"], "cityStateType": "Cultured", "declaringWar": "You leave us no choice. War it must be.", "attacked": "Very well, this shall not be forgotten.", - "defeated": "I guess you weren't here for the sprouts after all...", + "defeated": "So this is how it feels to die...", "outerColor": [0, 0, 0], - "innerColor": [153,255,51], - "cities": ["Brussels"] + "innerColor": [0,0,255], + "cities": ["Hanoi"] }, { "name": "Kabul", @@ -1005,138 +914,6 @@ "innerColor": [153,0,76], "cities": ["Kabul"] }, - { - "name": "Sidon", - "adjective": ["Sidon"], - "cityStateType": "Militaristic", - - "declaringWar": "You leave us no choice. War it must be.", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "What a fine battle! Sidon is willing to serve you!", - "outerColor": [0, 0, 0], - "innerColor": [250,128,114], - "cities": ["Sidon"] - }, - { - "name": "Almaty", - "adjective": ["Almaty"], - "cityStateType": "Militaristic", - - "declaringWar": "You leave us no choice. War it must be.", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "How could we fall to the likes of you?!", - "outerColor": [0, 0, 0], - "innerColor": [152,0,241], - "cities": ["Almaty"] - }, - { - "name": "Edinburgh", - "adjective": ["Edinburghensian"], - "cityStateType": "Militaristic", - - "declaringWar": "You shall stain this land no longer with your vileness! To arms, my countrymen - we ride to war!", - "attacked": "Traitorous man! The Celtic peoples will not stand for such wanton abuse and slander - I shall have your head!", - "defeated": "Vile ruler, know that you 'won' this war in name only!", - "outerColor": [0, 0, 0], - "innerColor": [0,102,102], - "cities": ["Edinburgh"] - }, - { - "name": "Singapore", - "adjective": ["Singaporean"], - "cityStateType": "Mercantile", - - "declaringWar": "You leave us no choice. War it must be.", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "Perhaps, in another world, we could have been friends...", - "outerColor": [0, 0, 0], - "innerColor": [255,255,0], - "cities": ["Singapore"] - }, - { - "name": "Zanzibar", - "adjective": ["Zanzibar"], - "cityStateType": "Mercantile", - - "declaringWar": "You leave us no choice. War it must be.", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "May the Heavens forgive you for inflicting this humiliation to our people.", - "outerColor": [0, 0, 0], - "innerColor": [255,153,255], - "cities": ["Zanzibar"] - }, - { - "name": "Sydney", - "adjective": ["Sydney"], - "cityStateType": "Maritime", - - "declaringWar": "After thorough deliberation, Australia finds itself at a crossroads. Prepare yourself, for war is upon us.", - "attacked": "We will mobilize every means of resistance to stop this transgression against our nation!", - "defeated": "The principles for which we have fought will survive longer than any nation you could ever build.", - "outerColor": [0, 0, 0], - "innerColor": [255,204,204], - "cities": ["Sydney"] - }, - { - "name": "Cape Town", - "adjective": ["Cape Town"], - "cityStateType": "Maritime", - - "declaringWar": "You leave us no choice. War it must be.", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "I have failed. May you, at least, know compassion towards our people.", - "outerColor": [0, 0, 0], - "innerColor": [255,153,153], - "cities": ["Cape Town"] - }, - { - "name": "Kathmandu", - "adjective": ["Kathmandu"], - "cityStateType": "Mercantile", - - "declaringWar": "You leave us no choice. War it must be.", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "We... defeated? No... we had so much work to do!", - "outerColor": [0, 0, 0], - "innerColor": [151,125,0], - "cities": ["Kathmandu"] - }, - { - "name": "Hanoi", - "adjective": ["Hanoi"], - "cityStateType": "Cultured", - - "declaringWar": "You leave us no choice. War it must be.", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "So this is how it feels to die...", - "outerColor": [0, 0, 0], - "innerColor": [0,0,255], - "cities": ["Hanoi"] - }, - { - "name": "Quebec City", - "adjective": ["Québécois"], - "cityStateType": "Cultured", - - "declaringWar": "You leave us no choice. War it must be.", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "We were too weak to protect ourselves...", - "outerColor": [0, 0, 0], - "innerColor": [51,102,0], - "cities": ["Quebec City"] - }, - { - "name": "Helsinki", - "adjective": ["Helsinki"], - "cityStateType": "Maritime", - - "declaringWar": "You leave us no choice. War it must be.", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "The day of judgement has come to us. But rest assured, the same will go for you!", - "outerColor": [0, 0, 0], - "innerColor": [255,178,102], - "cities": ["Helsinki"] - }, { "name": "Kuala Lumpur", "adjective": ["KLite"], @@ -1149,18 +926,6 @@ "innerColor": [0,102,102], "cities": ["Kuala Lumpur"] }, - { - "name": "Manila", - "adjective": ["Manilan"], - "cityStateType": "Maritime", - - "declaringWar": "You leave us no choice. War it must be.", - "attacked": "Very well, this shall not be forgotten.", - "defeated": "Ah, Gods! Why have you forsaken us?", - "outerColor": [0, 0, 0], - "innerColor": [96,96,96], - "cities": ["Manila"] - }, { "name": "Lhasa", "translatedName": "Lhasa", @@ -1174,6 +939,117 @@ "innerColor": [204,102,0], "cities": ["Lhasa"] }, + { + "name": "Milan", + "adjective": ["Milanese"], + "cityStateType": "Cultured", + + "declaringWar": "You leave us no choice. War it must be.", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "You fiend! History shall remember this!", + "outerColor": [0, 0, 0], + "innerColor": [185,132,66], + "cities": ["Milan"] + }, + { + "name": "Quebec City", + "adjective": ["Québécois"], + "cityStateType": "Cultured", + + "declaringWar": "You leave us no choice. War it must be.", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "We were too weak to protect ourselves...", + "outerColor": [0, 0, 0], + "innerColor": [51,102,0], + "cities": ["Quebec City"] + }, + + { + "name": "Cape Town", + "adjective": ["Cape Town"], + "cityStateType": "Maritime", + + "declaringWar": "You leave us no choice. War it must be.", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "I have failed. May you, at least, know compassion towards our people.", + "outerColor": [0, 0, 0], + "innerColor": [255,153,153], + "cities": ["Cape Town"] + }, + { + "name": "Helsinki", + "adjective": ["Helsinki"], + "cityStateType": "Maritime", + + "declaringWar": "You leave us no choice. War it must be.", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "The day of judgement has come to us. But rest assured, the same will go for you!", + "outerColor": [0, 0, 0], + "innerColor": [255,178,102], + "cities": ["Helsinki"] + }, + { + "name": "Manila", + "adjective": ["Manilan"], + "cityStateType": "Maritime", + + "declaringWar": "You leave us no choice. War it must be.", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "Ah, Gods! Why have you forsaken us?", + "outerColor": [0, 0, 0], + "innerColor": [96,96,96], + "cities": ["Manila"] + }, + { + "name": "Mogadishu", + "adjective": ["Mogadishu"], + "cityStateType": "Maritime", + + "declaringWar": "You leave us no choice. War it must be.", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "Congratulations, conqueror. This tribe serves you now.", + "outerColor": [0, 0, 0], + "innerColor": [224,224,224], + "cities": ["Mogadishu"] + }, + { + "name": "Rio de Janeiro", + "adjective": ["Carioca"], + "cityStateType": "Maritime", + "startBias": ["Coast"], + + "declaringWar": "I have to do this, for the sake of progress if nothing else. You must be opposed!", + "attacked": "You can see how fruitless this will be for you... right?", + "defeated": "May God grant me these last wishes - peace and prosperity for Brazil.", + "outerColor": [0, 0, 0], + "innerColor": [211, 220, 103], + "cities": ["Rio de Janeiro"] + }, + { + "name": "Sydney", + "adjective": ["Sydney"], + "cityStateType": "Maritime", + + "declaringWar": "After thorough deliberation, Australia finds itself at a crossroads. Prepare yourself, for war is upon us.", + "attacked": "We will mobilize every means of resistance to stop this transgression against our nation!", + "defeated": "The principles for which we have fought will survive longer than any nation you could ever build.", + "outerColor": [0, 0, 0], + "innerColor": [255,204,204], + "cities": ["Sydney"] + }, + { + "name": "Ur", + "adjective": ["Ur"], + "cityStateType": "Maritime", + "startBias": ["Coast"], + + "declaringWar": "I will enjoy hearing your last breath as you witness the destruction of your realm!", + "attacked": "Why do we fight? Because Inanna demands it. Now, witness the power of the Sumerians!", + "defeated": "What treachery has struck us? No, what evil?", + "outerColor": [0, 0, 0], + "innerColor": [255,69,0], + "cities": ["Ur"] + }, { "name": "Vancouver", "translatedName": "Vancouver", @@ -1187,6 +1063,146 @@ "innerColor": [0,255,128], "cities": ["Vancouver"] }, + { + "name": "Venice", + "adjective": ["Venetian"], + "cityStateType": "Maritime", + "startBias": ["Coast"], + + "declaringWar": "You have revealed your purposes a bit too early, my friend...", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "A wrong calculation, on my part.", + "outerColor": [0, 0, 0], + "innerColor": [153,204,255], + "cities": ["Venice"] + }, + + { + "name": "Antwerp", + "adjective": ["Antwerp"], + "cityStateType": "Mercantile", + "startBias": ["Coast"], + + "declaringWar": "You leave us no choice. War it must be.", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "They will write songs of this.... pray that they shall be in your favor.", + "outerColor": [0, 0, 0], + "innerColor": [194,97,255], + "cities": ["Antwerp"] + }, + { + "name": "Genoa", + "adjective": ["Genoese"], + "cityStateType": "Mercantile", + "startBias": ["Coast"], + + "declaringWar": "You leave us no choice. War it must be.", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "How barbaric. Those who live by the sword shall perish by the sword.", + "outerColor": [0, 0, 0], + "innerColor": [45,255,86], + "cities": ["Genoa"] + }, + { + "name": "Kathmandu", + "adjective": ["Kathmandu"], + "cityStateType": "Mercantile", + + "declaringWar": "You leave us no choice. War it must be.", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "We... defeated? No... we had so much work to do!", + "outerColor": [0, 0, 0], + "innerColor": [151,125,0], + "cities": ["Kathmandu"] + }, + { + "name": "Singapore", + "adjective": ["Singaporean"], + "cityStateType": "Mercantile", + + "declaringWar": "You leave us no choice. War it must be.", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "Perhaps, in another world, we could have been friends...", + "outerColor": [0, 0, 0], + "innerColor": [255,255,0], + "cities": ["Singapore"] + }, + { + "name": "Tyre", + "adjective": ["Tyrian"], + "cityStateType": "Mercantile", + "startBias": ["Coast"], + + "declaringWar": "You leave us no choice. War it must be.", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "We never fully trusted you from the start.", + "outerColor": [0, 0, 0], + "innerColor": [255,97,255], + "cities": ["Tyre"] + }, + { + "name": "Zanzibar", + "adjective": ["Zanzibar"], + "cityStateType": "Mercantile", + + "declaringWar": "You leave us no choice. War it must be.", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "May the Heavens forgive you for inflicting this humiliation to our people.", + "outerColor": [0, 0, 0], + "innerColor": [255,153,255], + "cities": ["Zanzibar"] + }, + + { + "name": "Almaty", + "adjective": ["Almaty"], + "cityStateType": "Militaristic", + + "declaringWar": "You leave us no choice. War it must be.", + "attacked": "Very well, this shall not be forgotten.", + "defeated": "How could we fall to the likes of you?!", + "outerColor": [0, 0, 0], + "innerColor": [152,0,241], + "cities": ["Almaty"] + }, + { + "name": "Belgrade", + "adjective": ["Belgrade"], + "cityStateType": "Militaristic", + + "declaringWar": "Let's have a nice little War, shall we?", + "attacked": "If you need your nose bloodied, we'll happily serve.", + "defeated": "The serbian guerilla will never stop haunting you!", + "outerColor": [0, 0, 0], + "innerColor": [211,180,113], + "cities": ["Belgrade"] + }, + { + "name": "Dublin", + "adjective": ["Dubliner"], + "cityStateType": "Militaristic", + + "declaringWar": "War lingers in our hearts. Why carry on with a false peace?", + "attacked": "You gormless radger! You'll dine on your own teeth before you set foot in Ireland!", + "defeated": "A lonely wind blows through the highlands today. A dirge for Ireland. Can you hear it?", + "outerColor": [0, 0, 0], + "innerColor": [211,180,113], + "cities": ["Dublin"], + "uniques": ["Will not be displayed in Civilopedia", "Will not be chosen for new games"] + }, + { + "name": "Edinburgh", + "adjective": ["Edinburghensian"], + "cityStateType": "Militaristic", + + "declaringWar": "You shall stain this land no longer with your vileness! To arms, my countrymen - we ride to war!", + "attacked": "Traitorous man! The Celtic peoples will not stand for such wanton abuse and slander - I shall have your head!", + "defeated": "Vile ruler, know that you 'won' this war in name only!", + "outerColor": [0, 0, 0], + "innerColor": [0,102,102], + "cities": ["Edinburgh"], + "uniques": ["Will not be displayed in Civilopedia", "Will not be chosen for new games"] + }, { "name": "M'Banza-Kongo", "adjective": ["M'Banza-Kongo"], @@ -1200,17 +1216,30 @@ "cities": ["M'Banza-Kongo"] }, { - "name": "Mogadishu", - "adjective": ["Mogadishu"], - "cityStateType": "Maritime", + "name": "Sidon", + "adjective": ["Sidon"], + "cityStateType": "Militaristic", "declaringWar": "You leave us no choice. War it must be.", "attacked": "Very well, this shall not be forgotten.", - "defeated": "Congratulations, conqueror. This tribe serves you now.", + "defeated": "What a fine battle! Sidon is willing to serve you!", "outerColor": [0, 0, 0], - "innerColor": [224,224,224], - "cities": ["Mogadishu"] + "innerColor": [250,128,114], + "cities": ["Sidon"] }, + { + "name": "Valletta", + "adjective": ["maltese"], + "cityStateType": "Militaristic", + + "declaringWar": "We don't like your face. To arms!", + "attacked": "You will see you have just bitten off more than you can chew.", + "defeated": "This ship may sink, but our spirits will linger.", + "outerColor": [0, 0, 0], + "innerColor": [0,102,102], + "cities": ["Valletta"] + }, + { "name": "Bratislava", "adjective": ["Bratislava"], diff --git a/core/src/com/unciv/logic/GameStarter.kt b/core/src/com/unciv/logic/GameStarter.kt index 57b4932bde..5cdf62b2f2 100644 --- a/core/src/com/unciv/logic/GameStarter.kt +++ b/core/src/com/unciv/logic/GameStarter.kt @@ -12,6 +12,7 @@ import com.unciv.models.ruleset.ModOptionsConstants import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.RulesetCache import com.unciv.models.ruleset.tile.ResourceType +import com.unciv.models.ruleset.unique.UniqueType import java.util.* import kotlin.collections.HashMap import kotlin.collections.HashSet @@ -200,8 +201,11 @@ object GameStarter { // since we shuffle and then order by, we end up with all the City-States with starting tiles first in a random order, // and then all the other City-States in a random order! Because the sortedBy function is stable! availableCityStatesNames.addAll( ruleset.nations - .filter { it.value.isCityState() && (it.value.cityStateType != CityStateType.Religious || newGameParameters.religionEnabled) } - .keys + .filter { + it.value.isCityState() && + (it.value.cityStateType != CityStateType.Religious || newGameParameters.religionEnabled) && + !it.value.hasUnique(UniqueType.CityStateDeprecated) + }.keys .shuffled() .sortedByDescending { it in civNamesWithStartingLocations } ) @@ -213,7 +217,7 @@ object GameStarter { val unusedMercantileResources = Stack() unusedMercantileResources.addAll(allMercantileResources.shuffled()) - + var addedCityStates = 0 // Keep trying to add city states until we reach the target number. while (addedCityStates < newGameParameters.numberOfCityStates) { diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 33e78629d7..9d1a689b6c 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -58,9 +58,9 @@ enum class UniqueTarget(val inheritsFrom:UniqueTarget?=null) { enum class UniqueType(val text:String, vararg targets: UniqueTarget) { //////////////////////////////////////// GLOBAL UNIQUES //////////////////////////////////////// - + /////// Stat providing uniques - + Stats("[stats]", UniqueTarget.Global), StatsPerCity("[stats] [cityFilter]", UniqueTarget.Global), @Deprecated("As of 3.16.16", ReplaceWith("[stats] "), DeprecationLevel.WARNING) @@ -68,7 +68,7 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) { StatPercentBonus("[amount]% [Stat]", UniqueTarget.Global), BonusStatsFromCityStates("[amount]% [stat] from City-States", UniqueTarget.Global), - + RemoveAnnexUnhappiness("Remove extra unhappiness from annexed cities", UniqueTarget.Building), /////// City-State related uniques @@ -86,16 +86,17 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) { CityStateCanBeBoughtForGold("Can spend Gold to annex or puppet a City-State that has been your ally for [amount] turns.", UniqueTarget.Global), CityStateTerritoryAlwaysFriendly("City-State territory always counts as friendly territory", UniqueTarget.Global), - + CityStateDeprecated("Will not be chosen for new games", UniqueTarget.Nation), // implemented for CS only for now + /////// Other global uniques - + FreeUnits("[amount] units cost no maintenance", UniqueTarget.Global), UnitMaintenanceDiscount("[amount]% maintenance costs for [mapUnitFilter] units", UniqueTarget.Global), @Deprecated("As of 3.16.16", ReplaceWith("[amount]% maintenance costs for [mapUnitFilter] units"), DeprecationLevel.WARNING) DecreasedUnitMaintenanceCostsByFilter("-[amount]% [mapUnitFilter] unit maintenance costs", UniqueTarget.Global), @Deprecated("As of 3.16.16", ReplaceWith("[amount]% maintenance costs for [mapUnitFilter] units"), DeprecationLevel.WARNING) DecreasedUnitMaintenanceCostsGlobally("-[amount]% unit upkeep costs", UniqueTarget.Global), - + ConsumesResources("Consumes [amount] [resource]", UniqueTarget.Improvement, UniqueTarget.Building, UniqueTarget.Unit), ProvidesResources("Provides [amount] [resource]", @@ -115,7 +116,7 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) { FreeExtraAnyBeliefs("May choose [amount] additional of any type when [foundingOrEnhancing] a religion", UniqueTarget.Global), ///////////////////////////////////////// UNIT UNIQUES ///////////////////////////////////////// - + Strength("[amount]% Strength", UniqueTarget.Unit, UniqueTarget.Global), @Deprecated("As of 3.17.3", ReplaceWith("[amount]% Strength"), DeprecationLevel.WARNING) @@ -147,7 +148,7 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) { CannotEnterOceanUntilAstronomy("Cannot enter ocean tiles until Astronomy", UniqueTarget.Unit), //////////////////////////////////////// TERRAIN UNIQUES //////////////////////////////////////// - + NaturalWonderNeighborCount("Must be adjacent to [amount] [simpleTerrain] tiles", UniqueTarget.Terrain), NaturalWonderNeighborsRange("Must be adjacent to [amount] to [amount] [simpleTerrain] tiles", UniqueTarget.Terrain), NaturalWonderSmallerLandmass("Must not be on [amount] largest landmasses", UniqueTarget.Terrain), @@ -155,15 +156,15 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) { NaturalWonderLatitude("Occurs on latitudes from [amount] to [amount] percent of distance equator to pole", UniqueTarget.Terrain), NaturalWonderGroups("Occurs in groups of [amount] to [amount] tiles", UniqueTarget.Terrain), NaturalWonderConvertNeighbors("Neighboring tiles will convert to [baseTerrain]", UniqueTarget.Terrain), - + // The "Except [terrainFilter]" could theoretically be implemented with a conditional NaturalWonderConvertNeighborsExcept("Neighboring tiles except [baseTerrain] will convert to [baseTerrain]", UniqueTarget.Terrain), TerrainGrantsPromotion("Grants [promotion] ([comment]) to adjacent [mapUnitFilter] units for the rest of the game", UniqueTarget.Terrain), - + TileProvidesYieldWithoutPopulation("Tile provides yield without assigned population", UniqueTarget.Terrain, UniqueTarget.Improvement), NullifyYields("Nullifies all other stats this tile provides", UniqueTarget.Terrain), - + NoNaturalGeneration("Doesn't generate naturally", UniqueTarget.Terrain), ///////////////////////////////////////// CONDITIONALS ///////////////////////////////////////// diff --git a/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt b/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt index 90cbb1f7bf..90c0838163 100644 --- a/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt +++ b/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt @@ -2,10 +2,12 @@ package com.unciv.ui.newgamescreen import com.badlogic.gdx.scenes.scene2d.ui.Table import com.unciv.UncivGame +import com.unciv.logic.civilization.CityStateType import com.unciv.models.metadata.BaseRuleset import com.unciv.models.metadata.GameSpeed import com.unciv.models.ruleset.RulesetCache import com.unciv.models.ruleset.VictoryType +import com.unciv.models.ruleset.unique.UniqueType import com.unciv.ui.audio.MusicMood import com.unciv.ui.audio.MusicTrackChooserFlags import com.unciv.ui.utils.* @@ -29,6 +31,7 @@ class GameOptionsTable( } private fun getGameOptionsTable() { + val cityStateSlider: UncivSlider? top() defaults().pad(5f) @@ -40,7 +43,7 @@ class GameOptionsTable( addEraSelectBox() // align left and right edges with other SelectBoxes but allow independent dropdown width add(Table().apply { - addCityStatesSlider() + cityStateSlider = addCityStatesSlider() }).colspan(2).fillX().row() }).row() addVictoryTypeCheckboxes() @@ -51,7 +54,7 @@ class GameOptionsTable( checkboxTable.addOneCityChallengeCheckbox() checkboxTable.addNuclearWeaponsCheckbox() checkboxTable.addIsOnlineMultiplayerCheckbox() - checkboxTable.addReligionCheckbox() + checkboxTable.addReligionCheckbox(cityStateSlider) add(checkboxTable).center().row() if (!withoutMods) @@ -89,23 +92,32 @@ class GameOptionsTable( gameParameters.isOnlineMultiplayer = it updatePlayerPickerTable("") } - - private fun Table.addReligionCheckbox() = - addCheckbox("Enable Religion", gameParameters.religionEnabled) - { gameParameters.religionEnabled = it } - private fun Table.addCityStatesSlider() { - val numberOfCityStates = ruleset.nations.filter { it.value.isCityState() }.size - if (numberOfCityStates == 0) return + private fun numberOfCityStates() = ruleset.nations.values.count { + it.isCityState() && + (it.cityStateType != CityStateType.Religious || gameParameters.religionEnabled) && + !it.hasUnique(UniqueType.CityStateDeprecated) + } + + private fun Table.addReligionCheckbox(cityStateSlider: UncivSlider?) = + addCheckbox("Enable Religion", gameParameters.religionEnabled) { + gameParameters.religionEnabled = it + cityStateSlider?.run { setRange(0f, numberOfCityStates().toFloat()) } + } + + private fun Table.addCityStatesSlider(): UncivSlider? { + val maxCityStates = numberOfCityStates() + if (maxCityStates == 0) return null add("{Number of City-States}:".toLabel()).left().expandX() - val slider = UncivSlider(0f,numberOfCityStates.toFloat(),1f) { + val slider = UncivSlider(0f, maxCityStates.toFloat(), 1f) { gameParameters.numberOfCityStates = it.toInt() } slider.permanentTip = true slider.isDisabled = locked add(slider).padTop(10f).row() slider.value = gameParameters.numberOfCityStates.toFloat() + return slider } private fun Table.addSelectBox(text: String, values: Collection, initialState: String, onChange: (newValue: String) -> Unit) { diff --git a/core/src/com/unciv/ui/utils/UncivSlider.kt b/core/src/com/unciv/ui/utils/UncivSlider.kt index 33bc36e6b3..79a55b209b 100644 --- a/core/src/com/unciv/ui/utils/UncivSlider.kt +++ b/core/src/com/unciv/ui/utils/UncivSlider.kt @@ -78,6 +78,10 @@ class UncivSlider ( var isDisabled: Boolean get() = slider.isDisabled set(value) { slider.isDisabled = value } + fun setRange(min: Float, max: Float) { + slider.setRange(min, max) + setPlusMinusEnabled() + } // Value tip format var tipFormat = "%.1f" @@ -125,7 +129,7 @@ class UncivSlider ( if (vertical) padTop(padding) else padRight(padding) } } else plusButton = null - + row() value = initial // set initial value late so the tooltip can work with the layout @@ -157,7 +161,10 @@ class UncivSlider ( tipHideTask.cancel() if (!permanentTip) Timer.schedule(tipHideTask, hideDelay) + setPlusMinusEnabled() + } + private fun setPlusMinusEnabled() { val enableMinus = slider.value > slider.minValue minusButton?.touchable = if(enableMinus) Touchable.enabled else Touchable.disabled minusButton?.apply {circle.color.a = if(enableMinus) 1f else 0.5f} @@ -165,7 +172,7 @@ class UncivSlider ( plusButton?.touchable = if(enablePlus) Touchable.enabled else Touchable.disabled plusButton?.apply {circle.color.a = if(enablePlus) 1f else 0.5f} } - + private fun stepChanged() { tipFormat = when { stepSize > 0.99f -> "%.0f" @@ -208,7 +215,7 @@ class UncivSlider ( killedCaptureListeners.remove(widget) } } - + // Helpers to manage the light-weight "tooltip" showing the value private fun showTip() { if (tipContainer.hasParent()) return