mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-13 08:14:29 +07:00
Added ruleset validation for event uniques
This commit is contained in:
parent
ec131fe7cb
commit
44528d26d0
@ -21,7 +21,7 @@ class Event : INamed {
|
||||
class EventChoice {
|
||||
var text = ""
|
||||
var triggeredUniques = ArrayList<String>()
|
||||
val triggerredUniqueObjects by lazy { triggeredUniques.map { Unique(it) } }
|
||||
val triggeredUniqueObjects by lazy { triggeredUniques.map { Unique(it) } }
|
||||
|
||||
var conditions = ArrayList<String>()
|
||||
val conditionObjects by lazy { conditions.map { Unique(it) } }
|
||||
@ -29,7 +29,7 @@ class EventChoice {
|
||||
conditionObjects.all { Conditionals.conditionalApplies(null, it, stateForConditionals) }
|
||||
|
||||
fun triggerChoice(civ: Civilization) {
|
||||
for (unique in triggerredUniqueObjects)
|
||||
for (unique in triggeredUniqueObjects)
|
||||
UniqueTriggerActivation.triggerUnique(unique, civ)
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.unciv.models.ruleset.validation
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.files.FileHandle
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData
|
||||
import com.unciv.Constants
|
||||
@ -85,6 +84,7 @@ class RulesetValidator(val ruleset: Ruleset) {
|
||||
addUnitTypeErrors(lines, tryFixUnknownUniques)
|
||||
addVictoryTypeErrors(lines)
|
||||
addDifficultyErrors(lines)
|
||||
addEventErrors(lines, tryFixUnknownUniques)
|
||||
addCityStateTypeErrors(tryFixUnknownUniques, lines)
|
||||
|
||||
// Check for mod or Civ_V_GnK to avoid running the same test twice (~200ms for the builtin assets)
|
||||
@ -142,6 +142,17 @@ class RulesetValidator(val ruleset: Ruleset) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun addEventErrors(lines: RulesetErrorList,
|
||||
tryFixUnknownUniques: Boolean) {
|
||||
// A Difficulty is not a IHasUniques, so not suitable as sourceObject
|
||||
for (event in ruleset.events.values) {
|
||||
for (choice in event.choices) {
|
||||
for (unique in choice.conditionObjects + choice.triggeredUniqueObjects)
|
||||
lines += uniqueValidator.checkUnique(unique, tryFixUnknownUniques, null, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addVictoryTypeErrors(lines: RulesetErrorList) {
|
||||
// Victory and Milestone aren't IHasUniques and are unsuitable as sourceObject
|
||||
for (victoryType in ruleset.victories.values) {
|
||||
|
Loading…
Reference in New Issue
Block a user