Skip to content

Commit

Permalink
Added attributes of the [ai]
Browse files Browse the repository at this point in the history
Added the optional parameter "limit-max(number)"
  • Loading branch information
macabeus authored and Elvish-Hunter committed Mar 22, 2016
1 parent 58e8bc7 commit 74b72bb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
32 changes: 30 additions & 2 deletions data/schema.cfg
Expand Up @@ -432,14 +432,14 @@
scale_background="optional boolean" # TODO: Required 'background' defined
story="required string translatable"
show_title="optional boolean"
title="optional string translatable" # Incompatible with 'show_title=yes'
title="optional string translatable" # TODO: Incompatible with 'show_title=yes'
music="optional string" # TODO: Can be improved to check if the music file really exists
sound="optional string list"
[/part]
typescontroller="enum ai,human,null"
[side]
# TODO: _fog_override=...
# TODO: _ai=...
_ai="repeated ai"
# TODO: _village=...
# TODO: _unit=...
# TODO: _leader=...
Expand Down Expand Up @@ -480,6 +480,34 @@
facing="optional direction"
# TODO: And attributes for multiplayer?
[/side]
typesgrouping="enum offensive,defensive,no"
typesrecruitment_pattern="enum scout,fighter,archer,healer,mixed fighter"
[ai]
#TODO: _attacks=...
#TODO: _avoid=...
#TODO: _goal=...
#TODO: _leader_goal=...

time_of_day="optional string" # TODO: Can be improved be verified if the value exists in data/core/macros/schedules.cfg
turns="optional string" # TODO: Complex case
ai_algorithm="optional string" # TODO: Incompatible with 'time_of_day' and/or 'turns'
advancements="optional string list" # TODO: Can be improved be verified that the unit exists or not
aggression="optional float limit-max(1)"
caution="optional float"
grouping="optional typesgrouping"
leader_aggression="optional float"
leader_ignores_keep="optional boolean"
leader_value="optional float limit-lower(0)"
passive_leader="optional boolean"
passive_leader_shares_keep="optional boolean"
recruitment_ignore_bad_combat="optional boolean"
recruitment_pattern="optional typesrecruitment_pattern list"
scout_village_targeting="optional float"
simple_targeting="optional boolean"
support_villages="optional boolean"
village_value="optional float limit-lower(0)"
villages_per_scout="optional float limit-lower(0)"
[/ai]
[/schema]

## Things that still need to be converted, in a similar format.
Expand Down
9 changes: 9 additions & 0 deletions data/tools/wmlvalidator
Expand Up @@ -109,6 +109,15 @@ class Validator:
if float(value) < float(number):
self.validate_result_add(node.file, node.line, "Attribute [%s] %s%s" % (verbosename, attribute.name, gerate_message_with_pos()), "Value needs to be at least %s, found : %s" % (number, value))

regex_limit_max = re.compile(ur'^limit-max\((\d+.\d+|\d+)\)$')
check_limit_max = [i for i in attribute.optionals if regex_limit_max.search(i)]
if len(check_limit_max):
check_limit_max = check_limit_max[0]
number = regex_limit_max.search(check_limit_max).group(1)

if float(value) > float(number):
self.validate_result_add(node.file, node.line, "Attribute [%s] %s%s" % (verbosename, attribute.name, gerate_message_with_pos()), "Value needs to be at max %s, found : %s" % (number, value))

regex_file_exist = re.compile(ur'^need-file-in\(([\w.\-\/]+)\)$')
check_file_exist = [i for i in attribute.optionals if regex_file_exist.search(i)]
if len(check_file_exist):
Expand Down

0 comments on commit 74b72bb

Please sign in to comment.