add a bunch of attacks tests

This commit is contained in:
pentarctagon 2024-01-05 09:40:03 -06:00 committed by Pentarctagon
parent 1930008332
commit 26de1195e3
38 changed files with 1221 additions and 0 deletions

View File

@ -78,6 +78,7 @@
{test/scenarios/wml_tests/TerrainWML}
{test/scenarios/wml_tests/UnitsWML}
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML}
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/attacks}
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heals}
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/hides}
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/illuminates}

View File

@ -153,3 +153,96 @@ bob#endarg
{CLEAR_VARIABLE temp}
#enddef
# checks the number of strikes of all weapons a unit has
# they are expected to have the same number of strikes on all weapons
#define CHECK_STRIKES WEAPONS STRIKES RESULT
#arg ID1
alice#endarg
#arg ID2
bob#endarg
#arg COMPARE
numerical_equals#endarg
[event]
name = start
[modify_unit]
[filter]
id={ID1},{ID2}
[/filter]
[effect]
apply_to=attack
[set_specials]
mode=append
[damage]
value=1
[/damage]
[chance_to_hit]
value=100
[/chance_to_hit]
[/set_specials]
[/effect]
[/modify_unit]
{VARIABLE {ID1}_{ID2}_count 0}
[for]
variable=i
start=0
step=1
end="$({WEAPONS}-1)"
[do]
[test_do_attack_by_id]
attacker={ID1}
defender={ID2}
weapon=$i
resupply_attacks_left=5
[/test_do_attack_by_id]
[/do]
[/for]
[/event]
[event]
name=pre attack
first_time_only=no
[filter]
id={ID1}
[/filter]
{VARIABLE {ID1}_{ID2}_strikes 0}
[/event]
[event]
name=attacker hits, attacker misses
first_time_only=no
[filter]
id={ID1}
[/filter]
{VARIABLE_OP {ID1}_{ID2}_strikes add 1}
[/event]
[event]
name=attack end
first_time_only=no
[filter]
id={ID1}
[/filter]
{ASSERT {VARIABLE_CONDITIONAL {ID1}_{ID2}_strikes {COMPARE} {STRIKES}}}
{VARIABLE_OP {ID1}_{ID2}_count add 1}
[if]
{VARIABLE_CONDITIONAL {ID1}_{ID2}_count numerical_equals {WEAPONS}}
[then]
{RESULT}
[/then]
[/if]
[/event]
#enddef

View File

@ -0,0 +1,30 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with both the value and add attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons each of which now has 6 strikes (5+1)
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_add" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 5 (add=1) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 6 ({SUCCEED})}
)}

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with both the value, add, and divide attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons each of which now has 3 strikes ((5+1)/2)
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_add_divide" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 5 (add=1
divide=2) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 3 ({SUCCEED})}
)}

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with both the value, add, and multiply attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons each of which now has 12 strikes ((5+1)*2)
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_add_multiply" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 5 (add=1
multiply=2) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 12 ({SUCCEED})}
)}

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with both the value, add, and sub attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons each of which now has 3 strikes (5-2), add is ignored
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_add_sub" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 5 (add=1
sub=2) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 3 ({SUCCEED})}
)}

View File

@ -0,0 +1,39 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]affect_allies=
##
# Actions:
# Give the side 1 leader an attacks 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:
# The side 2 leader has 2 weapons each of which now has 5 strikes
# The side 1 leader has two weapons neither of which has been modified to have 5 strikes
#####
{COMMON_KEEP_A_B_C_D_UNIT_TEST "attacks_affect_allies" (
[event]
name = start
[modify_side]
side=1,2
team_name=allies
[/modify_side]
[modify_unit]
[filter]
side=1
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 5 ([affect_adjacent][/affect_adjacent]) ALLIES=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 5 () ID1=bob ID2=charlie}
{CHECK_STRIKES 2 5 ({SUCCEED}) ID1=alice ID2=dave COMPARE=numerical_not_equals}
) SIDE_LEADER="Elvish Archer"}

View File

@ -0,0 +1,34 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]affect_enemies=
##
# Actions:
# Give the side 1 leader an attacks ability that only affects adjacent enemies
# Have the side 2 leader attack the side 1 leader with both its weapons
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 2 leader has 2 weapons each of which now has 5 strikes
# The side 1 leader has two weapons neither of which has been modified to have 5 strikes
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_affect_enemies" (
[event]
name = start
[modify_unit]
[filter]
side=1
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 5 ([affect_adjacent][/affect_adjacent]) ENEMIES=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 5 () COMPARE=numerical_not_equals}
{CHECK_STRIKES 2 5 ({SUCCEED}) ID1=bob ID2=alice}
) SIDE2_LEADER="Elvish Archer"}

View File

@ -0,0 +1,43 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]affect_allies=
##
# Actions:
# Give the side 1 leader an attacks 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:
# The side 1 leader has 2 weapons each of which now has 5 strikes
# The side 2 leader has 2 weapons each of which now has 5 strikes
# The side 4 leader has 2 weapons each of which now has 5 strikes
#####
{COMMON_KEEP_A_B_C_D_UNIT_TEST "attacks_affect_everybody" (
[event]
name = start
[modify_side]
side=1,2
team_name=allies
[/modify_side]
[modify_unit]
[filter]
side = 1
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 5 ([affect_adjacent][/affect_adjacent]) ENEMIES=yes SELF=yes ALLIES=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 5 () ID1=alice ID2=charlie}
{CHECK_STRIKES 2 5 () ID1=bob ID2=dave}
{CHECK_STRIKES 2 5 ({SUCCEED}) ID1=dave ID2=alice}
) SIDE_LEADER="Elvish Archer"}

View File

@ -0,0 +1,30 @@
# 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:
# The side 1 leader has 2 weapons neither of which has 5 strikes
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_affect_self_no" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 5 ()}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 5 ({SUCCEED}) COMPARE=numerical_not_equals}
)}

View File

@ -0,0 +1,30 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with both the value and divide attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 3 strikes
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_divide" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 6 (divide=2) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 3 ({SUCCEED})}
)}

View File

@ -0,0 +1,32 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with a value of 3.8.
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 3 strikes
#####
#ifndef SCHEMA_VALIDATION
{COMMON_KEEP_A_B_UNIT_TEST "attacks_high_fraction" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 3.8 () SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 3 ({SUCCEED})}
)}
#endif

View File

@ -0,0 +1,32 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with a value of 3.2.
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 3 strikes
#####
#ifndef SCHEMA_VALIDATION
{COMMON_KEEP_A_B_UNIT_TEST "attacks_low_fraction" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 3.2 () SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 3 ({SUCCEED})}
)}
#endif

View File

@ -0,0 +1,33 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with both the value and add attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# max_value does nothing.
# The side 1 leader has 2 weapons both of which have 3 strikes
#####
#ifndef SCHEMA_VALIDATION
{COMMON_KEEP_A_B_UNIT_TEST "attacks_max_value" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 3 (max_value=1) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 3 ({SUCCEED})}
)}
#endif

View File

@ -0,0 +1,30 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with both the value and multiply attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 8 strikes (2*4)
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_multiply" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 4 (multiply=2) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 8 ({SUCCEED})}
)}

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with both the value, multiply, and divide attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 6 strikes ((4*3)/2)
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_multiply_divide" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 4 (multiply=3
divide=2) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 6 ({SUCCEED})}
)}

View File

@ -0,0 +1,32 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with both the value and multiply attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 4 strikes (2*2, the .5 is truncated)
#####
#ifndef SCHEMA_VALIDATION
{COMMON_KEEP_A_B_UNIT_TEST "attacks_multiply_fraction" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 2.5 (multiply=2) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 4 ({SUCCEED})}
)}
#endif

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with a value of -10.
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The number of strikes is not changed.
# Errors are logged about the negative value for strikes.
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_negative_value" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks -10 () SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 -10 ({SUCCEED}) COMPARE=numerical_not_equals}
)}

View File

@ -0,0 +1,38 @@
#textdomain wesnoth-test
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability missing the value attribute.
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The number of strikes is not changed.
# No errors are logged.
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_no_value" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
[attacks]
id = "test-attacks"
name = _"test-attacks"
affect_self = yes
affect_allies = no
affect_enemies = no
cumulative = no
[/attacks]
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 5 ({SUCCEED}) COMPARE=numerical_not_equals}
)}

View File

@ -0,0 +1,33 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]overwrite_specials=
##
# Actions:
# Give the side 1 leader an attacks ability with the overwrite_specials=both_sides attribute
# Give the side 1 leader an attacks ability without the overwrite_specials attribute
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons each of which now has 5 strikes, since the 5 strike ability takes priority due to overwrite_specials
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_overwrite_specials_both_sides" (
[event]
name = start
[modify_unit]
[filter]
side=1
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 5 (overwrite_specials=both_sides) SELF=yes}
{TEST_ABILITY attacks 7 () SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 5 ({SUCCEED})}
)}

View File

@ -0,0 +1,33 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]overwrite_specials=
##
# Actions:
# Give the side 1 leader an attacks ability with the overwrite_specials=one_side attribute
# Give the side 1 leader another attacks ability with the overwrite_specials=both_sides attribute
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons each of which now has 7 strikes, since the the higher value ability is used
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_overwrite_specials_mixed" (
[event]
name = start
[modify_unit]
[filter]
side=1
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 5 (overwrite_specials=one_side) SELF=yes}
{TEST_ABILITY attacks 7 (overwrite_specials=both_sides) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 7 ({SUCCEED})}
)}

View File

@ -0,0 +1,33 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]overwrite_specials=
##
# Actions:
# Give the side 1 leader an attacks ability with the overwrite_specials=one_side attribute
# Give the side 1 leader an attacks ability without the overwrite_specials attribute
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons each of which now has 5 strikes, since the 5 strike ability takes priority due to overwrite_specials
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_overwrite_specials_one_side" (
[event]
name = start
[modify_unit]
[filter]
side=1
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 5 (overwrite_specials=one_side) SELF=yes}
{TEST_ABILITY attacks 7 () SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 5 ({SUCCEED})}
)}

View File

@ -0,0 +1,33 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]overwrite_specials=
##
# Actions:
# Give the side 1 leader an attacks ability with the overwrite_specials=both_sides attribute
# Give the side 1 leader another attacks ability with the overwrite_specials=both_sides attribute
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons each of which now has 7 strikes, since the the higher value ability is used
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_overwrite_specials_two_both_sides" (
[event]
name = start
[modify_unit]
[filter]
side=1
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 7 (overwrite_specials=both_sides) SELF=yes}
{TEST_ABILITY attacks 5 (overwrite_specials=both_sides) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 7 ({SUCCEED})}
)}

View File

@ -0,0 +1,33 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]overwrite_specials=
##
# Actions:
# Give the side 1 leader an attacks ability with the overwrite_specials=one_side attribute
# Give the side 1 leader another attacks ability with the overwrite_specials=one_side attribute
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons each of which now has 7 strikes, since the the higher value ability is used
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_overwrite_specials_two_one_side" (
[event]
name = start
[modify_unit]
[filter]
side=1
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 5 (overwrite_specials=one_side) SELF=yes}
{TEST_ABILITY attacks 7 (overwrite_specials=one_side) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 7 ({SUCCEED})}
)}

View File

@ -0,0 +1,30 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with both the value and sub attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 1 strike (3-2)
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_sub" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 3 (sub=2) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 1 ({SUCCEED})}
)}

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with both the value, sub, and divide attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 1 strike ((3-1)/2)
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_sub_divide" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 3 (sub=1
divide=2) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 1 ({SUCCEED})}
)}

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with both the value, sub, and multiply attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 4 strikes ((3-1)*2)
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_sub_multiply" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 3 (sub=1
multiply=2) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 4 ({SUCCEED})}
)}

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]cumulative=
##
# Actions:
# Give the leaders an attacks ability with non-unique IDs, one with cumulative=yes, and one with cumulative=no
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 6 strikes
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_two_cumulative_mixed_same_id" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 6 () ID=1 CUMULATIVE=yes SELF=yes}
{TEST_ABILITY attacks 4 () ID=1 CUMULATIVE=no SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 6 ({SUCCEED})}
)}

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]cumulative=
##
# Actions:
# Give the leaders an attacks ability with unique IDs, one with cumulative=yes, and one with cumulative=no
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 6 strikes
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_two_cumulative_mixed_unique_id" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 6 () ID=1 CUMULATIVE=yes SELF=yes}
{TEST_ABILITY attacks 4 () ID=2 CUMULATIVE=no SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 6 ({SUCCEED})}
)}

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]cumulative=
##
# Actions:
# Give the leaders an attacks ability with non-unique IDs and cumulative=no
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 6 strikes
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_two_cumulative_no_same_id" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 6 () ID=1 CUMULATIVE=no SELF=yes}
{TEST_ABILITY attacks 4 () ID=1 CUMULATIVE=no SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 6 ({SUCCEED})}
)}

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]cumulative=
##
# Actions:
# Give the leaders an attacks ability with unique IDs and cumulative=no
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 6 strikes
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_two_cumulative_no_unique_id" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 6 () ID=1 CUMULATIVE=no SELF=yes}
{TEST_ABILITY attacks 4 () ID=2 CUMULATIVE=no SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 6 ({SUCCEED})}
)}

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]cumulative=
##
# Actions:
# Give the leaders an attacks ability with non-unique IDs and cumulative=yes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 6 strikes
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_two_cumulative_yes_same_id" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 6 () ID=1 CUMULATIVE=yes SELF=yes}
{TEST_ABILITY attacks 4 () ID=1 CUMULATIVE=yes SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 6 ({SUCCEED})}
)}

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]cumulative=
##
# Actions:
# Give the leaders an attacks ability with unique IDs and cumulative=yes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 6 strikes
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_two_cumulative_yes_unique_id" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 6 () ID=1 CUMULATIVE=yes SELF=yes}
{TEST_ABILITY attacks 4 () ID=2 CUMULATIVE=yes SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 6 ({SUCCEED})}
)}

View File

@ -0,0 +1,30 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability that gives a quarter of the max hp of the other unit as strikes.
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 7 strikes (29/4), other is the attacker
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_wfl_other" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks "(other.max_hitpoints/4)" () SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 7 ({SUCCEED})}
)}

View File

@ -0,0 +1,30 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability that attacks half its own max hp.
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which have 7 strikes (29/4), self is the attacker
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_wfl_self" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks "(max_hitpoints/4)" () SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 7 ({SUCCEED})}
)}

View File

@ -0,0 +1,31 @@
# wmllint: no translatables
#####
# API(s) being tested: [attacks]value=
##
# Actions:
# Give the leaders an attacks ability with a value of 0.
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The side 1 leader has 2 weapons both of which don't have 0 strikes
# No errors are logged
#####
{COMMON_KEEP_A_B_UNIT_TEST "attacks_zero" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY attacks 0 ()}
[/abilities]
[/effect]
[/modify_unit]
[/event]
{CHECK_STRIKES 2 0 ({SUCCEED}) COMPARE=numerical_not_equals}
)}

View File

@ -22,6 +22,7 @@
[modify_unit]
[filter]
side=1
[/filter]
[effect]
apply_to = new_ability

View File

@ -675,6 +675,40 @@
0 tunnel_target_teleport_unit_succeed
0 tunnel_source_teleport_unit_fail
0 tunnel_source_teleport_unit_succeed
# attacks ability tests
9 attacks_negative_value
0 attacks_zero
0 attacks_add
0 attacks_add_divide
0 attacks_add_multiply
0 attacks_add_sub
0 attacks_affect_self_no
0 attacks_affect_enemies
0 attacks_affect_everybody
0 attacks_divide
0 attacks_high_fraction
0 attacks_low_fraction
0 attacks_multiply
0 attacks_multiply_divide
0 attacks_multiply_fraction
0 attacks_no_value
0 attacks_sub
0 attacks_sub_divide
0 attacks_sub_multiply
0 attacks_wfl_other
0 attacks_wfl_self
0 attacks_two_cumulative_yes_same_id
0 attacks_two_cumulative_yes_unique_id
0 attacks_two_cumulative_no_same_id
0 attacks_two_cumulative_no_unique_id
0 attacks_two_cumulative_mixed_same_id
0 attacks_two_cumulative_mixed_unique_id
0 attacks_max_value
0 attacks_overwrite_specials_one_side
0 attacks_overwrite_specials_both_sides
0 attacks_overwrite_specials_two_both_sides
0 attacks_overwrite_specials_two_one_side
0 attacks_overwrite_specials_mixed
# Warnings about WML
0 unknown_scenario_false_positives
0 unknown_scenario_interpolated