Skip to content

Commit

Permalink
drains tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pentarctagon committed Aug 26, 2024
1 parent c1fd40c commit 815739f
Show file tree
Hide file tree
Showing 40 changed files with 1,295 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/test/_main.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/damage}
{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/heals}
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/hides}
{test/scenarios/wml_tests/UnitsWML/AbilitiesWML/illuminates}
Expand Down
6 changes: 5 additions & 1 deletion data/test/macros/wml_unit_test_macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
# DAMAGE1 is expected hp loss for ID1 (alice).
# DAMAGE2 is expected hp loss for ID2 (bob), it defaults to the same as DAMAGE1.
# WEAPON_COUNT is how many weapons to test, starting from the first.
# STRIKE_COUNT is how many strikes to make
# DAMAGE_VALUE is the contents of the [damage] ability to set the attack to the default of 100
# ID1_HP is the hitpoints and max_hitpoints for the ID1 unit to have
# ID2_HP is the hitpoints and max_hitpoints for the ID2 unit to have
Expand All @@ -154,6 +155,9 @@ bob#endarg
#arg WEAPON_COUNT
1#endarg

#arg STRIKE_COUNT
1#endarg

#arg ID1_HP
1000#endarg

Expand All @@ -175,7 +179,7 @@ bob#endarg
[set_specials]
mode=append
[attacks]
value=1
value={STRIKE_COUNT}
[/attacks]
{DAMAGE_VALUE}
[chance_to_hit]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# wmllint: no translatables

#####
# API(s) being tested: [drains]value=
##
# Actions:
# Give the leaders an drains 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 both leaders have 2 weapons each of which now drains 6 hp (5+1), add is ignored
# The leader of side 1 heals 6 hp total since it has full hp when its first strike is made
# The leader of side 2 heals 12 hp total since it was damaged when its first strike was made
#####
{COMMON_KEEP_A_B_UNIT_TEST "drains_add" (
[event]
name = start

[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY drains 5 (add=1) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]

{ATTACK_AND_VALIDATE 194 DAMAGE2=188 STRIKE_COUNT=2}
{SUCCEED}
[/event]
) SIDE2_LEADER="Elvish Archer"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# wmllint: no translatables

#####
# API(s) being tested: [drains]value=
##
# Actions:
# Give the leaders a drains ability with the value, add, and divide attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The both leaders have 2 weapons each of which now drains 3 hp ((5+1)/2)
# The leader of side 1 heals 3 hp total since it has full hp when its first strike is made
# The leader of side 2 heals 6 hp total since it was damaged when its first strike was made
#####
{COMMON_KEEP_A_B_UNIT_TEST "drains_add_divide" (
[event]
name = start

[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY drains 5 (add=1
divide=2) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]

{ATTACK_AND_VALIDATE 197 DAMAGE2=194 STRIKE_COUNT=2}
{SUCCEED}
[/event]
) SIDE2_LEADER="Elvish Archer"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# wmllint: no translatables

#####
# API(s) being tested: [drains]value=
##
# Actions:
# Give the leaders a drains ability with the value, add, and multiply attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The both leaders have 2 weapons each of which now drains 12 hp ((5+1)*2)
# The leader of side 1 heals 12 hp total since it has full hp when its first strike is made
# The leader of side 2 heals 24 hp total since it was damaged when its first strike was made
#####
{COMMON_KEEP_A_B_UNIT_TEST "drains_add_multiply" (
[event]
name = start

[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY drains 5 (add=1
multiply=2) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]

{ATTACK_AND_VALIDATE 188 DAMAGE2=176 STRIKE_COUNT=2}
{SUCCEED}
[/event]
) SIDE2_LEADER="Elvish Archer"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# wmllint: no translatables

#####
# API(s) being tested: [drains]value=
##
# Actions:
# Give the leaders a drains ability with the value, add, and sub attributes
# Have the side 1 leader attack the side 2 leader with both its weapons
##
# Expected end state:
# The both leaders have 2 weapons each of which now drains 3 hp (5-2), add is ignored
# The leader of side 1 heals 3 hp total since it has full hp when its first strike is made
# The leader of side 2 heals 6 hp total since it was damaged when its first strike was made
#####
{COMMON_KEEP_A_B_UNIT_TEST "drains_add_sub" (
[event]
name = start

[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY drains 5 (add=1
sub=2) SELF=yes}
[/abilities]
[/effect]
[/modify_unit]

{ATTACK_AND_VALIDATE 197 DAMAGE2=194 STRIKE_COUNT=2}
{SUCCEED}
[/event]
) SIDE2_LEADER="Elvish Archer"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# wmllint: no translatables

#####
# API(s) being tested: [drains]affect_allies=
##
# Actions:
# Give the side 1 leader a drains 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 all leaders have 2 weapons each of which now drains 2 hp
# The leader of side 2 heals 2 hp total since it has full hp when its first strike is made
# No other units are healed via drains
#####
{COMMON_KEEP_A_B_C_D_UNIT_TEST "drains_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 drains 2 ([affect_adjacent][/affect_adjacent]) ALLIES=yes}
[/abilities]
[/effect]
[/modify_unit]

{ATTACK_AND_VALIDATE 198 DAMAGE2=200 ID1=bob ID2=charlie WEAPON_COUNT=2 STRIKE_COUNT=2}
{ATTACK_AND_VALIDATE 200 ID1=alice ID2=dave WEAPON_COUNT=2 STRIKE_COUNT=2}
{SUCCEED}
[/event]
) SIDE_LEADER="Elvish Archer"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# wmllint: no translatables

#####
# API(s) being tested: [drains]affect_enemies=
##
# Actions:
# Give the side 1 leader a drains ability that only affects adjacent enemies
# 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 drains 2 hp
# The side 1 leader has 2 weapons neither of which has been modified to have drains
#####
{COMMON_KEEP_A_B_UNIT_TEST "drains_affect_enemies" (
[event]
name = start

[modify_unit]
[filter]
side=1
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY drains 2 ([affect_adjacent][/affect_adjacent]) ENEMIES=yes}
[/abilities]
[/effect]
[/modify_unit]

{ATTACK_AND_VALIDATE 200 DAMAGE2=196 WEAPON_COUNT=2 STRIKE_COUNT=2}
{SUCCEED}
[/event]
) SIDE2_LEADER="Elvish Archer"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# wmllint: no translatables

#####
# API(s) being tested: [drains]affect_allies=
##
# Actions:
# Give the side 1 leader a drains 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 drains 2 hp
# The side 2 leader has 2 weapons each of which now has drains 2 hp
# The side 4 leader has 2 weapons each of which now has drains 2 hp
#####
{COMMON_KEEP_A_B_C_D_UNIT_TEST "drains_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 drains 2 ([affect_adjacent][/affect_adjacent]) ENEMIES=yes SELF=yes ALLIES=yes}
[/abilities]
[/effect]
[/modify_unit]

{ATTACK_AND_VALIDATE 198 DAMAGE2=196 ID1=alice ID2=charlie WEAPON_COUNT=2 STRIKE_COUNT=2}
{ATTACK_AND_VALIDATE 198 DAMAGE2=196 ID1=bob ID2=dave WEAPON_COUNT=2 STRIKE_COUNT=2}
{ATTACK_AND_VALIDATE 198 DAMAGE2=196 ID1=dave ID2=alice WEAPON_COUNT=2 STRIKE_COUNT=2}
{SUCCEED}
[/event]
) SIDE_LEADER="Elvish Archer"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# wmllint: no translatables

#####
# API(s) being tested: [drains]affect_self=
##
# Actions:
# Give the leaders a drains 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 drains
#####
{COMMON_KEEP_A_B_UNIT_TEST "drains_affect_self_no" (
[event]
name = start

[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY drains 2 ()}
[/abilities]
[/effect]
[/modify_unit]

{ATTACK_AND_VALIDATE 200 WEAPON_COUNT=2 STRIKE_COUNT=2}
{SUCCEED}
[/event]
) SIDE2_LEADER="Elvish Archer"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# wmllint: no translatables

#####
# API(s) being tested: [drains]cumulative=
##
# Actions:
# Give the leaders a drains ability with non-unique IDs, one with cumulative=yes, and one with cumulative=no
# The drains abilities give a lower value than drains' default of 50% gives
# 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 drain 50 hp (50% of 100), since the 50% default gives a higher value
#####
{COMMON_KEEP_A_B_UNIT_TEST "drains_default_cumulative_both" (
[event]
name = start

[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY drains 40 () ID=1 CUMULATIVE=yes SELF=yes}
{TEST_ABILITY drains 30 () ID=1 CUMULATIVE=no SELF=yes}
[/abilities]
[/effect]
[/modify_unit]

{ATTACK_AND_VALIDATE 150 DAMAGE2=100 WEAPON_COUNT=2 STRIKE_COUNT=2}
{SUCCEED}
[/event]
) SIDE2_LEADER="Elvish Archer"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# wmllint: no translatables

#####
# API(s) being tested: [drains]cumulative=
##
# Actions:
# Give the leaders a drains ability with non-unique IDs with cumulative=no
# The drains abilities give a lower value than drains' default of 50% gives
# 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 drain 30 hp, using the value of the cumulative=no ability even though it's lower
#####
{COMMON_KEEP_A_B_UNIT_TEST "drains_default_cumulative_no" (
[event]
name = start

[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY drains 30 () ID=1 CUMULATIVE=no SELF=yes}
[/abilities]
[/effect]
[/modify_unit]

{ATTACK_AND_VALIDATE 170 DAMAGE2=140 WEAPON_COUNT=2 STRIKE_COUNT=2}
{SUCCEED}
[/event]
) SIDE2_LEADER="Elvish Archer"}
Loading

0 comments on commit 815739f

Please sign in to comment.