add tests for scenario ending by killing enemy leader

Tests killing, killing on retal, and levelling up on killing,
in various configurations.
This commit is contained in:
Chris Beck 2014-06-07 17:21:00 -04:00
parent 8a9e9c7f16
commit f43cb8edc2
3 changed files with 269 additions and 2 deletions

View file

@ -0,0 +1,259 @@
# Tests that when a side wins by killing the
# enemy leader with an attack, the game ends
# correctly. (This is different from the
# test_check_victory tests because we use
# [do_command] attack, and not [kill]).
#
# Also we test that killing on retal works
# the same.
#define ALICE_MOVES_TO_BOB
[do_command]
[move]
x=7,8,9,10,11,12,13
y=3,3,4, 4, 4, 4, 4
[/move]
[/do_command]
#enddef
#define BOB_1_HP
[harm_unit]
[filter]
x,y=13,3
[/filter]
amount = 100
kill = no
[/harm_unit]
#enddef
#define ALICE_1_HP
[harm_unit]
[filter]
x,y=13,4
[/filter]
amount = 100
kill = no
[/harm_unit]
#enddef
#define BOTH_0_DEF
[terrain_mask]
x,y=13,3
mask="Xv"
[/terrain_mask]
[terrain_mask]
x,y=13,4
mask="Xv"
[/terrain_mask]
#enddef
#define BOTH_MAX_XP
[store_unit]
[filter]
id=alice
[/filter]
variable=temp
kill=yes
[/store_unit]
{VARIABLE temp.max_experience 8}
[unstore_unit]
variable=temp
animate=no
fire_event=no
[/unstore_unit]
[store_unit]
[filter]
id=bob
[/filter]
variable=temp
kill=yes
[/store_unit]
{VARIABLE temp.max_experience 1}
[unstore_unit]
variable=temp
animate=no
fire_event=no
[/unstore_unit]
#enddef
{GENERIC_UNIT_TEST "alice_kills_bob" (
[event]
name = start
{ALICE_MOVES_TO_BOB}
{BOB_1_HP}
{BOTH_0_DEF}
[do_command]
[attack]
weapon = 1
defender_weapon = -1
[source]
x,y=13,4
[/source]
[destination]
x,y=13,3
[/destination]
[/attack]
[/do_command]
[/event]
[event]
name= side turn end
{RETURN [false][/false]}
[/event]
)}
{GENERIC_UNIT_TEST "bob_kills_alice_on_retal" (
[event]
name = start
{ALICE_MOVES_TO_BOB}
{ALICE_1_HP}
{BOTH_0_DEF}
[do_command]
[attack]
weapon = 0
defender_weapon=0
[source]
x,y=13,4
[/source]
[destination]
x,y=13,3
[/destination]
[/attack]
[/do_command]
[/event]
[event]
name= side turn end
{RETURN [false][/false]}
[/event]
)}
{GENERIC_UNIT_TEST "alice_kills_bob_levelup" (
[event]
name = start
{ALICE_MOVES_TO_BOB}
{BOB_1_HP}
{BOTH_0_DEF}
{BOTH_MAX_XP}
[do_command]
[attack]
weapon = 1
defender_weapon = -1
[source]
x,y=13,4
[/source]
[destination]
x,y=13,3
[/destination]
[/attack]
[/do_command]
[/event]
[event]
name= side turn end
{RETURN [false][/false]}
[/event]
)}
{GENERIC_UNIT_TEST "bob_kills_alice" (
[event]
name = start
{ALICE_MOVES_TO_BOB}
{ALICE_1_HP}
{BOTH_0_DEF}
[end_turn]
[/end_turn]
[/event]
[event]
name = side 2 turn
[do_command]
[attack]
weapon = 0
defender_weapon = 0
[source]
x,y=13,3
[/source]
[destination]
x,y=13,4
[/destination]
[/attack]
[/do_command]
[/event]
[event]
name= side 2 turn end
{RETURN [false][/false]}
[/event]
)}
{GENERIC_UNIT_TEST "alice_kills_bob_on_retal" (
[event]
name = start
{ALICE_MOVES_TO_BOB}
{BOB_1_HP}
{BOTH_0_DEF}
[end_turn]
[/end_turn]
[/event]
[event]
name = side 2 turn
[do_command]
[attack]
weapon = 0
defender_weapon = 0
[source]
x,y=13,3
[/source]
[destination]
x,y=13,4
[/destination]
[/attack]
[/do_command]
[/event]
[event]
name= side 2 turn end
{RETURN [false][/false]}
[/event]
)}
{GENERIC_UNIT_TEST "alice_kills_bob_on_retal_levelup" (
[event]
name = start
{ALICE_MOVES_TO_BOB}
{BOB_1_HP}
{BOTH_0_DEF}
{BOTH_MAX_XP}
[end_turn]
[/end_turn]
[/event]
[event]
name = side 2 turn
[do_command]
[attack]
weapon = 0
defender_weapon = 0
[source]
x,y=13,3
[/source]
[destination]
x,y=13,4
[/destination]
[/attack]
[/do_command]
[/event]
[event]
name= side 2 turn end
{RETURN [false][/false]}
[/event]
)}

View file

@ -1389,7 +1389,7 @@ namespace
//to make mp games equal we only allow selecting advancements to the current side.
//otherwise we'd give an unfair advantage to the side that hosts ai sides if units advance during ai turns.
if(force_dialog_ || (t.is_human() && (is_current_side || !is_mp)))
if(!non_interactive() && (force_dialog_ || (t.is_human() && (is_current_side || !is_mp))))
{
res = dialogs::advance_unit_dialog(loc_);
}
@ -1459,7 +1459,9 @@ void advance_unit_at(const map_location& loc, const ai::unit_advancements_aspect
config selected = mp_sync::get_user_choice("choose",
unit_advancement_choice(loc, unit_helper::number_of_possible_advances(*u),u->side(), ai_advancement, force_dialog), side_for);
//calls actions::advance_unit.
dialogs::animate_unit_advancement(loc, selected["value"], true, true);
bool result = dialogs::animate_unit_advancement(loc, selected["value"], true, true);
DBG_NG << "animate_unit_advancement result = " << result << std::endl;
u = resources::units->find(loc);
// level 10 unit gives 80 XP and the highest mainline is level 5
if (u.valid() && u->experience() > 80)

View file

@ -86,6 +86,12 @@
#
# Attack calculations & codepath tests
#
0 alice_kills_bob
0 bob_kills_alice_on_retal
0 alice_kills_bob_levelup
0 bob_kills_alice
0 alice_kills_bob_on_retal
0 alice_kills_bob_on_retal_levelup
0 test_grunt_tod_damage
0 test_berzerk_firststrike
#