Rewrite the WML unit test for sighted events
The old version's [event]name=sighted had a {RETURN} statement in it, which meant the test stopped on the first sighting. Most of the test wasn't testing anything.
This commit is contained in:
parent
00452c0187
commit
df41f13e41
2 changed files with 165 additions and 123 deletions
|
@ -1,133 +1,176 @@
|
||||||
|
# wmllint: no translatables
|
||||||
|
|
||||||
# This test checks that sighted events are being triggered
|
# This test checks that sighted events are being triggered
|
||||||
# at the appropriate time. An elvish archer moves towards
|
# correctly due to units moving - whether that's the viewer
|
||||||
# and discovers an orcish grunt.
|
# moving and revealing hexes in the fog, or whether that's
|
||||||
# We pass if the elvish archer is the discoverer, and the
|
# the enemy units moving into the already-revealed hexes.
|
||||||
# variable "sighted_should_trigger" is set.
|
[test]
|
||||||
# The second test checks what happens if the orc is discovered
|
name = "Unit Test sighted_on_move"
|
||||||
# on the elf's turn.
|
map_file=test/maps/sighted_events.map
|
||||||
|
turns = 4
|
||||||
|
id = sighted_on_move
|
||||||
|
random_start_time = no
|
||||||
|
is_unit_test = yes
|
||||||
|
|
||||||
#define TEST_SIGHTED_EVENTS_SCEN ID BOB_CONDITION
|
{DAWN}
|
||||||
[test]
|
|
||||||
name = "Unit Test {ID}"
|
|
||||||
map_file=test/maps/sighted_events.map
|
|
||||||
turns = 4
|
|
||||||
id = {ID}
|
|
||||||
random_start_time = no
|
|
||||||
is_unit_test = yes
|
|
||||||
|
|
||||||
{DAWN}
|
[side]
|
||||||
|
side=1
|
||||||
|
controller=human
|
||||||
|
name = "Alice"
|
||||||
|
type = Elvish Archer
|
||||||
|
id=alice
|
||||||
|
fog=yes
|
||||||
|
[/side]
|
||||||
|
[side]
|
||||||
|
side=2
|
||||||
|
controller=human
|
||||||
|
name = "Bob"
|
||||||
|
type = Orcish Grunt
|
||||||
|
id=bob
|
||||||
|
# For simplicity of counting the triggered events, disable fog so that
|
||||||
|
# there are no sighted-by-side-2 events.
|
||||||
|
fog=no
|
||||||
|
[/side]
|
||||||
|
|
||||||
[side]
|
#This makes the sides pass their turns, when the other events have taken place.
|
||||||
side=1
|
[event]
|
||||||
controller=human
|
name = side turn
|
||||||
name = "Alice"
|
first_time_only = no
|
||||||
type = Elvish Archer
|
[end_turn]
|
||||||
id=alice
|
[/end_turn]
|
||||||
fog=yes
|
[/event]
|
||||||
[/side]
|
|
||||||
[side]
|
|
||||||
side=2
|
|
||||||
controller=human
|
|
||||||
name = "Bob"
|
|
||||||
type = Orcish Grunt
|
|
||||||
id=bob
|
|
||||||
fog=yes
|
|
||||||
[/side]
|
|
||||||
|
|
||||||
[event]
|
[event]
|
||||||
name = prestart
|
name = prestart
|
||||||
{VARIABLE sighted_should_trigger no}
|
{VARIABLE sighted_count 0}
|
||||||
[/event]
|
[/event]
|
||||||
|
|
||||||
[event]
|
[event]
|
||||||
name = sighted
|
name = sighted
|
||||||
{ASSERT ({VARIABLE_CONDITIONAL unit.id equals bob})}
|
first_time_only = no
|
||||||
{ASSERT ({VARIABLE_CONDITIONAL second_unit.id equals alice})}
|
[set_variable]
|
||||||
{RETURN ({VARIABLE_CONDITIONAL sighted_should_trigger boolean_equals yes})}
|
name=sighted_count
|
||||||
[/event]
|
add=1
|
||||||
|
[/set_variable]
|
||||||
|
{ASSERT ({VARIABLE_CONDITIONAL unit.id equals bob})}
|
||||||
|
{ASSERT ({VARIABLE_CONDITIONAL second_unit.id equals alice})}
|
||||||
|
[/event]
|
||||||
|
|
||||||
#Alice moves towards Bob.
|
# Alice moves towards Bob, but stays far away enough that he is still hidden by the fog.
|
||||||
[event]
|
[event]
|
||||||
name = side 1 turn 1 refresh
|
name = side 1 turn 1 refresh
|
||||||
[do_command]
|
[do_command]
|
||||||
[move]
|
[move]
|
||||||
x=1,2,3,4,5,6,7
|
x=1,2,3,4,5,6,7
|
||||||
y=3,3,3,3,3,3,3
|
y=3,3,3,3,3,3,3
|
||||||
[/move]
|
[/move]
|
||||||
[/do_command]
|
[/do_command]
|
||||||
[/event]
|
{ASSERT ({VARIABLE_CONDITIONAL sighted_count equals 0})}
|
||||||
|
[/event]
|
||||||
|
|
||||||
#Bob moves either down, then up (unseen), or left, then right (seen)
|
# Bob moves around near the edge of Alice's vision
|
||||||
[event]
|
[event]
|
||||||
name = side 2 turn 1 refresh
|
name = side 2 turn 1 refresh
|
||||||
[if]
|
{ASSERT ({VARIABLE_CONDITIONAL sighted_count equals 0})}
|
||||||
{BOB_CONDITION}
|
|
||||||
[then]
|
|
||||||
[do_command]
|
|
||||||
[move]
|
|
||||||
x=16,16,16
|
|
||||||
y=3,4,5
|
|
||||||
[/move]
|
|
||||||
[/do_command]
|
|
||||||
[do_command]
|
|
||||||
[move]
|
|
||||||
x=16,16,16
|
|
||||||
y=5,4,3
|
|
||||||
[/move]
|
|
||||||
[/do_command]
|
|
||||||
[/then]
|
|
||||||
[else]
|
|
||||||
{VARIABLE sighted_should_trigger yes}
|
|
||||||
[do_command]
|
|
||||||
[move]
|
|
||||||
x=16,15,14
|
|
||||||
y=3,3,3
|
|
||||||
[/move]
|
|
||||||
[/do_command]
|
|
||||||
[do_command]
|
|
||||||
[move]
|
|
||||||
x=14,15,16
|
|
||||||
y=3,3,3
|
|
||||||
[/move]
|
|
||||||
[/do_command]
|
|
||||||
[/else]
|
|
||||||
[/if]
|
|
||||||
[/event]
|
|
||||||
|
|
||||||
#Alice discovers Bob.
|
# Give the unit enough MP, so that he doesn't run out of moves while
|
||||||
[event]
|
# moving around. The error without this is "found corrupt movement in
|
||||||
name = side 1 turn 2 refresh
|
# replay", which isn't obvious about what caused the problem.
|
||||||
[do_command]
|
[modify_unit]
|
||||||
[move]
|
[filter]
|
||||||
x=7,8
|
id=bob
|
||||||
y=3,3
|
[/filter]
|
||||||
[/move]
|
moves="$({UNREACHABLE} - 1)"
|
||||||
[/do_command]
|
[/modify_unit]
|
||||||
#With the next stop Bob should be visible.
|
|
||||||
{VARIABLE sighted_should_trigger yes}
|
|
||||||
[do_command]
|
|
||||||
[move]
|
|
||||||
x=8,9
|
|
||||||
y=3,3
|
|
||||||
[/move]
|
|
||||||
[/do_command]
|
|
||||||
[/event]
|
|
||||||
|
|
||||||
#If we got this far without triggering sighted, we fail the test.
|
# Bob moves down, then up. This doesn't move closer to Alice, so he should remain unseen.
|
||||||
[event]
|
[do_command]
|
||||||
name = side 2 turn 2
|
[move]
|
||||||
{FAIL}
|
x=16,16,16
|
||||||
[/event]
|
y=3,4,5
|
||||||
|
[/move]
|
||||||
|
[/do_command]
|
||||||
|
[do_command]
|
||||||
|
[move]
|
||||||
|
x=16,16,16
|
||||||
|
y=5,4,3
|
||||||
|
[/move]
|
||||||
|
[/do_command]
|
||||||
|
{ASSERT ({VARIABLE_CONDITIONAL sighted_count equals 0})}
|
||||||
|
|
||||||
#This makes the sides pass their turns, when the other events have taken place.
|
# Bob moves left twice, then back to the right. He should be seen on the second step left.
|
||||||
[event]
|
[do_command]
|
||||||
name = side turn
|
[move]
|
||||||
first_time_only = no
|
x=16,15
|
||||||
[end_turn]
|
y=3,3
|
||||||
[/end_turn]
|
[/move]
|
||||||
[/event]
|
[/do_command]
|
||||||
[/test]
|
{ASSERT ({VARIABLE_CONDITIONAL sighted_count equals 0})}
|
||||||
#enddef
|
[do_command]
|
||||||
|
[move]
|
||||||
|
x=15,14
|
||||||
|
y=3,3
|
||||||
|
[/move]
|
||||||
|
[/do_command]
|
||||||
|
{ASSERT ({VARIABLE_CONDITIONAL sighted_count equals 1})}
|
||||||
|
[do_command]
|
||||||
|
[move]
|
||||||
|
x=14,15,16
|
||||||
|
y=3,3,3
|
||||||
|
[/move]
|
||||||
|
[/do_command]
|
||||||
|
{ASSERT ({VARIABLE_CONDITIONAL sighted_count equals 1})}
|
||||||
|
|
||||||
{TEST_SIGHTED_EVENTS_SCEN sighted_events ([true][/true])}
|
# Bob moves left twice within a single [move]. He should be seen on 14,3.
|
||||||
{TEST_SIGHTED_EVENTS_SCEN sighted_on_opponents_turn ([false][/false])}
|
[do_command]
|
||||||
|
[move]
|
||||||
|
x=16,15,14
|
||||||
|
y=3,3,3
|
||||||
|
[/move]
|
||||||
|
[/do_command]
|
||||||
|
{ASSERT ({VARIABLE_CONDITIONAL sighted_count equals 2})}
|
||||||
|
|
||||||
|
# Alice can already see Bob, so this shouldn't trigger more sighted events
|
||||||
|
[do_command]
|
||||||
|
[move]
|
||||||
|
x=14,13,12
|
||||||
|
y=3,3,3
|
||||||
|
[/move]
|
||||||
|
[/do_command]
|
||||||
|
{ASSERT ({VARIABLE_CONDITIONAL sighted_count equals 2})}
|
||||||
|
|
||||||
|
# Return to the starting spot
|
||||||
|
[do_command]
|
||||||
|
[move]
|
||||||
|
x=12,13,14,15,16
|
||||||
|
y=3,3,3,3,3
|
||||||
|
[/move]
|
||||||
|
[/do_command]
|
||||||
|
{ASSERT ({VARIABLE_CONDITIONAL sighted_count equals 2})}
|
||||||
|
[/event]
|
||||||
|
|
||||||
|
# Alice moves further toward Bob
|
||||||
|
[event]
|
||||||
|
name = side 1 turn 2 refresh
|
||||||
|
{VARIABLE sighted_count 0}
|
||||||
|
[do_command]
|
||||||
|
[move]
|
||||||
|
x=7,8
|
||||||
|
y=3,3
|
||||||
|
[/move]
|
||||||
|
[/do_command]
|
||||||
|
{ASSERT ({VARIABLE_CONDITIONAL sighted_count equals 0})}
|
||||||
|
|
||||||
|
# With the next stop Bob should be visible.
|
||||||
|
[do_command]
|
||||||
|
[move]
|
||||||
|
x=8,9
|
||||||
|
y=3,3
|
||||||
|
[/move]
|
||||||
|
[/do_command]
|
||||||
|
{ASSERT ({VARIABLE_CONDITIONAL sighted_count equals 1})}
|
||||||
|
|
||||||
|
{SUCCEED}
|
||||||
|
[/event]
|
||||||
|
[/test]
|
||||||
|
|
|
@ -89,8 +89,7 @@
|
||||||
5 test_move_fail_6
|
5 test_move_fail_6
|
||||||
0 test_move_unit
|
0 test_move_unit
|
||||||
0 test_move_unit_in_circle
|
0 test_move_unit_in_circle
|
||||||
0 sighted_events
|
0 sighted_on_move
|
||||||
0 sighted_on_opponents_turn
|
|
||||||
0 move_skip_no_sighted_no_share_view
|
0 move_skip_no_sighted_no_share_view
|
||||||
0 move_skip_ally_sighted_no_share_view
|
0 move_skip_ally_sighted_no_share_view
|
||||||
0 move_skip_all_sighted_no_share_view
|
0 move_skip_all_sighted_no_share_view
|
||||||
|
|
Loading…
Add table
Reference in a new issue