Skip to content

Commit

Permalink
Modding: Replaced "Hidden when [victoryType] Victory is disabled" wit…
Browse files Browse the repository at this point in the history
…h "Only available <when [victoryType] Victory is enabled>"
  • Loading branch information
yairm210 committed Oct 20, 2024
1 parent 46644bc commit 579ea79
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 49 deletions.
8 changes: 4 additions & 4 deletions android/assets/jsons/Civ V - Gods & Kings/Buildings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1110,8 +1110,8 @@
"name": "Apollo Program",
"cost": 750,
"isNationalWonder": true,
"uniques": ["Enables construction of Spaceship parts", "Triggers a global alert upon completion",
"Hidden when [Scientific] Victory is disabled", "Cannot be hurried"],
"uniques": ["Enables construction of Spaceship parts", "Triggers a global alert upon completion",
"Only available <when [Scientific] Victory is enabled>", "Cannot be hurried"],
"requiredTech": "Rocketry"
},
{
Expand Down Expand Up @@ -1167,7 +1167,7 @@
"culture": 1,
"greatPersonPoints": {"Great Merchant": 2},
"requiredTech": "Globalization",
"uniques": ["Triggers voting for the Diplomatic Victory", "Hidden when [Diplomatic] Victory is disabled", "Triggers a global alert upon completion"],
"uniques": ["Triggers voting for the Diplomatic Victory", "Only available <when [Diplomatic] Victory is enabled>", "Triggers a global alert upon completion"],
"quote": "'More than ever before in human history, we share a common destiny. We can master it only if we face it together. And that is why we have the United Nations.' - Kofi Annan"
},

Expand All @@ -1178,7 +1178,7 @@
"cost": 1500,
"isNationalWonder": true,
"uniques": ["Hidden until [5] social policy branches have been completed", "Triggers a global alert upon build start",
"Triggers a Cultural Victory upon completion", "Hidden when [Cultural] Victory is disabled", "Cannot be hurried"]
"Triggers a Cultural Victory upon completion", "Only available <when [Cultural] Victory is enabled>", "Cannot be hurried"]
},

// Religious buildings
Expand Down
6 changes: 3 additions & 3 deletions android/assets/jsons/Civ V - Vanilla/Buildings.json
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@
"cost": 750,
"isNationalWonder": true,
"uniques": ["Enables construction of Spaceship parts", "Triggers a global alert upon completion",
"Hidden when [Scientific] Victory is disabled", "Cannot be hurried"],
"Only available <when [Scientific] Victory is enabled>", "Cannot be hurried"],
"requiredTech": "Rocketry"
},

Expand All @@ -956,7 +956,7 @@
"culture": 1,
"greatPersonPoints": {"Great Merchant": 2},
"requiredTech": "Globalization",
"uniques": ["Triggers voting for the Diplomatic Victory", "Hidden when [Diplomatic] Victory is disabled", "Triggers a global alert upon completion"],
"uniques": ["Triggers voting for the Diplomatic Victory", "Only available <when [Diplomatic] Victory is enabled>", "Triggers a global alert upon completion"],
"quote": "'More than ever before in human history, we share a common destiny. We can master it only if we face it together. And that is why we have the United Nations.' - Kofi Annan"
},

Expand All @@ -967,7 +967,7 @@
"cost": 1500,
"isNationalWonder": true,
"uniques": ["Hidden until [5] social policy branches have been completed", "Triggers a global alert upon build start",
"Triggers a Cultural Victory upon completion", "Hidden when [Cultural] Victory is disabled", "Cannot be hurried"]
"Triggers a Cultural Victory upon completion", "Only available <when [Cultural] Victory is enabled>", "Cannot be hurried"]
}

]
10 changes: 5 additions & 5 deletions core/src/com/unciv/models/ruleset/unique/Conditionals.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object Conditionals {
/** Helper to simplify conditional tests requiring gameInfo */
fun checkOnGameInfo(predicate: (GameInfo.() -> Boolean)): Boolean {
if (state.gameInfo == null) return false
return state.gameInfo!!.predicate()
return state.gameInfo.predicate()
}

/** Helper to simplify conditional tests requiring a Civilization */
Expand All @@ -49,7 +49,7 @@ object Conditionals {
/** Helper to simplify the "compare civ's current era with named era" conditions */
fun compareEra(eraParam: String, compare: (civEra: Int, paramEra: Int) -> Boolean): Boolean {
if (state.gameInfo == null) return false
val era = state.gameInfo!!.ruleset.eras[eraParam] ?: return false
val era = state.gameInfo.ruleset.eras[eraParam] ?: return false
return compare(state.relevantCiv!!.getEraNumber(), era.eraNumber)
}

Expand All @@ -62,15 +62,15 @@ object Conditionals {
compare: (current: Int, lowerLimit: Float, upperLimit: Float) -> Boolean
): Boolean {
if (state.gameInfo == null) return false
var gameSpeedModifier = if (modifyByGameSpeed) state.gameInfo!!.speed.modifier else 1f
var gameSpeedModifier = if (modifyByGameSpeed) state.gameInfo.speed.modifier else 1f

if (state.gameInfo!!.ruleset.tileResources.containsKey(resourceOrStatName))
if (state.gameInfo.ruleset.tileResources.containsKey(resourceOrStatName))
return compare(state.getResourceAmount(resourceOrStatName), lowerLimit * gameSpeedModifier, upperLimit * gameSpeedModifier)
val stat = Stat.safeValueOf(resourceOrStatName)
?: return false
val statReserve = state.getStatAmount(stat)

gameSpeedModifier = if (modifyByGameSpeed) state.gameInfo!!.speed.statCostModifiers[stat]!! else 1f
gameSpeedModifier = if (modifyByGameSpeed) state.gameInfo.speed.statCostModifiers[stat]!! else 1f
return compare(statReserve, lowerLimit * gameSpeedModifier, upperLimit * gameSpeedModifier)
}

Expand Down
26 changes: 25 additions & 1 deletion core/src/com/unciv/models/ruleset/unique/IHasUniques.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,33 @@ interface IHasUniques : INamed {
* - Overrides need to deal with e.g. Era-specific wonder disabling, no-nukes, ruin rewards by difficulty, and so on!
*/
fun isUnavailableBySettings(gameInfo: GameInfo): Boolean {
val gameBasedConditionals = setOf(
UniqueType.ConditionalVictoryDisabled,
UniqueType.ConditionalVictoryEnabled,
UniqueType.ConditionalSpeed,
)
val stateForConditionals = StateForConditionals(gameInfo = gameInfo)

if (getMatchingUniques(UniqueType.Unavailable, StateForConditionals.IgnoreConditionals)
.any { unique ->
unique.modifiers.any {
it.type in gameBasedConditionals
&& Conditionals.conditionalApplies(null, it, stateForConditionals) } })
return true

if (getMatchingUniques(UniqueType.OnlyAvailable, StateForConditionals.IgnoreConditionals)
.any { unique ->
unique.modifiers.any {
it.type in gameBasedConditionals
&& !Conditionals.conditionalApplies(null, it, stateForConditionals) } })
return true

if (!gameInfo.isReligionEnabled() && hasUnique(UniqueType.HiddenWithoutReligion)) return true
if (!gameInfo.isEspionageEnabled() && hasUnique(UniqueType.HiddenWithoutEspionage)) return true
if (getMatchingUniques(UniqueType.HiddenWithoutVictoryType).any { it.params[0] !in gameInfo.gameParameters.victoryTypes }) return true


if (getMatchingUniques(UniqueType.HiddenWithoutVictoryType)
.any { it.params[0] !in gameInfo.gameParameters.victoryTypes }) return true
return false
}

Expand Down
15 changes: 9 additions & 6 deletions core/src/com/unciv/models/ruleset/unique/UniqueType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -654,11 +654,17 @@ enum class UniqueType(
///////////////////////////////////////// region 08 CONDITIONALS /////////////////////////////////////////


/////// general conditionals
ConditionalChance("with [amount]% chance", UniqueTarget.Conditional),
/////// game conditionals
ConditionalEveryTurns("every [positiveAmount] turns", UniqueTarget.Conditional),
ConditionalBeforeTurns("before turn number [amount]", UniqueTarget.Conditional),
ConditionalAfterTurns("after turn number [amount]", UniqueTarget.Conditional),
ConditionalSpeed("on [speed] game speed", UniqueTarget.Conditional),
ConditionalVictoryEnabled("when [victoryType] Victory is enabled", UniqueTarget.Conditional),
ConditionalVictoryDisabled("when [victoryType] Victory is disabled", UniqueTarget.Conditional),


/////// general conditionals
ConditionalChance("with [amount]% chance", UniqueTarget.Conditional),
ConditionalTutorialsEnabled("if tutorials are enabled", UniqueTarget.Conditional, flags = UniqueFlag.setOfHiddenToUsers), // Hidden as no translations needed for now
ConditionalTutorialCompleted("if tutorial [comment] is completed", UniqueTarget.Conditional, flags = UniqueFlag.setOfHiddenToUsers), // Hidden as no translations needed for now

Expand All @@ -681,10 +687,6 @@ enum class UniqueType(
ConditionalStartingFromEra("starting from the [era]", UniqueTarget.Conditional),
ConditionalIfStartingInEra("if starting in the [era]", UniqueTarget.Conditional),

ConditionalSpeed("on [speed] game speed", UniqueTarget.Conditional),
ConditionalVictoryEnabled("when [victoryType] Victory is enabled", UniqueTarget.Conditional),
ConditionalVictoryDisabled("when [victoryType] Victory is disabled", UniqueTarget.Conditional),

ConditionalFirstCivToResearch("if no other Civilization has researched this", UniqueTarget.Conditional),
ConditionalTech("after discovering [tech]", UniqueTarget.Conditional),
ConditionalNoTech("before discovering [tech]", UniqueTarget.Conditional),
Expand Down Expand Up @@ -944,6 +946,7 @@ enum class UniqueType(
AiChoiceWeight("[relativeAmount]% weight to this choice for AI decisions", UniqueTarget.Tech,
UniqueTarget.Promotion, UniqueTarget.Policy, flags = UniqueFlag.setOfHiddenToUsers),

@Deprecated("As of 4.13.18", ReplaceWith("Only available <when [victoryType] Victory is enabled>"))
HiddenWithoutVictoryType("Hidden when [victoryType] Victory is disabled", UniqueTarget.Building, UniqueTarget.Unit, flags = UniqueFlag.setOfHiddenToUsers),
HiddenFromCivilopedia("Will not be displayed in Civilopedia", *UniqueTarget.Displayable, flags = UniqueFlag.setOfHiddenToUsers),
ModifierHiddenFromUsers("hidden from users", UniqueTarget.MetaModifier),
Expand Down
50 changes: 20 additions & 30 deletions docs/Modders/uniques.md
Original file line number Diff line number Diff line change
Expand Up @@ -1556,11 +1556,6 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
??? example "Hidden when espionage is disabled"
Applicable to: Building

??? example "Hidden when [victoryType] Victory is disabled"
Example: "Hidden when [Domination] Victory is disabled"

Applicable to: Building, Unit

??? example "Will not be displayed in Civilopedia"
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

Expand Down Expand Up @@ -2127,11 +2122,6 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
??? example "Hidden when religion is disabled"
Applicable to: Building, Unit, Ruins, Tutorial

??? example "Hidden when [victoryType] Victory is disabled"
Example: "Hidden when [Domination] Victory is disabled"

Applicable to: Building, Unit

??? example "Will not be displayed in Civilopedia"
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

Expand Down Expand Up @@ -2758,11 +2748,6 @@ If your mod renames Coast or Lakes, do not use this with one of these as paramet

Modifiers that can be added to other uniques to limit when they will be active

??? example "&lt;with [amount]% chance&gt;"
Example: "&lt;with [3]% chance&gt;"

Applicable to: Conditional

??? example "&lt;every [positiveAmount] turns&gt;"
Example: "&lt;every [3] turns&gt;"

Expand All @@ -2778,6 +2763,26 @@ If your mod renames Coast or Lakes, do not use this with one of these as paramet

Applicable to: Conditional

??? example "&lt;on [speed] game speed&gt;"
Example: "&lt;on [Quick] game speed&gt;"

Applicable to: Conditional

??? example "&lt;when [victoryType] Victory is enabled&gt;"
Example: "&lt;when [Domination] Victory is enabled&gt;"

Applicable to: Conditional

??? example "&lt;when [victoryType] Victory is disabled&gt;"
Example: "&lt;when [Domination] Victory is disabled&gt;"

Applicable to: Conditional

??? example "&lt;with [amount]% chance&gt;"
Example: "&lt;with [3]% chance&gt;"

Applicable to: Conditional

??? example "&lt;if tutorials are enabled&gt;"
Applicable to: Conditional

Expand Down Expand Up @@ -2841,21 +2846,6 @@ If your mod renames Coast or Lakes, do not use this with one of these as paramet

Applicable to: Conditional

??? example "&lt;on [speed] game speed&gt;"
Example: "&lt;on [Quick] game speed&gt;"

Applicable to: Conditional

??? example "&lt;when [victoryType] Victory is enabled&gt;"
Example: "&lt;when [Domination] Victory is enabled&gt;"

Applicable to: Conditional

??? example "&lt;when [victoryType] Victory is disabled&gt;"
Example: "&lt;when [Domination] Victory is disabled&gt;"

Applicable to: Conditional

??? example "&lt;if no other Civilization has researched this&gt;"
Applicable to: Conditional

Expand Down

0 comments on commit 579ea79

Please sign in to comment.