engine/source/ShadowOfTheWyrmEngine.cpp
// Set up everything needed by the Game
Set up everything needed by the Game
Set up everything needed by the Game
void ShadowOfTheWyrmEngine::setup_game()
{
  Game& game = Game::instance();
  XMLConfigurationReader reader(FileConstants::XML_CONFIGURATION_FILE);
  game.set_display(display);
  pair<ItemMap, GenerationValuesMap> items = reader.get_items();
  game.set_items(items.first);
  game.set_item_generation_values(items.second);
  FeatureMap basic_features = reader.get_basic_features();
  game.set_basic_features(basic_features);
  vector<ItemType> item_types{ ItemType::ITEM_TYPE_SCROLL, ItemType::ITEM_TYPE_WAND, ItemType::ITEM_TYPE_STAFF, ItemType::ITEM_TYPE_SPELLBOOK, ItemType::ITEM_TYPE_RING, ItemType::ITEM_TYPE_POTION, ItemType::ITEM_TYPE_AMULET };
  ItemDescriptionRandomizer item_randomizer(item_types);
  item_randomizer.randomize(game.items);
  map<string, string> scripts = reader.get_scripts();
  game.set_scripts(scripts);
  DeityMap deities = reader.get_deities();      
  game.set_deities(deities);
  RaceMap races = reader.get_races();
  game.set_races(races);
  ClassMap classes = reader.get_classes();
  game.set_classes(classes);
  pair<CreatureMap, CreatureGenerationValuesMap> creatures = reader.get_creatures();    
  game.set_creatures(creatures.first);
  game.set_creature_generation_values(creatures.second);
  SpellMap spells = reader.get_spells();
  game.set_spells(spells);
  vector<DisplayTile> tile_info = reader.get_tile_info();
  game.set_tile_display_info(tile_info);
  vector<TrapPtr> trap_info = reader.get_trap_info();
  game.set_trap_info(trap_info);
  map<int, CalendarDay> calendar_days = reader.get_calendar_days();
  game.set_calendar_days(calendar_days);
  StartingLocationMap starting_locations = reader.get_starting_locations();
  game.set_starting_locations(starting_locations);
  vector<MapPtr> custom_maps = reader.get_custom_maps(FileConstants::CUSTOM_MAPS_DIRECTORY, FileConstants::CUSTOM_MAPS_PATTERN);
  game.set_custom_maps(custom_maps);
  IMessageManager& manager = MM::instance();
  manager.set_display(display);
}
void ShadowOfTheWyrmEngine :: setup_game ( ) { Game & game = Game :: instance ( ) ; XMLConfigurationReader reader ( FileConstants :: XML_CONFIGURATION_FILE ) ; game . set_display ( display ) ; pair < ItemMap , GenerationValuesMap > items = reader . get_items ( ) ; game . set_items ( items . first ) ; game . set_item_generation_values ( items . second ) ; FeatureMap basic_features = reader . get_basic_features ( ) ; game . set_basic_features ( basic_features ) ; vector < ItemType > item_types { ItemType :: ITEM_TYPE_SCROLL , ItemType :: ITEM_TYPE_WAND , ItemType :: ITEM_TYPE_STAFF , ItemType :: ITEM_TYPE_SPELLBOOK , ItemType :: ITEM_TYPE_RING , ItemType :: ITEM_TYPE_POTION , ItemType :: ITEM_TYPE_AMULET } ; ItemDescriptionRandomizer item_randomizer ( item_types ) ; item_randomizer . randomize ( game . items ) ; map < string , string > scripts = reader . get_scripts ( ) ; game . set_scripts ( scripts ) ; DeityMap deities = reader . get_deities ( ) ; game . set_deities ( deities ) ; RaceMap races = reader . get_races ( ) ; game . set_races ( races ) ; ClassMap classes = reader . get_classes ( ) ; game . set_classes ( classes ) ; pair < CreatureMap , CreatureGenerationValuesMap > creatures = reader . get_creatures ( ) ; game . set_creatures ( creatures . first ) ; game . set_creature_generation_values ( creatures . second ) ; SpellMap spells = reader . get_spells ( ) ; game . set_spells ( spells ) ; vector < DisplayTile > tile_info = reader . get_tile_info ( ) ; game . set_tile_display_info ( tile_info ) ; vector < TrapPtr > trap_info = reader . get_trap_info ( ) ; game . set_trap_info ( trap_info ) ; map < int , CalendarDay > calendar_days = reader . get_calendar_days ( ) ; game . set_calendar_days ( calendar_days ) ; StartingLocationMap starting_locations = reader . get_starting_locations ( ) ; game . set_starting_locations ( starting_locations ) ; vector < MapPtr > custom_maps = reader . get_custom_maps ( FileConstants :: CUSTOM_MAPS_DIRECTORY , FileConstants :: CUSTOM_MAPS_PATTERN ) ; game . set_custom_maps ( custom_maps ) ; IMessageManager & manager = MM :: instance ( ) ; manager . set_display ( display ) ; }
Set up everything needed by the Game
Set up everything needed by the Game
// Read the races, classes, and items from the configuration file. // Items need to be read first so that each class's default items can be loaded. // Custom maps are read last because they rely on creatures (which rely on races // and classes), and items. // Randomize the items after reading them!  Otherwise, if any potions, etc., // are generated e.g. during custom map initialization, they will always have // the same descriptions. // This switches files/namespaces - so should be last. // As part of setting the custom maps, the game may run any associated // scripts. // Set up the message manager also.