From b58b73a790f189cc23d72bc89dd2a9c46d608d91 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Thu, 11 Jul 2024 16:34:03 +0300 Subject: [PATCH] Added "Can only start games from the starting era" conditional, "if [buildingFilter] is not constructed" unique --- .../com/unciv/logic/civilization/diplomacy/DeclareWar.kt | 1 - core/src/com/unciv/models/ruleset/unique/Conditionals.kt | 2 ++ core/src/com/unciv/models/ruleset/unique/UniqueType.kt | 4 +++- .../unciv/ui/screens/newgamescreen/GameOptionsTable.kt | 4 ++++ docs/Modders/uniques.md | 8 ++++++++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DeclareWar.kt b/core/src/com/unciv/logic/civilization/diplomacy/DeclareWar.kt index ac8ec7f0fa..7923636e96 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DeclareWar.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DeclareWar.kt @@ -26,7 +26,6 @@ object DeclareWar { internal fun declareWar(diplomacyManager: DiplomacyManager, declareWarReason: DeclareWarReason) { val civInfo = diplomacyManager.civInfo val otherCiv = diplomacyManager.otherCiv() - if (otherCiv.isDefeated()) throw Exception("Tried to declare war on a defeated civ!") val otherCivDiplomacy = diplomacyManager.otherCivDiplomacy() if (otherCiv.isCityState && declareWarReason.warType == WarType.DirectWar) diff --git a/core/src/com/unciv/models/ruleset/unique/Conditionals.kt b/core/src/com/unciv/models/ruleset/unique/Conditionals.kt index 95c6d08e16..e890e52736 100644 --- a/core/src/com/unciv/models/ruleset/unique/Conditionals.kt +++ b/core/src/com/unciv/models/ruleset/unique/Conditionals.kt @@ -171,6 +171,8 @@ object Conditionals { UniqueType.ConditionalBuildingBuilt -> checkOnCiv { cities.any { it.cityConstructions.containsBuildingOrEquivalent(conditional.params[0]) } } + UniqueType.ConditionalBuildingNotBuilt -> + checkOnCiv { cities.none { it.cityConstructions.containsBuildingOrEquivalent(conditional.params[0]) } } UniqueType.ConditionalBuildingBuiltAll -> checkOnCiv { cities.filter { it.matchesFilter(conditional.params[1]) }.all { it.cityConstructions.containsBuildingOrEquivalent(conditional.params[0]) } } diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index cdbcdb4cd5..3ad5828e0f 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -706,6 +706,7 @@ enum class UniqueType( ConditionalAfterGeneratingGreatProphet("after generating a Great Prophet", UniqueTarget.Conditional), ConditionalBuildingBuilt("if [buildingFilter] is constructed", UniqueTarget.Conditional), + ConditionalBuildingNotBuilt("if [buildingFilter] is not constructed", UniqueTarget.Conditional), ConditionalBuildingBuiltAll("if [buildingFilter] is constructed in all [cityFilter] cities", UniqueTarget.Conditional), ConditionalBuildingBuiltAmount("if [buildingFilter] is constructed in at least [positiveAmount] of [cityFilter] cities", UniqueTarget.Conditional), ConditionalBuildingBuiltByAnybody("if [buildingFilter] is constructed by anybody", UniqueTarget.Conditional), @@ -911,6 +912,7 @@ enum class UniqueType( AllowCityStatesSpawnUnits("Allow City States to spawn with additional units", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals), TradeCivIntroductions("Can trade civilization introductions for [positiveAmount] Gold", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals), DisableReligion("Disable religion", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals), + CanOnlyStartFromStartingEra("Can only start games from the starting era", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals), AllowRazeCapital("Allow raze capital", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals), AllowRazeHolyCity("Allow raze holy city", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals), @@ -1385,6 +1387,6 @@ enum class UniqueType( targetTypes.any { uniqueTarget.canAcceptUniqueTarget(it) } companion object { - val uniqueTypeMap: Map = UniqueType.values().associateBy { it.placeholderText } + val uniqueTypeMap: Map = entries.associateBy { it.placeholderText } } } diff --git a/core/src/com/unciv/ui/screens/newgamescreen/GameOptionsTable.kt b/core/src/com/unciv/ui/screens/newgamescreen/GameOptionsTable.kt index e1543a8670..17c1b8a66f 100644 --- a/core/src/com/unciv/ui/screens/newgamescreen/GameOptionsTable.kt +++ b/core/src/com/unciv/ui/screens/newgamescreen/GameOptionsTable.kt @@ -408,6 +408,10 @@ class GameOptionsTable( private fun Table.addEraSelectBox() { if (ruleset.eras.isEmpty()) return // mod with no techs + if (ruleset.modOptions.hasUnique(UniqueType.CanOnlyStartFromStartingEra)){ + gameParameters.startingEra = ruleset.eras.keys.first() + return + } val eras = ruleset.eras.keys addSelectBox("{Starting Era}:", eras, gameParameters.startingEra) { gameParameters.startingEra = it; null } diff --git a/docs/Modders/uniques.md b/docs/Modders/uniques.md index f2944692d8..e0a409ac50 100644 --- a/docs/Modders/uniques.md +++ b/docs/Modders/uniques.md @@ -2622,6 +2622,9 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl ??? example "Disable religion" Applicable to: ModOptions +??? example "Can only start games from the default era" + Applicable to: ModOptions + ??? example "Allow raze capital" Applicable to: ModOptions @@ -2842,6 +2845,11 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl Applicable to: Conditional +??? example "<if [buildingFilter] is not constructed>" + Example: "<if [Culture] is not constructed>" + + Applicable to: Conditional + ??? example "<if [buildingFilter] is constructed in all [cityFilter] cities>" Example: "<if [Culture] is constructed in all [in all cities] cities>"