mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-18 03:38:55 +07:00
Validate unique parameters for mods
This commit is contained in:
@ -599,7 +599,6 @@
|
|||||||
"uniques": [
|
"uniques": [
|
||||||
"[+25]% Strength <when attacking> <for [Military] units> <for [50] turns>",
|
"[+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 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)
|
val typeComplianceErrors = unique.type.getComplianceErrors(unique, ruleset)
|
||||||
for (complianceError in typeComplianceErrors) {
|
for (complianceError in typeComplianceErrors) {
|
||||||
if (complianceError.errorSeverity == severityToReport)
|
// TODO: Make this Error eventually, this is Not Good
|
||||||
rulesetErrors += "$name's unique \"${unique.text}\" contains parameter ${complianceError.parameterName}," +
|
if (complianceError.errorSeverity <= severityToReport)
|
||||||
|
rulesetErrors.add(RulesetError("$name's unique \"${unique.text}\" contains parameter ${complianceError.parameterName}," +
|
||||||
" which does not fit parameter type" +
|
" 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) {
|
for (conditional in unique.conditionals) {
|
||||||
|
@ -78,6 +78,8 @@ enum class UniqueParameterType(
|
|||||||
if ('{' in parameterText) // "{filter} {filter}" for and logic
|
if ('{' in parameterText) // "{filter} {filter}" for and logic
|
||||||
return parameterText.filterCompositeLogic({ getErrorSeverity(it, ruleset) }) { a, b -> maxOf(a, b) }
|
return parameterText.filterCompositeLogic({ getErrorSeverity(it, ruleset) }) { a, b -> maxOf(a, b) }
|
||||||
if (parameterText in knownValues) return null
|
if (parameterText in knownValues) return null
|
||||||
|
if (ruleset.unitPromotions.values.any { it.hasUnique(parameterText) })
|
||||||
|
return null
|
||||||
return BaseUnitFilter.getErrorSeverity(parameterText, ruleset)
|
return BaseUnitFilter.getErrorSeverity(parameterText, ruleset)
|
||||||
}
|
}
|
||||||
override fun getTranslationWriterStringsForOutput() = knownValues
|
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),
|
NoMovementToPillage("No movement cost to pillage", UniqueTarget.Unit, UniqueTarget.Global),
|
||||||
CanMoveAfterAttacking("Can move after attacking", UniqueTarget.Unit),
|
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),
|
MoveImmediatelyOnceBought("Can move immediately once bought", UniqueTarget.Unit),
|
||||||
MayParadrop("May Paradrop up to [amount] tiles from inside friendly territory", 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"
|
??? example "Can move after attacking"
|
||||||
Applicable to: Unit
|
Applicable to: Unit
|
||||||
|
|
||||||
??? example "Transfer Movement to [unit]"
|
??? example "Transfer Movement to [mapUnitFilter]"
|
||||||
Example: "Transfer Movement to [Musketman]"
|
Example: "Transfer Movement to [Wounded]"
|
||||||
|
|
||||||
Applicable to: Unit
|
Applicable to: Unit
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user