Ejemplo n.º 1
0
/**
 * \brief Gives the treasure to the player.
 *
 * Adds the item to the hero's equipment.
 * The item should not be empty and must be obtainable.
 */
void Treasure::give_to_player() const {

  Debug::check_assertion(!is_found(), "This treasure was already found");
  check_obtainable();

  // Mark the treasure as found in the savegame.
  if (is_saved()) {
    game->get_savegame().set_boolean(savegame_variable, true);
  }

  // Give the item to the player.
  EquipmentItem& item = get_item();
  if (item.is_saved()) {
    item.set_variant(get_variant());
  }

  // Notify the Lua item and the Lua map.
  LuaContext& lua_context = game->get_lua_context();
  lua_context.item_on_obtaining(item, *this);
  lua_context.map_on_obtaining_treasure(game->get_current_map(), *this);
}
Ejemplo n.º 2
0
/**
 * \brief Returns the name of the item.
 * \return The name of the item.
 */
const std::string& Treasure::get_item_name() const {

  check_obtainable();
  return item_name;
}