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