Better Expression documentation

This commit is contained in:
yairm210 2025-05-01 23:45:40 +03:00
parent a689d70ce9
commit ee9df6e9bf
4 changed files with 12 additions and 10 deletions

View File

@ -179,8 +179,9 @@ enum class Countables(
override val documentationHeader = "Evaluate expressions!"
override val documentationStrings = listOf(
"Expressions support arbitrary math operations, and can include other countables",
"For example, something like: `([[Melee] units] + 1) / [Cities]`",
"Expressions support arbitrary math operations, and can include other countables, when surrounded by square brackets.",
"For example, since `Cities` is a countable, and `[Melee] units` is a countable, " +
"you can have something like: `([[Melee] units] + 1) / [Cities]` (the whitespace is optional but helps readability)",
"Since on translation, the brackets are removed, the expression will be displayed as `(Melee units + 1) / Cities`",
"Supported operations between 2 values are: "+ Operator.BinaryOperators.entries.joinToString { it.symbol },
"Supported operations on 1 value are: " + Operator.UnaryOperators.entries.joinToString { it.symbol+" (${it.description})" },

View File

@ -69,7 +69,8 @@ enum class UniqueParameterType(
parameterText.getInvariantSeverityUnless { toIntOrNull() != null }
},
Countable("countable", "1000", "This indicates a number or a numeric variable") {
Countable("countable", "1000", "This indicates a number or a numeric variable." +
"They can be tested in the developer console with `civ checkcountable` - for example, `civ checkcountable \"[Iron]+2\"`") {
override fun isKnownValue(parameterText: String, ruleset: Ruleset) =
Countables.isKnownValue(parameterText, ruleset)

View File

@ -342,13 +342,13 @@ Allowed values:
[//]: # (Countables automatically generated BEGIN)
- Integer constant - any positive or negative integer number
- `turns` - Number of turns played
- (Always starts at zero irrespective of game speed or start era)
- Always starts at zero irrespective of game speed or start era
- `year` - The current year
- (Depends on game speed or start era, negative for years BC)
- Depends on game speed or start era, negative for years BC
- `Cities` - The number of cities the relevant Civilization owns
- `Units` - The number of units the relevant Civilization owns
- Stat name (`Production`, `Food`, `Gold`, `Science`, `Culture`, `Happiness` or `Faith`)
- gets the stat *reserve*, not the amount per turn (can be city stats or civilization stats, depending on where the unique is used)
- Gets the stat *reserve*, not the amount per turn (can be city stats or civilization stats, depending on where the unique is used)
- `Completed Policy branches`
- `[cityFilter] Cities`
- `[mapUnitFilter] Units`
@ -356,12 +356,12 @@ Allowed values:
- `Remaining [civFilter] Civilizations`
- `Owned [tileFilter] Tiles`
- Resource name - From [TileResources.json](3-Map-related-JSON-files.md#tileresourcesjson)
- (can be city stats or civilization stats, depending on where the unique is used)
- Can be city stats or civilization stats, depending on where the unique is used
- For example: If a unique is placed on a building, then the retrieved resources will be of the city. If placed on a policy, they will be of the civilization.
- This can make a difference for e.g. local resources, which are counted per city.
- Evaluate expressions!
- Expressions support arbitrary math operations, and can include other countables
- For example, something like: `([[Melee] units] + 1) / [Cities]`
- Expressions support arbitrary math operations, and can include other countables, when surrounded by square brackets.
- For example, since `Cities` is a countable, and `[Melee] units` is a countable, you can have something like: `([[Melee] units] + 1) / [Cities]` (the whitespace is optional but helps readability)
- Since on translation, the brackets are removed, the expression will be displayed as `(Melee units + 1) / Cities`
- Supported operations between 2 values are: +, -, *, /, %, ^
- Supported operations on 1 value are: - (negation), √ (square root), abs (absolute value - turns negative into positive), sqrt (square root), floor (round down), ceil (round up)

View File

@ -3531,7 +3531,7 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
*[civWideStat]: All the following stats have civ-wide fields: `Gold`, `Science`, `Culture`, `Faith`.
*[combatantFilter]: This indicates a combatant, which can either be a unit or a city (when bombarding). Must either be `City` or a `mapUnitFilter`.
*[costOrStrength]: `Cost` or `Strength`.
*[countable]: This indicates a number or a numeric variable.
*[countable]: This indicates a number or a numeric variable.They can be tested in the developer console with `civ checkcountable` - for example, `civ checkcountable "[Iron]+2"`.
*[difficulty]: The name of any difficulty.
*[era]: The name of any era.
*[event]: The name of any event.