Skip to content

Commit

Permalink
Allow comment uniques and timed uniques in event choices
Browse files Browse the repository at this point in the history
  • Loading branch information
yairm210 committed Sep 23, 2024
1 parent db5e45c commit 916317a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 31 deletions.
2 changes: 1 addition & 1 deletion core/src/com/unciv/models/ruleset/unique/UniqueTarget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ enum class UniqueTarget(
// As Array so it can used in a vararg parameter list.
val Displayable = arrayOf(
Building, Unit, UnitType, Improvement, Tech, FollowerBelief, FounderBelief,
Terrain, Resource, Policy, Promotion, Nation, Ruins, Speed
Terrain, Resource, Policy, Promotion, Nation, Ruins, Speed, EventChoice
)
val CanIncludeSuppression = arrayOf(
Triggerable, // Includes Global and covers most IHasUnique's
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ class UniqueValidator(val ruleset: Ruleset) {
if (unique.type == null) return checkUntypedUnique(unique, tryFixUnknownUniques, uniqueContainer, prefix)

val rulesetErrors = RulesetErrorList(ruleset)

if (uniqueContainer != null && !unique.type.canAcceptUniqueTarget(uniqueContainer.getUniqueTarget()))

if (uniqueContainer != null &&
!(unique.type.canAcceptUniqueTarget(uniqueContainer.getUniqueTarget()) ||
// "for X turns" effectively turns a global unique into a trigger
unique.hasModifier(UniqueType.ConditionalTimedUnique)
&& uniqueContainer.getUniqueTarget().canAcceptUniqueTarget(UniqueTarget.Triggerable)
))
rulesetErrors.add("$prefix is not allowed on its target type", RulesetErrorSeverity.Warning, uniqueContainer, unique)

val typeComplianceErrors = getComplianceErrors(unique)
Expand Down
65 changes: 37 additions & 28 deletions docs/Modders/uniques.md
Original file line number Diff line number Diff line change
Expand Up @@ -1043,13 +1043,13 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: Nation, Terrain, Improvement, Resource

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

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

## Personality uniques
??? example "Will not build [baseUnitFilter/buildingFilter]"
Expand Down Expand Up @@ -1088,13 +1088,13 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: Tech, Policy, Promotion

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

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

## Policy uniques
??? example "Only available"
Expand All @@ -1111,13 +1111,13 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: Tech, Policy, Promotion

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

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

## FounderBelief uniques
!!! note ""
Expand All @@ -1144,13 +1144,13 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, Promotion, Improvement, Ruins, Event, EventChoice

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

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

## FollowerBelief uniques
!!! note ""
Expand Down Expand Up @@ -1387,13 +1387,13 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: FollowerBelief

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

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

## Building uniques
??? example "Consumes [amount] [resource]"
Expand Down Expand Up @@ -1562,13 +1562,13 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
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
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

## UnitAction uniques
!!! note ""
Expand Down Expand Up @@ -2133,23 +2133,23 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
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
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

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

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

## Promotion uniques
??? example "Only available"
Expand All @@ -2172,13 +2172,13 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: Tech, Policy, Promotion

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

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

## Terrain uniques
??? example "[stats]"
Expand Down Expand Up @@ -2357,13 +2357,13 @@ If your mod renames Coast or Lakes, do not use this with one of these as paramet
Applicable to: Nation, Terrain, Improvement, Resource

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

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

??? example "Suppress warning [validationWarning]"
Allows suppressing specific validation warnings. Errors, deprecation warnings, or warnings about untyped and non-filtering uniques should be heeded, not suppressed, and are therefore not accepted. Note that this can be used in ModOptions, in the uniques a warning is about, or as modifier on the unique triggering a warning - but you still need to be specific. Even in the modifier case you will need to specify a sufficiently selective portion of the warning text as parameter.
Expand Down Expand Up @@ -2521,13 +2521,13 @@ If your mod renames Coast or Lakes, do not use this with one of these as paramet
Applicable to: Improvement

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

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

## Resource uniques
??? example "Obsolete with [tech]"
Expand Down Expand Up @@ -2598,13 +2598,13 @@ If your mod renames Coast or Lakes, do not use this with one of these as paramet
Applicable to: Resource

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

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

## Ruins uniques
??? example "Only available"
Expand All @@ -2629,23 +2629,23 @@ If your mod renames Coast or Lakes, do not use this with one of these as paramet
Applicable to: Building, Unit, Ruins, Tutorial

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

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

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

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed
Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

??? example "Suppress warning [validationWarning]"
Allows suppressing specific validation warnings. Errors, deprecation warnings, or warnings about untyped and non-filtering uniques should be heeded, not suppressed, and are therefore not accepted. Note that this can be used in ModOptions, in the uniques a warning is about, or as modifier on the unique triggering a warning - but you still need to be specific. Even in the modifier case you will need to specify a sufficiently selective portion of the warning text as parameter.
Expand Down Expand Up @@ -2744,6 +2744,15 @@ If your mod renames Coast or Lakes, do not use this with one of these as paramet
Meant to be used together with conditionals, like "Unavailable <after generating a Great Prophet>".
Applicable to: Tech, Policy, Building, Unit, Promotion, Improvement, Ruins, Event, EventChoice

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

??? example "Comment [comment]"
Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent.
Example: "Comment [comment]"

Applicable to: Nation, Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, UnitType, Promotion, Terrain, Improvement, Resource, Ruins, Speed, EventChoice

## Conditional uniques
!!! note ""

Expand Down

0 comments on commit 916317a

Please sign in to comment.