mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-23 21:22:39 +07:00
Validate unique parameters for mods
This commit is contained in:
parent
9cf47e9f48
commit
d20f8a53f8
@ -599,7 +599,6 @@
|
||||
"uniques": [
|
||||
"[+25]% Strength <when attacking> <for [Military] units> <for [50] turns>",
|
||||
"May buy [Great General] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>",
|
||||
"May buy [Great Admiral] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -455,10 +455,14 @@ class RulesetValidator(val ruleset: Ruleset) {
|
||||
|
||||
val typeComplianceErrors = unique.type.getComplianceErrors(unique, ruleset)
|
||||
for (complianceError in typeComplianceErrors) {
|
||||
if (complianceError.errorSeverity == severityToReport)
|
||||
rulesetErrors += "$name's unique \"${unique.text}\" contains parameter ${complianceError.parameterName}," +
|
||||
// TODO: Make this Error eventually, this is Not Good
|
||||
if (complianceError.errorSeverity <= severityToReport)
|
||||
rulesetErrors.add(RulesetError("$name's unique \"${unique.text}\" contains parameter ${complianceError.parameterName}," +
|
||||
" which does not fit parameter type" +
|
||||
" ${complianceError.acceptableParameterTypes.joinToString(" or ") { it.parameterName }} !"
|
||||
" ${complianceError.acceptableParameterTypes.joinToString(" or ") { it.parameterName }} !",
|
||||
RulesetErrorSeverity.Warning
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
for (conditional in unique.conditionals) {
|
||||
|
@ -78,6 +78,8 @@ enum class UniqueParameterType(
|
||||
if ('{' in parameterText) // "{filter} {filter}" for and logic
|
||||
return parameterText.filterCompositeLogic({ getErrorSeverity(it, ruleset) }) { a, b -> maxOf(a, b) }
|
||||
if (parameterText in knownValues) return null
|
||||
if (ruleset.unitPromotions.values.any { it.hasUnique(parameterText) })
|
||||
return null
|
||||
return BaseUnitFilter.getErrorSeverity(parameterText, ruleset)
|
||||
}
|
||||
override fun getTranslationWriterStringsForOutput() = knownValues
|
||||
|
@ -389,7 +389,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
|
||||
NoMovementToPillage("No movement cost to pillage", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
CanMoveAfterAttacking("Can move after attacking", UniqueTarget.Unit),
|
||||
TransferMovement("Transfer Movement to [unit]", UniqueTarget.Unit),
|
||||
TransferMovement("Transfer Movement to [mapUnitFilter]", UniqueTarget.Unit),
|
||||
MoveImmediatelyOnceBought("Can move immediately once bought", UniqueTarget.Unit),
|
||||
MayParadrop("May Paradrop up to [amount] tiles from inside friendly territory", UniqueTarget.Unit),
|
||||
|
||||
|
@ -1080,8 +1080,8 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
|
||||
??? example "Can move after attacking"
|
||||
Applicable to: Unit
|
||||
|
||||
??? example "Transfer Movement to [unit]"
|
||||
Example: "Transfer Movement to [Musketman]"
|
||||
??? example "Transfer Movement to [mapUnitFilter]"
|
||||
Example: "Transfer Movement to [Wounded]"
|
||||
|
||||
Applicable to: Unit
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user