1 /////////////////////////////////////////////////////////////////////////////// 2 // Copyright (C) 2004-2011 by The Allacrost Project 3 // Copyright (C) 2012-2016 by Bertram (Valyria Tear) 4 // All Rights Reserved 5 // 6 // This code is licensed under the GNU GPL version 2. It is free software 7 // and you may modify it and/or redistribute it under the terms of this license. 8 // See https://www.gnu.org/copyleft/gpl.html for details. 9 /////////////////////////////////////////////////////////////////////////////// 10 11 #ifndef __MAP_TREASURE_CONTENT_HEADER__ 12 #define __MAP_TREASURE_CONTENT_HEADER__ 13 14 #include <memory> 15 #include <vector> 16 17 namespace vt_global { 18 class GlobalObject; 19 } 20 21 namespace vt_map 22 { 23 24 namespace private_map 25 { 26 27 class TreasureObject; 28 29 /** **************************************************************************** 30 *** \brief A container class for treasures procured by the player 31 *** 32 *** Treasures may contain multiple quantities and types of items, weapons, armor, 33 *** or any other type of global object. They may additionally contain any amount 34 *** of drunes (money). As one would expect, the contents of a treasure should only 35 *** be retrieved by the player one time. This class holds a member for tracking whether 36 *** the treasure has been taken or not, but it is not responsible for determining 37 *** if a treasure was taken in the past (by a previous visit to the map or from the 38 *** saved game file). 39 *** ***************************************************************************/ 40 class MapTreasureContent 41 { 42 friend class TreasureSupervisor; 43 44 public: 45 MapTreasureContent(); 46 47 //! \brief Sets the number of drunes present in the chest's contents. SetDrunes(uint32_t amount)48 void SetDrunes(uint32_t amount) { 49 _drunes = amount; 50 } 51 52 /** \brief Adds an item to the contents of the MapTreasure 53 *** \param id The id of the GlobalObject to add 54 *** \param quantity The number of the object to add (default == 1) 55 *** \return True if the object was added successfully 56 **/ 57 bool AddItem(uint32_t id, uint32_t quantity = 1); 58 IsTaken()59 bool IsTaken() const { 60 return _taken; 61 } 62 SetTaken(bool taken)63 void SetTaken(bool taken) { 64 _taken = taken; 65 } 66 67 private: 68 //! \brief Set to true when the contents of the treasure have been added to the player's inventory 69 bool _taken; 70 71 //! \brief The number of drunes contained in the chest 72 uint32_t _drunes; 73 74 //! \brief The list of objects given to the player upon opening the treasure 75 std::vector<std::shared_ptr<vt_global::GlobalObject>> _items_list; 76 }; 77 78 } // namespace private_map 79 80 } // namespace vt_map 81 82 #endif // __MAP_TREASURE_CONTENT_HEADER__ 83