Skip to content

Commit

Permalink
firststrike tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pentarctagon committed Aug 29, 2024
1 parent 815739f commit 92783a6
Show file tree
Hide file tree
Showing 7 changed files with 714 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/test/_main.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
@@ -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"}
Original file line number Diff line number Diff line change
@@ -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"}
Original file line number Diff line number Diff line change
@@ -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"}
Loading

0 comments on commit 92783a6

Please sign in to comment.