fix bug #23130 (xp modifier not working), add unit tests
Reverts commit e85c37e161
which was
an error.
I chose to use a scoped_pointer this time around because the
definition of play_controller should not actually depend on the
complete definition of unit_type.
This commit is contained in:
parent
43a136fac1
commit
6a3321d0db
4 changed files with 54 additions and 0 deletions
48
data/test/scenarios/xp_mod.cfg
Normal file
48
data/test/scenarios/xp_mod.cfg
Normal file
|
@ -0,0 +1,48 @@
|
|||
{GENERIC_UNIT_TEST "xp_mod_1" (
|
||||
[event]
|
||||
name = start
|
||||
|
||||
[store_unit]
|
||||
variable=foo
|
||||
[filter]
|
||||
id = alice
|
||||
[/filter]
|
||||
[/store_unit]
|
||||
|
||||
{RETURN {VARIABLE_CONDITIONAL foo[0].max_experience equals 44}}
|
||||
[/event]
|
||||
)}
|
||||
|
||||
{GENERIC_UNIT_TEST "xp_mod_2" (
|
||||
experience_modifier = 50
|
||||
|
||||
[event]
|
||||
name = start
|
||||
|
||||
[store_unit]
|
||||
variable=foo
|
||||
[filter]
|
||||
id = alice
|
||||
[/filter]
|
||||
[/store_unit]
|
||||
|
||||
{RETURN {VARIABLE_CONDITIONAL foo[0].max_experience equals 22}}
|
||||
[/event]
|
||||
)}
|
||||
|
||||
{GENERIC_UNIT_TEST "xp_mod_3" (
|
||||
experience_modifier = 75
|
||||
|
||||
[event]
|
||||
name = start
|
||||
|
||||
[store_unit]
|
||||
variable=foo
|
||||
[filter]
|
||||
id = alice
|
||||
[/filter]
|
||||
[/store_unit]
|
||||
|
||||
{RETURN {VARIABLE_CONDITIONAL foo[0].max_experience equals 33}}
|
||||
[/event]
|
||||
)}
|
|
@ -58,6 +58,7 @@
|
|||
#include "tooltips.hpp"
|
||||
#include "unit.hpp"
|
||||
#include "unit_id.hpp"
|
||||
#include "unit_types.hpp"
|
||||
#include "whiteboard/manager.hpp"
|
||||
#include "wml_exception.hpp"
|
||||
|
||||
|
@ -126,6 +127,7 @@ play_controller::play_controller(const config& level, saved_game& state_of_game,
|
|||
soundsources_manager_(),
|
||||
persist_(),
|
||||
gui_(),
|
||||
xp_mod_(new unit_type::experience_accelerator(level["experience_modifier"].to_int(100))),
|
||||
statistics_context_(level["name"]),
|
||||
undo_stack_(new actions::undo_list(level.child("undo_stack"))),
|
||||
loading_game_(level["playing_team"].empty() == false),
|
||||
|
|
|
@ -247,6 +247,7 @@ protected:
|
|||
|
||||
//other objects
|
||||
boost::scoped_ptr<game_display> gui_;
|
||||
boost::scoped_ptr<unit_type::experience_accelerator> xp_mod_;
|
||||
const statistics::scenario_context statistics_context_;
|
||||
/// undo_stack_ is never NULL. It is implemented as a pointer so that
|
||||
/// undo_list can be an incomplete type at this point (which reduces the
|
||||
|
|
|
@ -84,6 +84,9 @@
|
|||
0 event_handlers_in_events_8
|
||||
0 filter_vision
|
||||
0 has_ally
|
||||
0 xp_mod_1
|
||||
0 xp_mod_2
|
||||
0 xp_mod_3
|
||||
#
|
||||
# LUA
|
||||
#
|
||||
|
|
Loading…
Add table
Reference in a new issue