1 // Copyright (C) 2007, 2008 Ben Asselstine
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #include <sigc++/trackable.h>
28 /** List of unique rewards in the game.
29 * Some rewards like gold, and allies can be created whenever they're needed,
30 * but other rewards are unique in nature. This list is for those unique
31 * rewards -- namely item rewards, and hidden ruins.
35 class Rewardlist : public std::list<Reward*>, public sigc::trackable
38 //! The xml tag of this object in a saved-game file.
39 static std::string d_tag;
42 // Methods that operate on the class data and modify the class.
44 //! deletes a reward from the list
45 void deleteReward(Reward* s);
47 //! remove one item reward from the list and return it
48 Reward *popRandomItemReward();
50 //! remove one ruin reward from the list and return it
51 Reward *popRandomRuinReward();
53 //! remove one ruin reward from the list and return it
54 Reward *popRandomMapReward();
56 //! Behaves like std::list::clear(), but frees pointers as well
59 //! Behaves like std::list::erase(), but frees pointers as well
60 iterator flErase(iterator object);
62 //! Behaves like std::list::remove(), but frees pointers as well
63 bool flRemove(Reward* object);
66 // Methods that operate on the class data and do not modify the class.
68 //! Save the data. See XML_Helper for details
69 bool save(XML_Helper* helper) const;
74 //! Returns the singleton instance. Creates a new one if required.
75 static Rewardlist* getInstance();
77 //! Loads the singleton instance with a savegame.
78 static Rewardlist* getInstance(XML_Helper* helper);
80 //! Explicitely deletes the singleton instance.
81 static void deleteInstance();
89 Rewardlist(Rewardlist *rewardlist);
91 //! Loading constructor.
92 Rewardlist(XML_Helper* helper);
98 //! Callback function for loading rewards.
99 bool load(std::string tag, XML_Helper* helper);
101 //! Return a random reward from the list of the given type.
102 Reward *popRandomReward(Reward::Type type);
106 static Rewardlist* s_instance;
109 #endif // REWARDLIST_H