diff --git a/data/test/scenarios/backstab.cfg b/data/test/scenarios/backstab.cfg new file mode 100644 index 00000000000..c35f77d9fbf --- /dev/null +++ b/data/test/scenarios/backstab.cfg @@ -0,0 +1,103 @@ +# wmllint: no translatables +# Test that the backstab ability does double-damage, under the correct circumstances + +# Given a set of directions, create units on the opposite directions around +# Bob's starting location. Note: the order that they spawn might not match the +# order in the ANTIDIRECTIONS argument. +# +# The first unit spawned then attacks Bob, and we check that the +# EXPECTED_DAMAGE was inflicted. +# +# Any commands in EXTRA_SETUP can access the new units via the spawn_points +# array. +#define TEST_BACKSTAB NAME ANTIDIRECTIONS EXPECTED_DAMAGE EXTRA_SETUP +{GENERIC_UNIT_TEST {NAME} ( + [event] + # Using this event instead of "start" because units get healed after "start", which makes debugging more confusing + name=side 1 turn 1 + + # Give Bob enough hitpoints to survive, but put him on bad terrain to give a 100% chance to be hit + [modify_unit] + [filter] + id=bob + [/filter] + hitpoints=100 + [/modify_unit] + [terrain] + location_id=2 + terrain="Xv" + [/terrain] + + # Spawn enemies + [store_locations] + [filter_adjacent_location] + location_id=2 + adjacent={ANTIDIRECTIONS} + [/filter_adjacent_location] + variable=spawn_points + [/store_locations] + [foreach] + array=spawn_points + [do] + # Use the L2 unit, because a Thief might be killed by Bob's counterattack + {NOTRAIT_UNIT 1 Rogue $this_item.x $this_item.y} + [/do] + [/foreach] + + {EXTRA_SETUP} + + [store_locations] + location_id=2 + variable=bob_location + [/store_locations] + [do_command] + [attack] + weapon=0 + defender_weapon=0 + [source] + x=$spawn_points[0].x + y=$spawn_points[0].y + [/source] + [destination] + x=$bob_location[0].x + y=$bob_location[0].y + [/destination] + [/attack] + [/do_command] + + [store_unit] + [filter] + id=bob + [/filter] + variable=b + [/store_unit] + {ASSERT ({VARIABLE_CONDITIONAL b.hitpoints equals "$(100 - {EXPECTED_DAMAGE})"})} + + {CLEAR_VARIABLE b} + {CLEAR_VARIABLE spawn_points} + + {SUCCEED} + [/event] +)} +#enddef + +# The test uses a Rogue to do the attack, which does 6x3 damage before the ability is applied +{TEST_BACKSTAB "backstab_simple" "n,s" (6 * 3 * 2) ()} +{TEST_BACKSTAB "backstab_without_enemy_behind" "n,se,sw" (6 * 3 * 1) ()} +{TEST_BACKSTAB "backstab_with_statue_behind" "n,s" (6 * 3 * 1) ( + [petrify] + x=$spawn_points[1].x + y=$spawn_points[1].y + [/petrify] +)} +{TEST_BACKSTAB "backstab_with_ally_behind" "n,s" (6 * 3 * 1) ( + [modify_unit] + [filter] + x=$spawn_points[1].x + y=$spawn_points[1].y + [/filter] + side=2 + [/modify_unit] +)} + +#undef TEST_BACKSTAB diff --git a/data/test/scenarios/feeding.cfg b/data/test/scenarios/feeding.cfg index 9467dfe222c..6c29a1bbdae 100644 --- a/data/test/scenarios/feeding.cfg +++ b/data/test/scenarios/feeding.cfg @@ -1,3 +1,4 @@ +# wmllint: no translatables # This unit test defines a WML object based implementation of the "feeding" ability # and checks that it works. What is being tested here, beyond what is tested in # test_unit_map and other scenarios that test the attack pathway, is that @@ -41,6 +42,7 @@ {VARIABLE Killer_start_hp $Killer.hitpoints} + # Force 100% chance to hit by putting the victim on bad terrain [terrain] x,y=$victim_x|,$victim_y| terrain="Xv" @@ -166,3 +168,8 @@ {SUCCEED} [/event] )} + +#undef TEST_FEEDING +#undef STR_FEEDING_DESCRIPTION +#undef STR_FEEDING_EFFECT +#undef STR_FEEDING diff --git a/wml_test_schedule b/wml_test_schedule index f8e04429c02..59e1c758c35 100644 --- a/wml_test_schedule +++ b/wml_test_schedule @@ -238,6 +238,10 @@ 0 test_time_area_prestart 0 test_berzerk_firststrike 0 feeding +0 backstab_simple +0 backstab_without_enemy_behind +0 backstab_with_statue_behind +0 backstab_with_ally_behind 0 swarm_disables_upgrades 0 swarm_disables_upgrades_with_abilities 0 swarm_disables_upgrades_with_abilities_fail