mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-02 06:58:07 +00:00
253 lines
5.9 KiB
INI
253 lines
5.9 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
|
||
# 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
|