From b0bf18afa01b6888fef27e9e6d34fdd1a9ea1879 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 5 Feb 2021 16:06:58 +0200 Subject: [PATCH] Added custom victory conditions --- .../jsons/Civ V - Vanilla/Policies.json | 5 +++-- .../jsons/translations/template.properties | 2 ++ .../logic/civilization/VictoryManager.kt | 20 ++++++++++--------- .../unciv/ui/victoryscreen/VictoryScreen.kt | 3 +++ 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Policies.json b/android/assets/jsons/Civ V - Vanilla/Policies.json index 665c47caed..73b096f4d8 100644 --- a/android/assets/jsons/Civ V - Vanilla/Policies.json +++ b/android/assets/jsons/Civ V - Vanilla/Policies.json @@ -89,7 +89,8 @@ { "name": "Honor", "era": "Ancient era", - "uniques": ["+25% bonus vs Barbarians", "Earn [100]% of [Barbarian] opponent's [Strength] as [Culture] for kills", "Notified of new Barbarian encampments"], + "uniques": ["+25% bonus vs Barbarians", "Earn [100]% of [Barbarian] opponent's [Strength] as [Culture] for kills", + "Notified of new Barbarian encampments"], "policies": [ { "name": "Warrior Code", @@ -112,7 +113,7 @@ }, { "name": "Military Caste", - "uniques": ["[+1 Happiness, +2 Culture] in all cities with a garrison"], + "uniques": ["[+1 Happiness, +2 Culture] [in all cities with a garrison]"], "requires": ["Discipline"], "row": 2, "column": 4 diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 97174a196c..56eb2549f6 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -694,9 +694,11 @@ Destroy all enemies\n to win! = You have won a scientific victory! = You have won a cultural victory! = You have won a domination victory! = +You have won! = You have achieved victory through the awesome power of your Culture. Your civilization's greatness - the magnificence of its monuments and the power of its artists - have astounded the world! Poets will honor you as long as beauty brings gladness to a weary heart. = The world has been convulsed by war. Many great and powerful civilizations have fallen, but you have survived - and emerged victorious! The world will long remember your glorious triumph! = You have achieved victory through mastery of Science! You have conquered the mysteries of nature and led your people on a voyage to a brave new world! Your triumph will be remembered as long as the stars burn in the night sky! = +Your civilization stands above all others! The exploits of your people shall be remembered until the end of civilizaton itself! = You have been defeated. Your civilization has been overwhelmed by its many foes. But your people do not despair, for they know that one day you shall return - and lead them forward to victory! = One more turn...! = Built Apollo Program = diff --git a/core/src/com/unciv/logic/civilization/VictoryManager.kt b/core/src/com/unciv/logic/civilization/VictoryManager.kt index 36aa01c0f1..c86b7e178e 100644 --- a/core/src/com/unciv/logic/civilization/VictoryManager.kt +++ b/core/src/com/unciv/logic/civilization/VictoryManager.kt @@ -4,7 +4,8 @@ import com.unciv.models.Counter import com.unciv.models.ruleset.VictoryType class VictoryManager { - @Transient lateinit var civInfo: CivilizationInfo + @Transient + lateinit var civInfo: CivilizationInfo var requiredSpaceshipParts = Counter() var currentsSpaceshipParts = Counter() @@ -32,10 +33,10 @@ class VictoryManager { private fun hasVictoryType(victoryType: VictoryType) = civInfo.gameInfo.gameParameters.victoryTypes.contains(victoryType) - fun hasWonScientificVictory() = hasVictoryType(VictoryType.Scientific) && spaceshipPartsRemaining()==0 + fun hasWonScientificVictory() = hasVictoryType(VictoryType.Scientific) && spaceshipPartsRemaining() == 0 fun hasWonCulturalVictory() = hasVictoryType(VictoryType.Cultural) - && civInfo.policies.adoptedPolicies.count{it.endsWith("Complete")} > 4 + && civInfo.policies.adoptedPolicies.count { it.endsWith("Complete") } > 4 fun hasWonDominationVictory(): Boolean { return (hasVictoryType(VictoryType.Domination) || hasVictoryType(VictoryType.Scenario)) && @@ -43,12 +44,13 @@ class VictoryManager { } fun hasWonVictoryType(): VictoryType? { - if(!civInfo.isMajorCiv()) return null - if(hasWonDominationVictory()) return VictoryType.Domination - if(hasWonScientificVictory()) return VictoryType.Scientific - if(hasWonCulturalVictory()) return VictoryType.Cultural + if (!civInfo.isMajorCiv()) return null + if (hasWonDominationVictory()) return VictoryType.Domination + if (hasWonScientificVictory()) return VictoryType.Scientific + if (hasWonCulturalVictory()) return VictoryType.Cultural + if (civInfo.hasUnique("Triggers victory")) return VictoryType.Neutral return null } - fun hasWon() = hasWonVictoryType()!=null -} + fun hasWon() = hasWonVictoryType() != null +} \ No newline at end of file diff --git a/core/src/com/unciv/ui/victoryscreen/VictoryScreen.kt b/core/src/com/unciv/ui/victoryscreen/VictoryScreen.kt index 739d6b24c7..4ca7a56028 100644 --- a/core/src/com/unciv/ui/victoryscreen/VictoryScreen.kt +++ b/core/src/com/unciv/ui/victoryscreen/VictoryScreen.kt @@ -58,6 +58,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() { VictoryType.Cultural -> wonOrLost("You have won a cultural victory!") VictoryType.Domination -> wonOrLost("You have won a domination victory!") // todo change translation VictoryType.Scientific -> wonOrLost("You have won a scientific victory!") + VictoryType.Neutral -> wonOrLost("You have won!") } } for (civ in game.gameInfo.civilizations.filter { it.isMajorCiv() && it != playerCivInfo }) { @@ -69,6 +70,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() { VictoryType.Cultural -> wonOrLost("[$winningCivName] has won a cultural victory!") VictoryType.Domination -> wonOrLost("[$winningCivName] has won a domination victory!") VictoryType.Scientific -> wonOrLost("[$winningCivName] has won a scientific victory!") + VictoryType.Neutral -> wonOrLost("[$winningCivName] has won!") } } } @@ -88,6 +90,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() { "You have won a cultural victory!" -> "You have achieved victory through the awesome power of your Culture. Your civilization's greatness - the magnificence of its monuments and the power of its artists - have astounded the world! Poets will honor you as long as beauty brings gladness to a weary heart." "You have won a domination victory!" -> "The world has been convulsed by war. Many great and powerful civilizations have fallen, but you have survived - and emerged victorious! The world will long remember your glorious triumph!" "You have won a scientific victory!" -> "You have achieved victory through mastery of Science! You have conquered the mysteries of nature and led your people on a voyage to a brave new world! Your triumph will be remembered as long as the stars burn in the night sky!" + "You have won!" -> "Your civilization stands above all others! The exploits of your people shall be remembered until the end of civilizaton itself!" else -> "You have been defeated. Your civilization has been overwhelmed by its many foes. But your people do not despair, for they know that one day you shall return - and lead them forward to victory!" }