mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-27 22:04:47 +00:00
437 lines
11 KiB
INI
437 lines
11 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
|
||
|
||
#define GIVE_ALL_TYPES DAMAGE STRIKES
|
||
[modify_unit]
|
||
[filter]
|
||
[/filter]
|
||
[effect]
|
||
apply_to = new_attack
|
||
name = "arcane"
|
||
type = "arcane"
|
||
range = "melee"
|
||
damage = {DAMAGE}
|
||
number = {STRIKES}
|
||
[/effect]
|
||
[effect]
|
||
apply_to = new_attack
|
||
name = "fire"
|
||
type = "fire"
|
||
range = "melee"
|
||
damage = {DAMAGE}
|
||
number = {STRIKES}
|
||
[/effect]
|
||
[effect]
|
||
apply_to = new_attack
|
||
name = "cold"
|
||
type = "cold"
|
||
range = "melee"
|
||
damage = {DAMAGE}
|
||
number = {STRIKES}
|
||
[/effect]
|
||
[effect]
|
||
apply_to = new_attack
|
||
name = "pierce"
|
||
type = "pierce"
|
||
range = "melee"
|
||
damage = {DAMAGE}
|
||
number = {STRIKES}
|
||
[/effect]
|
||
[effect]
|
||
apply_to = new_attack
|
||
name = "impact"
|
||
type = "impact"
|
||
range = "melee"
|
||
damage = {DAMAGE}
|
||
number = {STRIKES}
|
||
[/effect]
|
||
[effect]
|
||
apply_to = attack
|
||
name = "sword"
|
||
set_name = "blade"
|
||
set_damage = {DAMAGE}
|
||
set_attacks = {STRIKES}
|
||
[/effect]
|
||
[/modify_unit]
|
||
#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.
|
||
# 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
|
||
#define ATTACK_AND_VALIDATE DAMAGE1
|
||
|
||
#arg ID1
|
||
alice#endarg
|
||
|
||
#arg ID2
|
||
bob#endarg
|
||
|
||
#arg DAMAGE2
|
||
{DAMAGE1}#endarg
|
||
|
||
#arg WEAPON_COUNT
|
||
1#endarg
|
||
|
||
#arg STRIKE_COUNT
|
||
1#endarg
|
||
|
||
#arg ID1_HP
|
||
1000#endarg
|
||
|
||
#arg ID2_HP
|
||
1000#endarg
|
||
|
||
#arg DAMAGE_VALUE
|
||
[damage]
|
||
value=100
|
||
[/damage]
|
||
#endarg
|
||
|
||
[modify_unit]
|
||
[filter]
|
||
id={ID1},{ID2}
|
||
[/filter]
|
||
[effect]
|
||
apply_to=attack
|
||
[set_specials]
|
||
mode=append
|
||
[attacks]
|
||
value={STRIKE_COUNT}
|
||
[/attacks]
|
||
{DAMAGE_VALUE}
|
||
[chance_to_hit]
|
||
value=100
|
||
[/chance_to_hit]
|
||
[/set_specials]
|
||
[/effect]
|
||
[/modify_unit]
|
||
|
||
{VARIABLE weapons {WEAPON_COUNT}}
|
||
[for]
|
||
start=0
|
||
end="$($weapons-1)"
|
||
step=1
|
||
[do]
|
||
[modify_unit]
|
||
[filter]
|
||
id={ID1}
|
||
[/filter]
|
||
hitpoints = {ID1_HP}
|
||
max_hitpoints = {ID1_HP}
|
||
[/modify_unit]
|
||
[modify_unit]
|
||
[filter]
|
||
id={ID2}
|
||
[/filter]
|
||
hitpoints = {ID2_HP}
|
||
max_hitpoints = {ID2_HP}
|
||
[/modify_unit]
|
||
|
||
[test_do_attack_by_id]
|
||
attacker={ID1}
|
||
defender={ID2}
|
||
weapon=$i
|
||
resupply_attacks_left=1
|
||
[/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}}
|
||
[/do]
|
||
[/for]
|
||
#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
|
||
# By default, both units chance to hit will be set to 100%. This can be overridden with the optional CHANCE_TO_HIT argument
|
||
#define CHECK_STRIKES STRIKES RESULT
|
||
|
||
#arg ID1
|
||
alice#endarg
|
||
|
||
#arg ID2
|
||
bob#endarg
|
||
|
||
#arg COMPARE
|
||
numerical_equals#endarg
|
||
|
||
#arg CHANCE_TO_HIT
|
||
[chance_to_hit]
|
||
value=100
|
||
[/chance_to_hit]
|
||
#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}
|
||
[/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
|
||
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
|
||
|
||
#define SWARM_ATTACK_TEST WEAPON ID1 ID2 DAMAGE1_1 DAMAGE2_1 DAMAGE1_2 DAMAGE2_2
|
||
[test_do_attack_by_id]
|
||
attacker={ID1}
|
||
defender={ID2}
|
||
weapon={WEAPON}
|
||
resupply_attacks_left=1
|
||
[/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_1})"}}
|
||
{ASSERT {VARIABLE_CONDITIONAL {ID2}.hitpoints numerical_equals "$(${ID2}.max_hitpoints-{DAMAGE2_1})"}}
|
||
|
||
{CLEAR_VARIABLE {ID1}}
|
||
{CLEAR_VARIABLE {ID2}}
|
||
|
||
[test_do_attack_by_id]
|
||
attacker={ID1}
|
||
defender={ID2}
|
||
weapon={WEAPON}
|
||
resupply_attacks_left=1
|
||
[/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_2})"}}
|
||
{ASSERT {VARIABLE_CONDITIONAL {ID2}.hitpoints numerical_equals "$(${ID2}.max_hitpoints-{DAMAGE2_2})"}}
|
||
|
||
{CLEAR_VARIABLE {ID1}}
|
||
{CLEAR_VARIABLE {ID2}}
|
||
|
||
[heal_unit]
|
||
[filter]
|
||
[/filter]
|
||
[/heal_unit]
|
||
#enddef
|