Schema: Support omitting the final index in [modify_ai] paths

Also mark the subtags in [modify_ai] as required
This commit is contained in:
Celtic Minstrel 2018-03-30 23:37:22 -04:00
parent cfe4d120ee
commit 9a966a46f5
2 changed files with 51 additions and 3 deletions

View file

@ -5,6 +5,7 @@
[then]
[tag]
name="aspect"
min=1
[if]
# This is the best way we have to proscribe a particular value:
# If it's any other value, the tag must not contain what it's supposed to.
@ -49,11 +50,16 @@
[/elseif]
[elseif]
glob_on_path=aspect[{ASPECT}]*.facet[*]
[or]
action=add
glob_on_path=aspect[{ASPECT}]*.facet
[/or]
# Glob isn't good enough to verify that these are really just a chain of facets
# Combined with the regex type validation on path though, it should be good enough
[then]
[tag]
name="facet"
min=1
super="$ai/facet~{TYPE}"
[/tag]
[/then]
@ -73,27 +79,43 @@
# Nothing extra for deleting components
[elseif]
glob_on_path=goal[*]
[or]
action=add
path=goal
[/or]
[then]
[tag]
name="goal"
min=1
super="$ai/goal"
[/tag]
[/then]
[/elseif]
# Candidate actions before stages because the stage glob also matches candidate action paths
[elseif]
glob_on_path=stage[*].candidate_action[*]
[or]
action=add
glob_on_path=stage[*].candidate_action
[/or]
[then]
[tag]
name="candidate_action"
min=1
super="$ai/$candidate_action"
[/tag]
[/then]
[/elseif]
[elseif]
glob_on_path=stage[*]
[or]
action=add
path=stage
[/or]
[then]
[tag]
name="stage"
min=1
super="$ai/stage"
[/tag]
[/then]
@ -101,18 +123,28 @@
# Recruitment jobs before aspects because some could also be matched by the facet globs
[elseif]
glob_on_path=aspect[recruitment_instructions]*.recruit[*]
[or]
action=add
glob_on_path=aspect[recruitment_instructions]*.recruit
[/or]
[then]
[tag]
name="recruit"
min=1
super="$ai/$recruit"
[/tag]
[/then]
[/elseif]
[elseif]
glob_on_path=aspect[recruitment_instructions]*.limit[*]
[or]
action=add
glob_on_path=aspect[recruitment_instructions]*.limit
[/or]
[then]
[tag]
name="limit"
min=1
super="$ai/$recruit_limit"
[/tag]
[/then]

View file

@ -269,14 +269,30 @@
# This only does some very basic validation and accepts quite a few invalid values.
# For example, only aspect[recruitment_instructions] can have a .recruit or .limit suffix.
[union]
# Toplevel components without index
# Aspect isn't really useful here but I guess is technically valid
[type]
value="aspect\[([a-zA-Z0-9_]+|\*)?\](\.facet\[([a-zA-Z0-9_]+|\*)?\])*(\.(recruit|limit)\[([a-zA-Z0-9_]+|\*)?\])?"
value="aspect|goal|stage"
[/type]
# Toplevel components with index
[type]
value="goal\[([a-zA-Z0-9_]+|\*)?\]"
value="(aspect|goal|stage)\[[^\]]*\]"
[/type]
# Facets without index
[type]
value="stage\[([a-zA-Z0-9_]+|\*)?\](\.candidate_action\[([a-zA-Z0-9_]+|\*)?\])?"
value="aspect\[[^\]]*\](\.facet\[[^\]]*\])*\.facet"
[/type]
# Facets with index
[type]
value="aspect\[[^\]]*\](\.facet\[[^\]]*\])+"
[/type]
# Recruitment jobs with optional index
[type]
value="aspect\[[^\]]*\](\.facet\[[^\]]*\])+\.(recruit|limit)(\[[^\]]*\])?"
[/type]
# Candidate actions with optional index
[type]
value="stage\[[^\]]*\]\.candidate_action(\[[^\]]*\])?"
[/type]
[/union]
[/type]