Add tests for pre_attack event.
This commit is contained in:
parent
0f763cfdd6
commit
8bc084bc0b
3 changed files with 171 additions and 15 deletions
|
@ -1,19 +1,16 @@
|
|||
#textdomain wesnoth-test
|
||||
# unit placed
|
||||
# prerecruit
|
||||
# recruit
|
||||
# exit_hex
|
||||
# enter_hex
|
||||
# moveto
|
||||
# attack
|
||||
# attacker hits
|
||||
# defender misses
|
||||
# attack end
|
||||
# attacker misses
|
||||
# defender hits
|
||||
# pre advance
|
||||
# advance
|
||||
# post advance
|
||||
#####
|
||||
# API(s) being tested: [event]name=unit placed,prerecruit,recruit,exit_hex,enter_hex,moveto,pre_attack,attack,attacker hits,defender misses,attack end,attacker misses,defender hits,pre advance,advance,post advance
|
||||
##
|
||||
# Actions:
|
||||
# Trigger various sets of events and check that they are executed in the proper sequence.
|
||||
##
|
||||
# Expected end state:
|
||||
# unit placed -> prerecruit -> recruit
|
||||
# exit_hex -> enter_hex -> moveto
|
||||
# pre_attack -> attack -> attacker hits/attacker misses -> defender hits/defender misses -> attack end
|
||||
# pre advance -> advance -> post advance
|
||||
#####
|
||||
{GENERIC_UNIT_TEST "events-test_filterable1" (
|
||||
[event]
|
||||
name=start
|
||||
|
@ -134,9 +131,17 @@
|
|||
{FAIL_IF_NOT enter_hex_flag 1}
|
||||
{FAIL_IF_NOT moveto_flag 1}
|
||||
[/event]
|
||||
[event]
|
||||
name=pre_attack
|
||||
{VARIABLE pre_attack_flag 1}
|
||||
{FAIL_IF_NOT pre_attack_flag 1}
|
||||
{FAIL_IF_NOT attack_flag $null}
|
||||
{FAIL_IF_NOT attack_end_flag $null}
|
||||
[/event]
|
||||
[event]
|
||||
name=attack
|
||||
{VARIABLE attack_flag 1}
|
||||
{FAIL_IF_NOT pre_attack_flag 1}
|
||||
{FAIL_IF_NOT attack_flag 1}
|
||||
{FAIL_IF_NOT attack_end_flag $null}
|
||||
[/event]
|
||||
|
@ -151,6 +156,7 @@
|
|||
[event]
|
||||
name=attack end
|
||||
{VARIABLE attack_end_flag 1}
|
||||
{FAIL_IF_NOT pre_attack_flag 1}
|
||||
{FAIL_IF_NOT attack_flag 1}
|
||||
{FAIL_IF_NOT attack_end_flag 1}
|
||||
[/event]
|
||||
|
|
148
data/test/scenarios/events-test_pre_attack.cfg
Normal file
148
data/test/scenarios/events-test_pre_attack.cfg
Normal file
|
@ -0,0 +1,148 @@
|
|||
#####
|
||||
# API(s) being tested: [event]name=pre_attack
|
||||
##
|
||||
# Actions:
|
||||
# Move a unit and attack with it.
|
||||
##
|
||||
# Expected end state:
|
||||
# The pre_attack event is triggered.
|
||||
#####
|
||||
{GENERIC_UNIT_TEST "events-test_pre_attack_base" (
|
||||
[event]
|
||||
name=start
|
||||
[do_command]
|
||||
[move]
|
||||
x=7,8,9,10,11,12
|
||||
y=3,3,3,3,3,3
|
||||
[/move]
|
||||
[/do_command]
|
||||
[do_command]
|
||||
[attack]
|
||||
weapon=0
|
||||
defender_weapon=0
|
||||
[source]
|
||||
x,y=12,3
|
||||
[/source]
|
||||
[destination]
|
||||
x,y=13,3
|
||||
[/destination]
|
||||
[/attack]
|
||||
[/do_command]
|
||||
[/event]
|
||||
[event]
|
||||
name=pre_attack
|
||||
{SUCCEED}
|
||||
[/event]
|
||||
)}
|
||||
|
||||
#####
|
||||
# API(s) being tested: [event]name=pre_attack
|
||||
##
|
||||
# Actions:
|
||||
# Check that the relevant automatically stored variables are present
|
||||
# Check that modifications to the attack being used are applied to the combat
|
||||
##
|
||||
# Expected end state:
|
||||
# All automatically stored variables are present.
|
||||
# The Elvish Archer's sword attack is modified to have 1 damage, resulting in the Orcish Grunt having 36/38 hitpoints.
|
||||
#####
|
||||
{GENERIC_UNIT_TEST "events-test_pre_attack_change_weapon" (
|
||||
[event]
|
||||
name=start
|
||||
[do_command]
|
||||
[move]
|
||||
x=7,8,9,10,11,12
|
||||
y=3,3,3,3,3,3
|
||||
[/move]
|
||||
[/do_command]
|
||||
[do_command]
|
||||
[attack]
|
||||
weapon=0
|
||||
defender_weapon=0
|
||||
[source]
|
||||
x,y=12,3
|
||||
[/source]
|
||||
[destination]
|
||||
x,y=13,3
|
||||
[/destination]
|
||||
[/attack]
|
||||
[/do_command]
|
||||
[/event]
|
||||
[event]
|
||||
name=pre_attack
|
||||
# test unit and second_unit
|
||||
{ASSERT (
|
||||
[variable]
|
||||
name=unit.type
|
||||
equals="Elvish Archer"
|
||||
[/variable]
|
||||
)}
|
||||
{ASSERT (
|
||||
[variable]
|
||||
name=second_unit.type
|
||||
equals="Orcish Grunt"
|
||||
[/variable]
|
||||
)}
|
||||
# test weapon and second_weapon
|
||||
{ASSERT (
|
||||
[variable]
|
||||
name=weapon.name
|
||||
equals="sword"
|
||||
[/variable]
|
||||
)}
|
||||
{ASSERT (
|
||||
[variable]
|
||||
name=second_weapon.name
|
||||
equals="sword"
|
||||
[/variable]
|
||||
)}
|
||||
# test x1,y1
|
||||
{ASSERT (
|
||||
[variable]
|
||||
name=x1
|
||||
equals=12
|
||||
[/variable]
|
||||
)}
|
||||
{ASSERT (
|
||||
[variable]
|
||||
name=y1
|
||||
equals=3
|
||||
[/variable]
|
||||
)}
|
||||
# test x2,y2
|
||||
{ASSERT (
|
||||
[variable]
|
||||
name=x2
|
||||
equals=13
|
||||
[/variable]
|
||||
)}
|
||||
{ASSERT (
|
||||
[variable]
|
||||
name=y2
|
||||
equals=3
|
||||
[/variable]
|
||||
)}
|
||||
# modify the unit's attack before using it
|
||||
[modify_unit]
|
||||
[filter]
|
||||
x=$x1
|
||||
y=$y1
|
||||
[/filter]
|
||||
[effect]
|
||||
apply_to=attack
|
||||
set_accuracy=100
|
||||
set_damage=1
|
||||
[/effect]
|
||||
[/modify_unit]
|
||||
[/event]
|
||||
[event]
|
||||
name=attack_end
|
||||
{ASSERT (
|
||||
[variable]
|
||||
name=second_unit.hitpoints
|
||||
equals=36
|
||||
[/variable]
|
||||
)}
|
||||
{SUCCEED}
|
||||
[/event]
|
||||
)}
|
|
@ -178,6 +178,8 @@
|
|||
0 events-test_victory
|
||||
0 events-test_defeat
|
||||
0 events-test_die
|
||||
0 events-test_pre_attack_base
|
||||
0 events-test_pre_attack_change_weapon
|
||||
0 test_store_unit_defense_on
|
||||
9 test_store_unit_defense_deprecated
|
||||
# Terrain mask tests
|
||||
|
|
Loading…
Add table
Reference in a new issue