Unit test cumulative resistance with a base value

These tests clarify what "cumulative" means for non-leadership abilites,
which since Wesnoth 1.1.3 doesn't seem to fit the English word.

For cumulative abilities, if the base value from the unit is higher that
the ability's value, then the base value is used instead. In the case of
a Skeleton with 40% base resistance, "cumulative=yes" is equivalent to
"value,cumulative=40,no".

In all of these cases, a single ability's value is used; "cumulative"
doesn't mean that the values from multiple abilities interact.

This is all when using value=, not when using add= or sub=.

(cherry picked from commit 9b2016a4af)
This commit is contained in:
Steve Cotton 2024-04-11 04:15:16 +02:00 committed by Steve Cotton
parent 51e568ff1c
commit 3fb8a91bc6
5 changed files with 109 additions and 1 deletions

View file

@ -6,7 +6,7 @@
# Actions:
# Give all units 20% resistance to all damage types with cumulative=yes
# Give all units 30% resistance to all damage types with cumulative=no
# Both abilities have the a unique id
# Both abilities have a unique id
# Attack each other
##
# Expected end state:

View file

@ -0,0 +1,35 @@
# wmllint: no translatables
#####
# API(s) being tested: [resistance]cumulative=
##
# Actions:
# Both units are Skeletons, with a blade attack and 40% resistance to blade
# Give all units 20% resistance to all damage types with cumulative=yes
# Give all units 30% resistance to all damage types with cumulative=no
# Both abilities have a unique id
# Attack each other
##
# Expected end state:
# The damage from the attack is reduced by 40%
#####
{COMMON_KEEP_A_B_UNIT_TEST "resistance_two_cumulative_mixed_unique_id_skeletal" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY resistance 20 (max_value=100) ID=1 CUMULATIVE=yes SELF=yes}
{TEST_ABILITY resistance 30 (max_value=100) ID=2 CUMULATIVE=no SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
{ATTACK_AND_VALIDATE 60}
{SUCCEED}
[/event]
) SIDE1_LEADER=Skeleton SIDE2_LEADER=Skeleton}

View file

@ -0,0 +1,35 @@
# wmllint: no translatables
#####
# API(s) being tested: [resistance]cumulative=
##
# Actions:
# Both units are Skeletons, with a blade attack and 40% resistance to blade
# Give all units 20% resistance to all damage types with cumulative=no
# Give all units 30% resistance to all damage types with cumulative=no
# Both abilities have unique ids
# Attack each other
##
# Expected end state:
# The damage from the attack is reduced by 30%
#####
{COMMON_KEEP_A_B_UNIT_TEST "resistance_two_cumulative_no_unique_id_skeletal" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY resistance 20 (max_value=100) ID=1 CUMULATIVE=no SELF=yes}
{TEST_ABILITY resistance 30 (max_value=100) ID=2 CUMULATIVE=no SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
{ATTACK_AND_VALIDATE 70}
{SUCCEED}
[/event]
) SIDE1_LEADER=Skeleton SIDE2_LEADER=Skeleton}

View file

@ -0,0 +1,35 @@
# wmllint: no translatables
#####
# API(s) being tested: [resistance]cumulative=
##
# Actions:
# Both units are Skeletons, with a blade attack and 40% resistance to blade
# Give all units 20% resistance to all damage types with cumulative=yes
# Give all units 30% resistance to all damage types with cumulative=yes
# Both abilities have unique ids
# Attack each other
##
# Expected end state:
# The damage from the attack is reduced by 40%
#####
{COMMON_KEEP_A_B_UNIT_TEST "resistance_two_cumulative_yes_unique_id_skeletal" (
[event]
name = start
[modify_unit]
[filter]
[/filter]
[effect]
apply_to = new_ability
[abilities]
{TEST_ABILITY resistance 20 (max_value=100) ID=1 CUMULATIVE=yes SELF=yes}
{TEST_ABILITY resistance 30 (max_value=100) ID=2 CUMULATIVE=yes SELF=yes}
[/abilities]
[/effect]
[/modify_unit]
{ATTACK_AND_VALIDATE 60}
{SUCCEED}
[/event]
) SIDE1_LEADER=Skeleton SIDE2_LEADER=Skeleton}

View file

@ -596,10 +596,13 @@
0 resistance_wfl_self
0 resistance_two_cumulative_yes_same_id
0 resistance_two_cumulative_yes_unique_id
0 resistance_two_cumulative_yes_unique_id_skeletal
0 resistance_two_cumulative_no_same_id
0 resistance_two_cumulative_no_unique_id
0 resistance_two_cumulative_no_unique_id_skeletal
0 resistance_two_cumulative_mixed_same_id
0 resistance_two_cumulative_mixed_unique_id
0 resistance_two_cumulative_mixed_unique_id_skeletal
0 resistance_max_value
0 resistance_min_value
0 resistance_negative_max_value