wesnoth/data/test/scenarios/ai/_main.cfg

91 lines
2.3 KiB
INI

#define AI_NOTIFICATION_STAGE CODE
[ai]
ai_algorithm=idle_ai
[stage]
id=check_validity
engine=lua
code={CODE}
[/stage]
[/ai]
#enddef
#define ASPECT_NOTIFICATION
<<
local expected = wml.array_access.get('expected')
local aspect = wml.variables['test_attribute']
if ai.aspects[aspect] ~= expected[wesnoth.current.turn].value then
wml.variables['is_valid'] = false
local msg = 'Failed on turn ' .. tostring(wesnoth.current.turn)
msg = msg .. ' (time: ' .. wesnoth.get_time_of_day().id .. ')'
msg = msg .. '; ' .. aspect
msg = msg .. ' was ' .. tostring(ai.aspects[aspect])
msg = msg .. ' but expected to be '
msg = msg .. tostring(expected[wesnoth.current.turn].value)
wesnoth.wml_actions.wml_message{message=msg, logger='error'}
end
>>
#enddef
#define SPLIT LIST SEP
[split]
list={LIST}
key=value
separator={SEP}
[/split]
#enddef
#define AI_ASPECT_UNIT_TEST NAME TEST_ATTRIBUTE EXPECTED AIWML CONTENT
{AI_UNIT_TEST {NAME} {ASPECT_NOTIFICATION} {TEST_ATTRIBUTE} {EXPECTED} {AIWML} {CONTENT}}
#enddef
#define AI_UNIT_TEST NAME TEST_CODE TEST_ATTRIBUTE EXPECTED AIWML CONTENT
[test]
name = "AI Unit Test " + {NAME}
map_data = "{test/maps/generic_unit_test.map}"
turns = -1
id = {NAME}
is_unit_test = yes
{DEFAULT_SCHEDULE}
[side]
side=1
controller=computer
name = "Alice"
type = Elvish Archer
id=alice
{AI_NOTIFICATION_STAGE {TEST_CODE}}
{AIWML}
[/side]
[side]
side=2
controller=computer
name = "Bob"
type = Orcish Grunt
id=bob
[ai]
ai_algorithm=idle_ai
[/ai]
[/side]
[event]
name=prestart
{VARIABLE is_valid true}
{VARIABLE test_attribute {TEST_ATTRIBUTE}}
[set_variables]
name=expected
{EXPECTED}
[/set_variables]
[/event]
[event]
name=turn 12 end
{RETURN {VARIABLE_CONDITIONAL is_valid boolean_equals true}}
[/event]
{CONTENT}
[/test]
#enddef
{test/scenarios/ai/config}
{test/scenarios/ai/modify}