mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-20 19:56:51 +01:00
modding: Added validation for UnitType.movementType
This commit is contained in:
parent
9c618a242f
commit
55f4f44e65
|
|
@ -13,7 +13,7 @@ enum class UnitMovementType { // The types of tiles the unit can by default ente
|
|||
}
|
||||
|
||||
class UnitType() : RulesetObject() {
|
||||
private var movementType: String? = null
|
||||
internal var movementType: String? = null
|
||||
private val unitMovementType: UnitMovementType? by lazy { if (movementType == null) null else UnitMovementType.valueOf(movementType!!) }
|
||||
override fun getUniqueTarget() = UniqueTarget.UnitType
|
||||
override fun makeLink() = "UnitType/$name"
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import com.unciv.models.ruleset.unique.StateForConditionals
|
|||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.ruleset.unit.BaseUnit
|
||||
import com.unciv.models.ruleset.unit.Promotion
|
||||
import com.unciv.models.ruleset.unit.UnitMovementType
|
||||
import com.unciv.models.stats.INamed
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.models.tilesets.TileSetCache
|
||||
|
|
@ -312,11 +313,14 @@ class RulesetValidator(val ruleset: Ruleset) {
|
|||
}
|
||||
}
|
||||
|
||||
val unitMovementTypes = UnitMovementType.entries.map { it.name }.toSet()
|
||||
private fun addUnitTypeErrors(
|
||||
lines: RulesetErrorList,
|
||||
tryFixUnknownUniques: Boolean
|
||||
) {
|
||||
for (unitType in ruleset.unitTypes.values) {
|
||||
if (unitType.movementType !in unitMovementTypes)
|
||||
lines.add("Unit type ${unitType.name} has an invalid movement type ${unitType.movementType}", sourceObject = unitType)
|
||||
uniqueValidator.checkUniques(unitType, lines, true, tryFixUnknownUniques)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user