mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-02 18:05:39 +00:00

Changes: * CHECK_STRIKES macro now takes a comma-delimited list of strike counts for when units have a different number of strikes for different weapons, and updates the existing usage in the attacks tests * Fixed a typo in the attacks_zero test * Adds tests for berserk as a weapon special ability. Berserk's handling differs from attacks as a weapon special ability: * A value less than 1 is treated as effectively infinite rounds of combat (undocumented) * The cumulative attribute is handled differently - in some cases it sums the values instead of using the highest single value whereas for attacks it always uses the highest single value Also now exclude data/tests/ from scons pot-update since it was hitting the argument limit for number of arguments to a script.
275 lines
6.6 KiB
INI
275 lines
6.6 KiB
INI
#textdomain wesnoth-test
|
||
#define RETURN X
|
||
[if]
|
||
[variable]
|
||
name=ended
|
||
boolean_not_equals=yes
|
||
[/variable]
|
||
[then]
|
||
[if]
|
||
{X}
|
||
[then]
|
||
{VARIABLE ended yes}
|
||
[endlevel]
|
||
test_result=pass
|
||
linger_mode = yes
|
||
[/endlevel]
|
||
[/then]
|
||
[else]
|
||
[test_condition]
|
||
result=no
|
||
{X}
|
||
[/test_condition]
|
||
{VARIABLE ended yes}
|
||
[endlevel]
|
||
test_result=fail
|
||
linger_mode = yes
|
||
[/endlevel]
|
||
[/else]
|
||
[/if]
|
||
[/then]
|
||
[/if]
|
||
#enddef
|
||
|
||
#define ASSERT X
|
||
[if]
|
||
[variable]
|
||
name=ended
|
||
boolean_not_equals=yes
|
||
[/variable]
|
||
[then]
|
||
[if]
|
||
{X}
|
||
[else]
|
||
[test_condition]
|
||
result=no
|
||
{X}
|
||
[/test_condition]
|
||
{VARIABLE ended yes}
|
||
[endlevel]
|
||
test_result=fail
|
||
linger_mode = yes
|
||
[/endlevel]
|
||
[/else]
|
||
[/if]
|
||
[/then]
|
||
[/if]
|
||
#enddef
|
||
|
||
#define FAIL
|
||
{RETURN ([false][/false])}
|
||
#enddef
|
||
|
||
#define SUCCEED
|
||
{RETURN ([true][/true])}
|
||
#enddef
|
||
|
||
#define FAIL_IF_NOT FLAG NOT_EQUALS
|
||
[if]
|
||
[variable]
|
||
name={FLAG}
|
||
not_equals={NOT_EQUALS}
|
||
[/variable]
|
||
[then]
|
||
{FAIL}
|
||
[/then]
|
||
[/if]
|
||
#enddef
|
||
|
||
# Have one adjacent unit attack another adjacent unit.
|
||
# Each unit is given 1000 hp and their attack is made to 100×1, with a 100% chance of hitting.
|
||
#
|
||
# By default "alice" attacks "bob", these can be overridden with the ID1 and ID2 optional arguments.
|
||
# DAMAGE1 is expected hp loss for ID1 (alice).
|
||
# DAMAGE2 is expected hp loss for ID2 (bob), it defaults to the same as DAMAGE1.
|
||
#define ATTACK_AND_VALIDATE DAMAGE1
|
||
|
||
#arg ID1
|
||
alice#endarg
|
||
|
||
#arg ID2
|
||
bob#endarg
|
||
|
||
#arg DAMAGE2
|
||
{DAMAGE1}#endarg
|
||
|
||
[modify_unit]
|
||
[filter]
|
||
id={ID1},{ID2}
|
||
[/filter]
|
||
[effect]
|
||
apply_to=attack
|
||
[set_specials]
|
||
mode=append
|
||
[attacks]
|
||
value=1
|
||
[/attacks]
|
||
[damage]
|
||
value=100
|
||
[/damage]
|
||
[chance_to_hit]
|
||
value=100
|
||
[/chance_to_hit]
|
||
[/set_specials]
|
||
[/effect]
|
||
hitpoints = 1000
|
||
max_hitpoints = 1000
|
||
[/modify_unit]
|
||
|
||
[test_do_attack_by_id]
|
||
attacker={ID1}
|
||
defender={ID2}
|
||
[/test_do_attack_by_id]
|
||
|
||
[store_unit]
|
||
[filter]
|
||
id={ID1}
|
||
[/filter]
|
||
variable={ID1}
|
||
[/store_unit]
|
||
[store_unit]
|
||
[filter]
|
||
id={ID2}
|
||
[/filter]
|
||
variable={ID2}
|
||
[/store_unit]
|
||
|
||
{ASSERT {VARIABLE_CONDITIONAL {ID1}.hitpoints numerical_equals "$(${ID1}.max_hitpoints-{DAMAGE1})"}}
|
||
{ASSERT {VARIABLE_CONDITIONAL {ID2}.hitpoints numerical_equals "$(${ID2}.max_hitpoints-{DAMAGE2})"}}
|
||
|
||
{CLEAR_VARIABLE {ID1}}
|
||
{CLEAR_VARIABLE {ID2}}
|
||
#enddef
|
||
|
||
# Takes a unit id, and checks that its hitpoints and experience are the expected values.
|
||
# Clobbers the variable "temp".
|
||
#define ASSERT_UNIT_HP_XP ID EXPECTED_HP EXPECTED_XP
|
||
[store_unit]
|
||
[filter]
|
||
id={ID}
|
||
[/filter]
|
||
variable=temp
|
||
[/store_unit]
|
||
|
||
{ASSERT ({VARIABLE_CONDITIONAL temp.length numerical_equals 1})}
|
||
{ASSERT ({VARIABLE_CONDITIONAL temp.hitpoints numerical_equals {EXPECTED_HP}})}
|
||
{ASSERT ({VARIABLE_CONDITIONAL temp.experience numerical_equals {EXPECTED_XP}})}
|
||
|
||
{CLEAR_VARIABLE temp}
|
||
#enddef
|
||
|
||
# checks the number of strikes of all weapons a unit has
|
||
# STRIKES is a comma-delimited list containing the number of strikes each weapon the unit has is expected to have
|
||
# The implementation currently only supports one CHECK_STRIKES per unique ID1 per unit test
|
||
#define CHECK_STRIKES STRIKES RESULT
|
||
|
||
#arg ID1
|
||
alice#endarg
|
||
|
||
#arg ID2
|
||
bob#endarg
|
||
|
||
#arg COMPARE
|
||
numerical_equals#endarg
|
||
|
||
[event]
|
||
name = start
|
||
|
||
# allow specifying a different number of strikes per weapon
|
||
[set_variables]
|
||
name=strikes
|
||
[split]
|
||
list={STRIKES}
|
||
key=value
|
||
separator=","
|
||
remove_empty=yes
|
||
[/split]
|
||
[/set_variables]
|
||
|
||
[store_unit]
|
||
[filter]
|
||
id={ID1}
|
||
[/filter]
|
||
variable={ID1}
|
||
[/store_unit]
|
||
|
||
{ASSERT ({VARIABLE_CONDITIONAL {ID1}.attack.length numerical_equals $strikes.length})}
|
||
{CLEAR_VARIABLE {ID1}}
|
||
|
||
[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="$($strikes.length-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[$i].value}}
|
||
{VARIABLE_OP {ID1}_{ID2}_count add 1}
|
||
[if]
|
||
{VARIABLE_CONDITIONAL {ID1}_{ID2}_count numerical_equals $strikes.length}
|
||
[then]
|
||
{RESULT}
|
||
[/then]
|
||
[/if]
|
||
[/event]
|
||
#enddef
|