Skip to content

Commit

Permalink
Schema: Support omitting the final index in [modify_ai] paths
Browse files Browse the repository at this point in the history
Also mark the subtags in [modify_ai] as required
  • Loading branch information
CelticMinstrel committed Apr 12, 2018
1 parent a73f31f commit f816668
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
32 changes: 32 additions & 0 deletions data/schema/ai/modify.cfg
Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand All @@ -73,46 +79,72 @@
# 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]
[/elseif]
# 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]
Expand Down
22 changes: 19 additions & 3 deletions data/schema/game_config.cfg
Expand Up @@ -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]
Expand Down

0 comments on commit f816668

Please sign in to comment.