16 #define GETTEXT_DOMAIN "wesnoth-test"
18 #include <boost/test/unit_test.hpp>
41 std::unique_ptr<saved_game> state;
42 std::unique_ptr<randomness::mt_rng> rng;
60 state->classification().type = campaign_type::type::multiplayer;
61 state->classification().era_id =
"era_default";
62 config_manager->load_game_config_for_game(state->classification(), state->get_scenario_id());
64 state->mp_settings().name =
"multiplayer_The_Freelands";
65 state->mp_settings().use_map_settings =
true;
66 state->mp_settings().saved_game = saved_game_mode::type::no;
68 state->set_scenario(
config_manager->game_config().find_mandatory_child(
"multiplayer",
"id", state->mp_settings().name));
70 state->mp_settings().num_turns = state->get_starting_point()[
"turns"].to_int();
91 return connect_engine;
100 side_cfg.
append(defaults);
114 state->mp_settings().use_map_settings =
true;
115 state->mp_settings().saved_game = saved_game_mode::type::no;
122 side[
"recruit"] =
"Elvish Archer";
124 BOOST_CHECK_EQUAL( side_engine->new_config()[
"recruit"],
"Elvish Archer" );
130 state->mp_settings().use_map_settings =
true;
131 state->mp_settings().saved_game = saved_game_mode::type::no;
138 side[
"faction"] =
"Custom";
140 BOOST_CHECK_EQUAL( side_engine->flg().current_faction()[
"id"],
"Custom" );
141 BOOST_CHECK_EQUAL( side_engine->new_config()[
"recruit"].empty(),
true );
147 state->mp_settings().use_map_settings =
true;
148 state->mp_settings().saved_game = saved_game_mode::type::no;
155 side[
"faction"] =
"Random";
157 BOOST_CHECK_EQUAL( side_engine->flg().current_faction()[
"id"],
"Random" );
163 state->mp_settings().use_map_settings =
true;
164 state->mp_settings().saved_game = saved_game_mode::type::no;
171 side[
"faction"] =
"Rebels";
173 BOOST_CHECK_EQUAL( side_engine->flg().current_faction()[
"id"],
"Rebels" );
179 state->mp_settings().use_map_settings =
true;
180 state->mp_settings().saved_game = saved_game_mode::type::no;
187 side[
"faction"] =
"ThisFactionDoesNotExist";
189 BOOST_CHECK( side_engine->flg().choosable_factions().size() > 1 );
190 BOOST_CHECK_EQUAL( side_engine->flg().current_faction()[
"id"],
"Random" );
196 state->mp_settings().use_map_settings =
true;
197 state->mp_settings().saved_game = saved_game_mode::type::no;
204 side[
"recruit"] =
"Elvish Archer";
205 side[
"faction"] =
"Undead";
212 state->mp_settings().use_map_settings =
true;
213 state->mp_settings().saved_game = saved_game_mode::type::no;
220 side[
"previous_recruits"] =
"Elvish Archer";
222 BOOST_CHECK_EQUAL( side_engine->new_config()[
"previous_recruits"],
"Elvish Archer" );
228 state->mp_settings().use_map_settings =
true;
229 state->mp_settings().saved_game = saved_game_mode::type::no;
236 side[
"type"] =
"Shadow";
238 BOOST_CHECK_EQUAL( side_engine->flg().choosable_leaders().size(), 1 );
239 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"Shadow" );
240 BOOST_CHECK_EQUAL( side_engine->new_config()[
"type"],
"Shadow" );
246 state->mp_settings().use_map_settings =
true;
247 state->mp_settings().saved_game = saved_game_mode::type::no;
254 side[
"type"] =
"ThisUnitDoesNotExist";
256 BOOST_CHECK_EQUAL( side_engine->flg().choosable_leaders().size(), 1 );
257 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"null" );
263 state->mp_settings().use_map_settings =
true;
264 state->mp_settings().saved_game = saved_game_mode::type::no;
271 side[
"faction"] =
"Custom";
273 BOOST_CHECK( side_engine->flg().choosable_leaders().size() > 1 );
274 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"random" );
280 state->mp_settings().use_map_settings =
true;
281 state->mp_settings().saved_game = saved_game_mode::type::no;
288 side[
"faction"] =
"Random";
290 BOOST_CHECK_EQUAL( side_engine->flg().choosable_leaders().size(), 1 );
291 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"null" );
297 state->mp_settings().use_map_settings =
true;
298 state->mp_settings().saved_game = saved_game_mode::type::no;
309 state->mp_settings().use_map_settings =
true;
310 state->mp_settings().saved_game = saved_game_mode::type::no;
317 side[
"faction"] =
"Undead";
319 BOOST_CHECK( side_engine->flg().choosable_leaders().size() > 1 );
320 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"random" );
326 state->mp_settings().use_map_settings =
true;
327 state->mp_settings().saved_game = saved_game_mode::type::no;
334 side[
"id"] =
"LeaderID";
335 side[
"type"] =
"Elvish Archer";
337 unit[
"id"] =
"LeaderID";
338 unit[
"type"] =
"Elvish Ranger";
340 BOOST_CHECK_EQUAL( side_engine->flg().choosable_leaders().size(), 1 );
341 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"Elvish Ranger" );
347 state->mp_settings().use_map_settings =
true;
348 state->mp_settings().saved_game = saved_game_mode::type::no;
359 state->mp_settings().use_map_settings =
true;
360 state->mp_settings().saved_game = saved_game_mode::type::no;
367 side[
"type"] =
"random";
369 BOOST_CHECK_EQUAL( side_engine->flg().choosable_leaders().size(), 1 );
375 state->mp_settings().use_map_settings =
true;
376 state->mp_settings().saved_game = saved_game_mode::type::no;
383 side[
"type"] =
"Elvish Archer";
385 BOOST_CHECK_EQUAL( side_engine->flg().choosable_genders().size(), 3 );
386 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"random" );
392 state->mp_settings().use_map_settings =
true;
393 state->mp_settings().saved_game = saved_game_mode::type::no;
400 side[
"type"] =
"Swordsman";
402 BOOST_CHECK_EQUAL( side_engine->flg().choosable_genders().size(), 1 );
403 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"male" );
409 state->mp_settings().use_map_settings =
true;
410 state->mp_settings().saved_game = saved_game_mode::type::no;
417 side[
"type"] =
"Elvish Druid";
419 BOOST_CHECK_EQUAL( side_engine->flg().choosable_genders().size(), 1 );
420 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"female" );
426 state->mp_settings().use_map_settings =
true;
427 state->mp_settings().saved_game = saved_game_mode::type::no;
434 side[
"type"] =
"White Mage";
435 side[
"gender"] =
"female";
437 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"female" );
443 state->mp_settings().use_map_settings =
true;
444 state->mp_settings().saved_game = saved_game_mode::type::no;
451 side[
"type"] =
"Troll";
452 side[
"gender"] =
"female";
454 BOOST_CHECK_EQUAL( side_engine->flg().choosable_genders().size(), 1 );
455 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"male" );
461 state->mp_settings().use_map_settings =
true;
462 state->mp_settings().saved_game = saved_game_mode::type::no;
469 side[
"type"] =
"White Mage";
470 side[
"gender"] =
"random";
472 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"random" );
478 state->mp_settings().use_map_settings =
true;
479 state->mp_settings().saved_game = saved_game_mode::type::no;
490 state->mp_settings().use_map_settings =
true;
491 state->mp_settings().saved_game = saved_game_mode::type::no;
498 side[
"leader_lock"] =
true;
500 BOOST_CHECK_EQUAL( side_engine->flg().choosable_leaders().size(), 1 );
501 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"null" );
507 state->mp_settings().use_map_settings =
true;
508 state->mp_settings().saved_game = saved_game_mode::type::no;
515 side[
"faction"] =
"Random";
517 side_engine->resolve_random(*rng);
518 BOOST_CHECK( side_engine->flg().current_faction()[
"id"] !=
"Random" );
519 BOOST_CHECK( side_engine->flg().current_leader() !=
"random" && side_engine->flg().current_leader() !=
"null");
520 BOOST_CHECK( side_engine->flg().current_gender() !=
"random" && side_engine->flg().current_gender() !=
"null");
526 state->mp_settings().use_map_settings =
true;
527 state->mp_settings().saved_game = saved_game_mode::type::no;
534 side[
"faction"] =
"Random";
535 side[
"type"] =
"Troll";
537 side_engine->resolve_random(*rng);
538 BOOST_CHECK( side_engine->flg().current_faction()[
"id"] !=
"Random" );
539 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"Troll" );
540 BOOST_CHECK( side_engine->flg().current_gender() !=
"random" && side_engine->flg().current_gender() !=
"null" );
546 state->mp_settings().use_map_settings =
true;
547 state->mp_settings().saved_game = saved_game_mode::type::no;
554 side[
"faction"] =
"Random";
555 side[
"type"] =
"White Mage";
556 side[
"gender"] =
"male";
558 side_engine->resolve_random(*rng);
559 BOOST_CHECK( side_engine->flg().current_faction()[
"id"] !=
"Random" );
560 BOOST_CHECK_EQUAL( side_engine->flg().current_leader(),
"White Mage" );
561 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"male" );
567 state->mp_settings().use_map_settings =
true;
568 state->mp_settings().saved_game = saved_game_mode::type::no;
575 side[
"type"] =
"random";
577 side_engine->resolve_random(*rng);
578 BOOST_CHECK( side_engine->flg().current_leader() !=
"random" );
588 state->mp_settings().use_map_settings =
false;
589 state->mp_settings().saved_game = saved_game_mode::type::no;
596 side[
"recruit"] =
"Elvish Archer";
598 BOOST_CHECK( side_engine->flg().choosable_factions().size() > 1 );
604 state->mp_settings().use_map_settings =
false;
605 state->mp_settings().saved_game = saved_game_mode::type::no;
612 side[
"faction"] =
"Custom";
614 BOOST_CHECK( side_engine->flg().choosable_factions().size() > 1 );
615 BOOST_CHECK_EQUAL( side_engine->flg().current_faction()[
"id"],
"Custom" );
616 BOOST_CHECK_EQUAL( side_engine->new_config()[
"recruit"].empty(),
true );
622 state->mp_settings().use_map_settings =
false;
623 state->mp_settings().saved_game = saved_game_mode::type::no;
630 side[
"previous_recruits"] =
"Elvish Archer";
632 BOOST_CHECK( side_engine->flg().choosable_factions().size() > 1 );
633 BOOST_CHECK_EQUAL( side_engine->new_config()[
"previous_recruits"],
"Elvish Archer" );
639 state->mp_settings().use_map_settings =
false;
640 state->mp_settings().saved_game = saved_game_mode::type::no;
647 side[
"type"] =
"Goblin Impaler";
649 side_engine->flg().set_current_faction(
"Rebels");
650 BOOST_CHECK( side_engine->flg().choosable_leaders().size() > 1 );
656 state->mp_settings().use_map_settings =
false;
657 state->mp_settings().saved_game = saved_game_mode::type::no;
664 side[
"faction"] =
"Custom";
665 side[
"type"] =
"Swordsman";
667 BOOST_CHECK( side_engine->flg().choosable_leaders().size() > 1 );
668 const std::vector<std::string>& leaders = side_engine->flg().choosable_leaders();
669 BOOST_CHECK_EQUAL( std::count(leaders.begin(), leaders.end(),
"Swordsman"), 1 );
675 state->mp_settings().use_map_settings =
false;
676 state->mp_settings().saved_game = saved_game_mode::type::no;
683 side[
"gender"] =
"female";
685 side_engine->flg().set_current_faction(
"Rebels");
686 side_engine->flg().set_current_leader(
"Elvish Ranger");
687 BOOST_CHECK_EQUAL( side_engine->flg().current_gender(),
"random" );
690 BOOST_AUTO_TEST_SUITE_END()
A config object defines a single node in a WML file, with access to child nodes.
void append(const config &cfg)
Append data from another config object to this one.
void remove_attributes(T... keys)
config & mandatory_child(config_key_type key, int n=0)
Returns the nth child with the given key, or throws an error if there is none.
void clear_children(T... keys)
const attribute_value * get(config_key_type key) const
Returns a pointer to the attribute with the given key or nullptr if it does not exist.
config & add_child(config_key_type key)
@ NO_FORCE_RELOAD
Don't reload if the previous defines equal the new defines.
this class is initialized once at game start put all initialization and wipe code in the methods here...
config * current_config()
connect_engine(saved_game &state, const bool first_scenario, mp_game_metadata *metadata)
test_connect_engine(saved_game &gamestate)
This class represents a single unit of a specific type.
std::shared_ptr< side_engine > side_engine_ptr
game_display & get_fake_display(const int width, const int height)
Gets a fake test display.
std::vector< std::string > dummy_args
hotkey::manager hotkey_manager
commandline_options cmdline_opts
std::unique_ptr< game_config_manager > config_manager
BOOST_FIXTURE_TEST_SUITE(test_map_location, MLFixture)
static ng::side_engine * create_side_engine(const config &defaults, test_connect_engine *connect_engine)
static test_connect_engine * create_test_connect_engine()
BOOST_AUTO_TEST_CASE(flg_map_settings2)