diff --git a/android/assets/jsons/Civ V - Vanilla/Policies.json b/android/assets/jsons/Civ V - Vanilla/Policies.json index 6ebb85e42e..6c13a31e84 100644 --- a/android/assets/jsons/Civ V - Vanilla/Policies.json +++ b/android/assets/jsons/Civ V - Vanilla/Policies.json @@ -109,18 +109,21 @@ { "name": "Warrior Code", "effect": "+20% production when training melee units", + "uniques":["+20% production when training melee units"], "row": 1, "column": 2 }, { "name": "Discipline", "effect": "+15% combat strength for melee units which have another military unit in an adjacent tile", + "uniques":["+15% combat strength for melee units which have another military unit in an adjacent tile"], "row": 1, "column": 4 }, { "name": "Military Tradition", "effect": "Military units gain 50% more Experience from combat", + "uniques":["Military units gain 50% more Experience from combat"], "requires": ["Warrior Code"], "row": 2, "column": 2 @@ -128,6 +131,7 @@ { "name": "Military Caste", "effect": "Each city with a garrison increases happiness by 1 and culture by 2", + "uniques": ["[+1 Happiness, +2 Culture] in all cities with a garrison"] "requires": ["Discipline"], "row": 2, "column": 4 diff --git a/core/src/com/unciv/MainMenuScreen.kt b/core/src/com/unciv/MainMenuScreen.kt index 3a5f1772a1..72c1863767 100644 --- a/core/src/com/unciv/MainMenuScreen.kt +++ b/core/src/com/unciv/MainMenuScreen.kt @@ -96,7 +96,7 @@ class MainMenuScreen: CameraStageBaseScreen() { table.add(multiplayerTable).row() val mapEditorScreenTable = getTableBlock("Map editor", "OtherIcons/MapEditor") - { openMapEditorPopup() } + { if(stage.actors.none { it is MapEditorMainScreenPopup }) MapEditorMainScreenPopup(this) } table.add(mapEditorScreenTable).padBottom(0f) // set the same width for all buttons @@ -118,56 +118,57 @@ class MainMenuScreen: CameraStageBaseScreen() { /** Shows the [Popup] with the map editor initialization options */ - private fun openMapEditorPopup() { + class MapEditorMainScreenPopup(screen: MainMenuScreen):Popup(screen){ + init{ + defaults().pad(10f) - val mapEditorPopup = Popup(this) - mapEditorPopup.defaults().pad(10f) + val tableBackground = ImageGetter.getBackground(colorFromRGB(29, 102, 107)) - val tableBackground = ImageGetter.getBackground(colorFromRGB(29, 102, 107)) - - val newMapButton = getTableBlock("New map", "OtherIcons/New") { - game.setScreen(NewMapScreen()) - dispose() - } - newMapButton.background = tableBackground - mapEditorPopup.add(newMapButton).row() - - val loadMapButton = getTableBlock("Load map", "OtherIcons/Load") { - val loadMapScreen = LoadMapScreen(null) - loadMapScreen.closeButton.isVisible = true - loadMapScreen.closeButton.onClick { - game.setScreen(MainMenuScreen()) - loadMapScreen.dispose() + val newMapButton = screen.getTableBlock("New map", "OtherIcons/New") { + screen.game.setScreen(NewMapScreen()) + screen.dispose() } - game.setScreen(loadMapScreen) - dispose() - } + newMapButton.background = tableBackground + add(newMapButton).row() - loadMapButton.background = tableBackground - mapEditorPopup.add(loadMapButton).row() - - if (UncivGame.Current.settings.extendedMapEditor) { - val loadScenarioButton = getTableBlock("Load scenario", "OtherIcons/Scenario") { - val loadScenarioScreen = LoadScenarioScreen(null) - loadScenarioScreen.closeButton.isVisible = true - loadScenarioScreen.closeButton.onClick { - game.setScreen(MainMenuScreen()) - loadScenarioScreen.dispose() + val loadMapButton = screen.getTableBlock("Load map", "OtherIcons/Load") { + val loadMapScreen = LoadMapScreen(null) + loadMapScreen.closeButton.isVisible = true + loadMapScreen.closeButton.onClick { + screen.game.setScreen(MainMenuScreen()) + loadMapScreen.dispose() } - game.setScreen(loadScenarioScreen) - dispose() + screen.game.setScreen(loadMapScreen) + screen.dispose() } - loadScenarioButton.background = tableBackground - mapEditorPopup.add(loadScenarioButton).row() + loadMapButton.background = tableBackground + add(loadMapButton).row() + + if (UncivGame.Current.settings.extendedMapEditor) { + val loadScenarioButton = screen.getTableBlock("Load scenario", "OtherIcons/Scenario") { + val loadScenarioScreen = LoadScenarioScreen(null) + loadScenarioScreen.closeButton.isVisible = true + loadScenarioScreen.closeButton.onClick { + screen.game.setScreen(MainMenuScreen()) + loadScenarioScreen.dispose() + } + screen.game.setScreen(loadScenarioScreen) + screen.dispose() + } + + loadScenarioButton.background = tableBackground + add(loadScenarioButton).row() + } + + add(screen.getTableBlock("Close", "OtherIcons/Close") { close() } + .apply { background=tableBackground }) + + open(force = true) } - - mapEditorPopup.add(getTableBlock("Close", "OtherIcons/Close") { mapEditorPopup.close() } - .apply { background=tableBackground }) - - mapEditorPopup.open(force = true) } + private fun autoLoadGame() { try { game.loadGame(autosave) diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index daab05b4b6..38bdc5b5b7 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -236,7 +236,7 @@ object Battle { return var XPModifier = 1f - if (thisCombatant.getCivInfo().policies.isAdopted("Military Tradition")) XPModifier += 0.5f + if (thisCombatant.getCivInfo().hasUnique("Military units gain 50% more Experience from combat")) XPModifier += 0.5f if (thisCombatant.unit.hasUnique("50% Bonus XP gain")) XPModifier += 0.5f val XPGained = (amount * XPModifier).toInt() diff --git a/core/src/com/unciv/logic/battle/BattleDamage.kt b/core/src/com/unciv/logic/battle/BattleDamage.kt index 3e998da6b6..c2218f1235 100644 --- a/core/src/com/unciv/logic/battle/BattleDamage.kt +++ b/core/src/com/unciv/logic/battle/BattleDamage.kt @@ -71,7 +71,7 @@ object BattleDamage { modifiers["Populism"] = 0.25f } - if (civInfo.policies.hasEffect("+15% combat strength for melee units which have another military unit in an adjacent tile") + if (civInfo.hasUnique("+15% combat strength for melee units which have another military unit in an adjacent tile") && combatant.isMelee() && combatant.getTile().neighbors.flatMap { it.getUnits() } .any { it.civInfo == civInfo && !it.type.isCivilian() && !it.type.isAirUnit() }) diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index cb387d0147..9364fb0f38 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -14,6 +14,7 @@ import com.unciv.models.stats.Stat import com.unciv.models.stats.Stats import com.unciv.models.translations.equalsPlaceholderText import com.unciv.models.translations.getPlaceholderParameters +import com.unciv.models.translations.getPlaceholderText class CityStats { @@ -215,9 +216,11 @@ class CityStats { if (civInfo.hasUnique("+1 happiness for every city connected to capital") && cityInfo.isConnectedToCapital()) happinessFromPolicies += 1f - if (civInfo.policies.hasEffect("Each city with a garrison increases happiness by 1 and culture by 2" - ) && cityInfo.getCenterTile().militaryUnit != null) - happinessFromPolicies += 1 + + if (cityInfo.getCenterTile().militaryUnit != null) + for (unique in civInfo.policies.policyEffects) + if (unique.equalsPlaceholderText("[] in all cities with a garrison")) + happinessFromPolicies += Stats.parse(unique.getPlaceholderParameters()[0]).happiness newHappinessList["Policies"] = happinessFromPolicies @@ -230,7 +233,7 @@ class CityStats { newHappinessList["Wonders"] = 1f newHappinessList["Tile yields"] = getStatsFromTiles().happiness - + // we don't want to modify the existing happiness list because that leads // to concurrency problems if we iterate on it while changing happinessList = newHappinessList @@ -267,9 +270,10 @@ class CityStats { if (adoptedPolicies.hasEffect("+3 culture in capital") && cityInfo.isCapital()) stats.culture += 3f for(effect in adoptedPolicies.policyEffects) { - if (effect.equalsPlaceholderText("[] in capital") && cityInfo.isCapital()) - stats.add(Stats.parse(effect.getPlaceholderParameters()[0])) - else if(effect.equalsPlaceholderText("[] in all cities")) + val placeholderText = effect.getPlaceholderText() + if ((placeholderText == "[] in capital" && cityInfo.isCapital()) + || placeholderText == "[] in all cities" + || (placeholderText == "[] in all cities with a garrison" && cityInfo.getCenterTile().militaryUnit != null)) stats.add(Stats.parse(effect.getPlaceholderParameters()[0])) } if (adoptedPolicies.hasEffect("+1 gold and -1 unhappiness for every 2 citizens in capital") && cityInfo.isCapital()) @@ -278,8 +282,6 @@ class CityStats { stats.culture += 1f if (adoptedPolicies.hasEffect("+1 production in every city, +5% production when constructing buildings")) stats.production += 1f - if (adoptedPolicies.hasEffect("Each city with a garrison increases happiness by 1 and culture by 2") && cityInfo.getCenterTile().militaryUnit != null) - stats.culture += 2 if (adoptedPolicies.hasEffect("+1 production per 5 population")) stats.production += (cityInfo.population.population / 5).toFloat() if (adoptedPolicies.hasEffect("+1 culture for every 2 citizens")) @@ -337,7 +339,8 @@ class CityStats { stats.production += 50f if (policies.contains("Republic") && currentConstruction is Building) stats.production += 5f - if (policies.contains("Warrior Code") && currentConstruction is BaseUnit && currentConstruction.unitType.isMelee()) + if (cityInfo.civInfo.hasUnique("+20% production when training melee units") + && currentConstruction is BaseUnit && currentConstruction.unitType.isMelee()) stats.production += 20 if (policies.contains("Piety") && listOf("Monument", "Temple", "Opera House", "Museum", "Broadcast Tower").contains(currentConstruction.name))