firststrike tests

This commit is contained in:
pentarctagon 2024-08-28 18:15:11 -05:00 committed by Pentarctagon
parent 41f87afaf7
commit f22fb410a3
7 changed files with 714 additions and 0 deletions

View file

@ -85,6 +85,7 @@
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/damage_type}
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/disable}
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/drains}
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/firststrike}
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heals}
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/hides}
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/illuminates}

View file

@ -0,0 +1,101 @@
#textdomain wesnoth-test
#####
# API(s) being tested: [firststrike]
##
# Actions:
# Give bob a firststrike ability
##
# Expected end state:
# At time of checking, only side 1 has been struck but side 2 has not been struck
#####
{COMMON_KEEP_A_B_UNIT_TEST "firststrike_ability" (
[event]
name = start
{VARIABLE is_event 0}
[modify_unit]
[filter]
id = bob
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY_NO_VALUE firststrike () SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[modify_unit]
[filter]
id=alice,bob
[/filter]
[effect]
apply_to=attack
[set_specials]
mode=append
[attacks]
value=1
[/attacks]
[damage]
value=1
[/damage]
[chance_to_hit]
value=100
[/chance_to_hit]
[/set_specials]
[/effect]
[/modify_unit]
[test_do_attack_by_id]
attacker=alice
defender=bob
weapon=0
resupply_attacks_left=1
[/test_do_attack_by_id]
[heal_unit]
[filter]
[/filter]
amount = "full"
[/heal_unit]
[test_do_attack_by_id]
attacker=alice
defender=bob
weapon=1
resupply_attacks_left=1
[/test_do_attack_by_id]
{ASSERT {VARIABLE_CONDITIONAL is_event numerical_equals 1}}
{SUCCEED}
[/event]
[event]
name = defender hits
first_time_only = no
{VARIABLE is_event 1}
[store_unit]
[filter]
id=alice
[/filter]
variable=alice
[/store_unit]
[store_unit]
[filter]
id=bob
[/filter]
variable=bob
[/store_unit]
{ASSERT {VARIABLE_CONDITIONAL alice.hitpoints numerical_equals "$($alice.max_hitpoints-1)"}}
{ASSERT {VARIABLE_CONDITIONAL bob.hitpoints numerical_equals $bob.max_hitpoints}}
{CLEAR_VARIABLE alice}
{CLEAR_VARIABLE bob}
[/event]
) SIDE2_LEADER="Elvish Archer"}

View file

@ -0,0 +1,167 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]affect_allies=
##
# Actions:
# Give the side 1 leader a firststrike ability that only affects adjacent allies
# Have the side 2 leader attack the side 3 leader with both its weapons
# Have the side 1 leader attack the side 4 leader with both its weapons
##
# Expected end state:
# At time of checking, both side 1 and side 4 have been struck
# At time of checking, only side 3 has been struck but side 2 has not been struck
#####
{COMMON_KEEP_A_B_C_D_UNIT_TEST "firststrike_affect_allies" (
[event]
name = start
{VARIABLE no_firststrike 0}
{VARIABLE is_firststrike 0}
[modify_side]
side=1,2
team_name=allies
[/modify_side]
[modify_unit]
[filter]
id=alice
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY_NO_VALUE firststrike ([affect_adjacent][/affect_adjacent]) ALLIES=yes}
[/abilities]
[/effect]
[/modify_unit]
[modify_unit]
[filter]
id=alice,bob,charlie,dave
[/filter]
[effect]
apply_to=attack
[set_specials]
mode=append
[attacks]
value=1
[/attacks]
[damage]
value=1
[/damage]
[chance_to_hit]
value=100
[/chance_to_hit]
[/set_specials]
[/effect]
[/modify_unit]
[test_do_attack_by_id]
attacker=alice
defender=dave
weapon=0
resupply_attacks_left=1
[/test_do_attack_by_id]
[heal_unit]
[filter]
[/filter]
amount = "full"
[/heal_unit]
[test_do_attack_by_id]
attacker=alice
defender=dave
weapon=1
resupply_attacks_left=1
[/test_do_attack_by_id]
[test_do_attack_by_id]
attacker=charlie
defender=bob
weapon=0
resupply_attacks_left=1
[/test_do_attack_by_id]
[heal_unit]
[filter]
[/filter]
amount = "full"
[/heal_unit]
[test_do_attack_by_id]
attacker=charlie
defender=bob
weapon=1
resupply_attacks_left=1
[/test_do_attack_by_id]
{ASSERT {VARIABLE_CONDITIONAL no_firststrike numerical_equals 1}}
{ASSERT {VARIABLE_CONDITIONAL is_firststrike numerical_equals 1}}
{SUCCEED}
[/event]
# defender dave does not have firststrike, therefore alice and dave have now both been struck
[event]
name = defender hits
first_time_only = no
[filter_second]
id=dave
[/filter_second]
{VARIABLE no_firststrike 1}
[store_unit]
[filter]
id=alice
[/filter]
variable=alice
[/store_unit]
[store_unit]
[filter]
id=dave
[/filter]
variable=dave
[/store_unit]
{ASSERT {VARIABLE_CONDITIONAL dave.hitpoints numerical_equals "$($dave.max_hitpoints-1)"}}
{ASSERT {VARIABLE_CONDITIONAL alice.hitpoints numerical_equals "$($alice.max_hitpoints-1)"}}
{CLEAR_VARIABLE alice}
{CLEAR_VARIABLE dave}
[/event]
# defender bob does have firststrike, therefore charlie has already been struck and bob has not yet been struck
[event]
name = defender hits
first_time_only = no
[filter_second]
id=bob
[/filter_second]
{VARIABLE is_firststrike 1}
[store_unit]
[filter]
id=bob
[/filter]
variable=bob
[/store_unit]
[store_unit]
[filter]
id=charlie
[/filter]
variable=charlie
[/store_unit]
{ASSERT {VARIABLE_CONDITIONAL bob.hitpoints numerical_equals $bob.max_hitpoints}}
{ASSERT {VARIABLE_CONDITIONAL charlie.hitpoints numerical_equals "$($charlie.max_hitpoints-1)"}}
{CLEAR_VARIABLE bob}
{CLEAR_VARIABLE charlie}
[/event]
) SIDE_LEADER="Elvish Archer"}

View file

@ -0,0 +1,102 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]affect_enemies=
##
# Actions:
# Give the side 1 leader a firststrike ability that only affects adjacent enemies
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# At time of checking, only side 1 has been struck but side 2 has not been struck
#####
{COMMON_KEEP_A_B_UNIT_TEST "firststrike_affect_enemies" (
[event]
name = start
{VARIABLE is_event 0}
[modify_unit]
[filter]
id=alice
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY_NO_VALUE firststrike ([affect_adjacent][/affect_adjacent]) ENEMIES=yes}
[/abilities]
[/effect]
[/modify_unit]
[modify_unit]
[filter]
id=alice,bob
[/filter]
[effect]
apply_to=attack
[set_specials]
mode=append
[attacks]
value=1
[/attacks]
[damage]
value=1
[/damage]
[chance_to_hit]
value=100
[/chance_to_hit]
[/set_specials]
[/effect]
[/modify_unit]
[test_do_attack_by_id]
attacker=alice
defender=bob
weapon=0
resupply_attacks_left=1
[/test_do_attack_by_id]
[heal_unit]
[filter]
[/filter]
amount = "full"
[/heal_unit]
[test_do_attack_by_id]
attacker=alice
defender=bob
weapon=1
resupply_attacks_left=1
[/test_do_attack_by_id]
{ASSERT {VARIABLE_CONDITIONAL is_event numerical_equals 1}}
{SUCCEED}
[/event]
[event]
name = defender hits
first_time_only = no
{VARIABLE is_event 1}
[store_unit]
[filter]
id=alice
[/filter]
variable=alice
[/store_unit]
[store_unit]
[filter]
id=bob
[/filter]
variable=bob
[/store_unit]
{ASSERT {VARIABLE_CONDITIONAL alice.hitpoints numerical_equals "$($alice.max_hitpoints-1)"}}
{ASSERT {VARIABLE_CONDITIONAL bob.hitpoints numerical_equals $bob.max_hitpoints}}
{CLEAR_VARIABLE alice}
{CLEAR_VARIABLE bob}
[/event]
) SIDE2_LEADER="Elvish Archer"}

View file

@ -0,0 +1,236 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]affect_allies=
##
# Actions:
# Give the side 1 leader a firststrike ability with affect_allies, affect_enemies, and affect_self
# Make side 1 and side 2 allies
# Have the side 1 leader attack the side 3 leader with both its weapons
# Have the side 2 leader attack the side 4 leader with both its weapons
# Have the side 4 leader attack the side 1 leader with both its weapons
##
# Expected end state:
# All units have firststrike, therefore by the time of the defender hits event both attacker and defender have been damaged
#####
{COMMON_KEEP_A_B_C_D_UNIT_TEST "firststrike_affect_everybody" (
[event]
name = start
{VARIABLE is_event1 0}
{VARIABLE is_event2 0}
{VARIABLE is_event3 0}
[modify_side]
side=1,2
team_name=allies
[/modify_side]
[modify_unit]
[filter]
side = 1
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY_NO_VALUE firststrike ([affect_adjacent][/affect_adjacent]) ENEMIES=yes SELF=yes ALLIES=yes}
[/abilities]
[/effect]
[/modify_unit]
[modify_unit]
[filter]
id=alice,bob,charlie,dave
[/filter]
[effect]
apply_to=attack
[set_specials]
mode=append
[attacks]
value=1
[/attacks]
[damage]
value=1
[/damage]
[chance_to_hit]
value=100
[/chance_to_hit]
[/set_specials]
[/effect]
[/modify_unit]
# alice -> charlie
[test_do_attack_by_id]
attacker=alice
defender=charlie
weapon=0
resupply_attacks_left=1
[/test_do_attack_by_id]
[heal_unit]
[filter]
[/filter]
amount = "full"
[/heal_unit]
[test_do_attack_by_id]
attacker=alice
defender=charlie
weapon=1
resupply_attacks_left=1
[/test_do_attack_by_id]
[heal_unit]
[filter]
[/filter]
amount = "full"
[/heal_unit]
# bob -> dave
[test_do_attack_by_id]
attacker=bob
defender=dave
weapon=0
resupply_attacks_left=1
[/test_do_attack_by_id]
[heal_unit]
[filter]
[/filter]
amount = "full"
[/heal_unit]
[test_do_attack_by_id]
attacker=bob
defender=dave
weapon=1
resupply_attacks_left=1
[/test_do_attack_by_id]
[heal_unit]
[filter]
[/filter]
amount = "full"
[/heal_unit]
# dave -> alice
[test_do_attack_by_id]
attacker=dave
defender=alice
weapon=0
resupply_attacks_left=1
[/test_do_attack_by_id]
[heal_unit]
[filter]
[/filter]
amount = "full"
[/heal_unit]
[test_do_attack_by_id]
attacker=dave
defender=alice
weapon=1
resupply_attacks_left=1
[/test_do_attack_by_id]
{ASSERT {VARIABLE_CONDITIONAL is_event1 numerical_equals 1}}
{ASSERT {VARIABLE_CONDITIONAL is_event2 numerical_equals 1}}
{ASSERT {VARIABLE_CONDITIONAL is_event3 numerical_equals 1}}
{SUCCEED}
[/event]
# both have firststrike, therefore both have taken damage by this point
[event]
name = defender hits
first_time_only = no
[filter_second]
id=charlie
[/filter_second]
{VARIABLE is_event1 1}
[store_unit]
[filter]
id=alice
[/filter]
variable=alice
[/store_unit]
[store_unit]
[filter]
id=charlie
[/filter]
variable=charlie
[/store_unit]
{ASSERT {VARIABLE_CONDITIONAL charlie.hitpoints numerical_equals "$($charlie.max_hitpoints-1)"}}
{ASSERT {VARIABLE_CONDITIONAL alice.hitpoints numerical_equals "$($alice.max_hitpoints-1)"}}
{CLEAR_VARIABLE alice}
{CLEAR_VARIABLE charlie}
[/event]
# both have firststrike, therefore both have taken damage by this point
[event]
name = defender hits
first_time_only = no
[filter_second]
id=dave
[/filter_second]
{VARIABLE is_event2 1}
[store_unit]
[filter]
id=bob
[/filter]
variable=bob
[/store_unit]
[store_unit]
[filter]
id=dave
[/filter]
variable=dave
[/store_unit]
{ASSERT {VARIABLE_CONDITIONAL dave.hitpoints numerical_equals "$($dave.max_hitpoints-1)"}}
{ASSERT {VARIABLE_CONDITIONAL bob.hitpoints numerical_equals "$($bob.max_hitpoints-1)"}}
{CLEAR_VARIABLE bob}
{CLEAR_VARIABLE dave}
[/event]
# both have firststrike, therefore both have taken damage by this point
[event]
name = defender hits
first_time_only = no
[filter_second]
id=alice
[/filter_second]
{VARIABLE is_event3 1}
[store_unit]
[filter]
id=alice
[/filter]
variable=alice
[/store_unit]
[store_unit]
[filter]
id=dave
[/filter]
variable=dave
[/store_unit]
{ASSERT {VARIABLE_CONDITIONAL dave.hitpoints numerical_equals "$($dave.max_hitpoints-1)"}}
{ASSERT {VARIABLE_CONDITIONAL alice.hitpoints numerical_equals "$($alice.max_hitpoints-1)"}}
{CLEAR_VARIABLE alice}
{CLEAR_VARIABLE dave}
[/event]
) SIDE_LEADER="Elvish Archer"}

View file

@ -0,0 +1,101 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]affect_self=
##
# Actions:
# Give the leaders an attacks ability that doesn't affect themselves.
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# No units have firststrike, therefore by the time of the defender hits event both attacker and defender have been damaged
#####
{COMMON_KEEP_A_B_UNIT_TEST "firststrike_affect_self_no" (
[event]
name = start
{VARIABLE is_event 0}
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY_NO_VALUE firststrike ()}
[/abilities]
[/effect]
[/modify_unit]
[modify_unit]
[filter]
id=alice,bob
[/filter]
[effect]
apply_to=attack
[set_specials]
mode=append
[attacks]
value=1
[/attacks]
[damage]
value=1
[/damage]
[chance_to_hit]
value=100
[/chance_to_hit]
[/set_specials]
[/effect]
[/modify_unit]
[test_do_attack_by_id]
attacker=alice
defender=bob
weapon=0
resupply_attacks_left=1
[/test_do_attack_by_id]
[heal_unit]
[filter]
[/filter]
amount = "full"
[/heal_unit]
[test_do_attack_by_id]
attacker=alice
defender=bob
weapon=1
resupply_attacks_left=1
[/test_do_attack_by_id]
{ASSERT {VARIABLE_CONDITIONAL is_event numerical_equals 1}}
{SUCCEED}
[/event]
[event]
name = defender hits
first_time_only = no
{VARIABLE is_event 1}
[store_unit]
[filter]
id=alice
[/filter]
variable=alice
[/store_unit]
[store_unit]
[filter]
id=bob
[/filter]
variable=bob
[/store_unit]
{ASSERT {VARIABLE_CONDITIONAL alice.hitpoints numerical_equals "$($alice.max_hitpoints-1)"}}
{ASSERT {VARIABLE_CONDITIONAL bob.hitpoints numerical_equals "$($bob.max_hitpoints-1)"}}
{CLEAR_VARIABLE alice}
{CLEAR_VARIABLE bob}
[/event]
) SIDE2_LEADER="Elvish Archer"}

View file

@ -927,6 +927,12 @@
0 drains_overwrite_specials_two_both_sides
0 drains_overwrite_specials_two_one_side
0 drains_overwrite_specials_mixed
# firststrike tests
0 firststrike_ability
0 firststrike_affect_allies
0 firststrike_affect_self_no
0 firststrike_affect_enemies
0 firststrike_affect_everybody
# Warnings about WML
0 unknown_scenario_false_positives
0 unknown_scenario_interpolated