Skip to content

Commit

Permalink
Healing: Add a unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jostephd committed Oct 21, 2018
1 parent 5ce2f2d commit 2f62302
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 0 deletions.
154 changes: 154 additions & 0 deletions data/test/scenarios/heal.cfg
@@ -0,0 +1,154 @@
#define EXPECT_HITPOINTS leader1 healer1 leader2 healer2
[store_unit]
[filter]
side=1
canrecruit=yes
[/filter]
variable=leader1
kill=no
[/store_unit]
[store_unit]
[filter]
side=2
canrecruit=yes
[/filter]
variable=leader2
kill=no
[/store_unit]
[store_unit]
[filter]
side=1
canrecruit=no
[/filter]
variable=healer1
kill=no
[/store_unit]
[store_unit]
[filter]
side=2
canrecruit=no
[/filter]
variable=healer2
kill=no
[/store_unit]
[if]
[not]
{VARIABLE_CONDITIONAL leader1.hitpoints numerical_equals {leader1}}
{VARIABLE_CONDITIONAL leader2.hitpoints numerical_equals {leader2}}
{VARIABLE_CONDITIONAL healer1.hitpoints numerical_equals {healer1}}
{VARIABLE_CONDITIONAL healer2.hitpoints numerical_equals {healer2}}
[/not]
[then]
{FAIL}
[/then]
[/if]
#enddef

{GENERIC_UNIT_TEST "heal" (
[event]
name = start
# Create two healers adjacent to the leaders
{UNIT 1 (Elvish Shyde) 7 4 (id=healer1)}
{UNIT 2 (Saurian Soothsayer) 13 4 (id=healer2)}
[modify_unit]
[filter][/filter]
# Ensure we can heal as much as we may need to
hitpoints=1
max_hitpoints=999
[/modify_unit]
[/event]

# Baseline: as defined in the scenario
[event]
name=side 1 turn 1 refresh
{EXPECT_HITPOINTS 1 1 1 1}
[end_turn][/end_turn]
[/event]

# side 2 gets healing but no rest healing
[event]
name=side 2 turn 1 refresh
{EXPECT_HITPOINTS 1 1 9 1}
[end_turn][/end_turn]
[/event]

# side 1 gets healing but no rest healing (??)
[event]
name=side 1 turn 2 refresh
{EXPECT_HITPOINTS 9 1 9 1}
[end_turn][/end_turn]
[/event]

# side 2 gets healing and rest healing
[event]
name=side 2 turn 2 refresh
{EXPECT_HITPOINTS 9 1 19 3}
[end_turn][/end_turn]
[/event]

# side 1 gets healing and rest healing
[event]
name=side 1 turn 3 refresh
{EXPECT_HITPOINTS 19 3 19 3}
[move_unit]
side=1
canrecruit=yes
to_x,to_y=8,1
[/move_unit]
[move_unit]
side=1
canrecruit=no
to_x,to_y=8,2
[/move_unit]
[modify_unit]
[filter]
side=1
[/filter]
moves=0
[/modify_unit]
[end_turn][/end_turn]
[/event]

# side 2 gets healing and rest healing
[event]
name=side 2 turn 3 refresh
{EXPECT_HITPOINTS 19 3 29 5}
[move_unit]
side=2
canrecruit=yes
to_x,to_y=15,1
[/move_unit]
[move_unit]
side=2
canrecruit=no
to_x,to_y=15,2
[/move_unit]
[modify_unit]
[filter]
side=2
[/filter]
moves=0
[/modify_unit]
[end_turn][/end_turn]
[/event]

# side 1 gets healing but not rest healing
[event]
name=side 1 turn 4 refresh
{EXPECT_HITPOINTS 27 3 29 5}
[end_turn][/end_turn]
[/event]

# side 2 gets healing but not rest healing
[event]
name=side 2 turn 4 refresh
{EXPECT_HITPOINTS 27 3 37 5}
[end_turn][/end_turn]
[/event]

[event]
name=turn 5
{SUCCEED}
[/event]

)}
2 changes: 2 additions & 0 deletions wml_test_schedule
Expand Up @@ -205,3 +205,5 @@
0 order_of_variable_events1
1 order_of_variable_events2
0 event_name_variable_substitution
# Game mechanics
0 heal

0 comments on commit 2f62302

Please sign in to comment.