1 // Copyright (C) 2007, 2008, 2009 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
18 #ifndef QUEST_PILLAGE_GOLD_H
19 #define QUEST_PILLAGE_GOLD_H
21 #include <sigc++/trackable.h>
27 //! A Quest to accrue an amount of gold pieces from another Player.
29 * The Hero is required to conquer cities and obtain a given amount of gold
30 * pieces from a victim Player. Sacking and pillaging means to cash-in Army
31 * production bases from conquered cities.
33 * The quest succeeds when the Player successfully accrues the given amount
34 * of gold pieces. This quest never expires.
36 class QuestPillageGold : public Quest, public sigc::trackable
39 //! Default constructor.
41 * Make a new sack and pillage quest.
43 * @param q_mgr The quests manager to associate this quest with.
44 * @param hero The Id of the Hero who is responsible for the quest.
46 QuestPillageGold(QuestsManager& q_mgr, guint32 hero);
48 //! Loading constructor.
50 * @param q_mgr The quests manager to associate this quest with.
51 * @param helper The opened saved-game file to load this quest from.
53 QuestPillageGold(QuestsManager& q_mgr, XML_Helper* helper);
55 // Construct from remote action.
56 QuestPillageGold(QuestsManager& q_mgr, guint32 hero, guint32 gold);
61 //! Return a description of how many gold pieces have been accrued.
62 std::string getProgress() const;
64 //! Return a queue of strings to show when the quest is compeleted.
65 void getSuccessMsg(std::queue<std::string>& msgs) const;
67 //! Return a queue of strings to show when the quest has expired.
68 void getExpiredMsg(std::queue<std::string>& msgs) const;
70 //! Returns the amount of gold to be pillaged.
71 guint32 getGoldToPillage() {return d_to_pillage;}
74 // Methods that operate on the class data and do not modify the class.
76 //! Saves the sack and pillage quest data to an opened saved-game file.
77 bool save(XML_Helper* helper) const;
80 // Methods that need to be implemented from the superclass.
82 //! Callback for when an Army object is killed.
84 * @note This method is not used.
86 void armyDied(Army *a, bool heroIsCulprit);
88 //! Callback for when a City object is defeated.
90 * This method notifies the Quest that a City has fallen, and what the
91 * conquering action (pillage/sack/raze/occupy) was. It also notifies
92 * whether or not the hero responsible for this quest was involved in
93 * the conquering, and how much gold was taken as a result.
95 * The amount of gold is added to Quest_Pillage::d_pillaged.
97 * @param city The City object that has been conquered.
98 * @param action What action was taken by the Player. See
99 * CityDefeatedAction for more information.
100 * @param heroIsCulprit Whether or not the Hero object associated with
101 * this Quest object is responsible for
102 * conquering the given City object.
103 * @param gold How many gold pieces were taken as a result
106 void cityAction(City *city, CityDefeatedAction action,
107 bool heroIsCulprit, int gold);
112 //! Returns that this quest is feasible.
113 static bool isFeasible(guint32 heroId) {return true;}
117 //! Generate a description of the Quest.
118 void initDescription();
122 //! The amount of gold pieces to sack and pillage to succeed.
123 guint32 d_to_pillage;
125 //! The number of gold pieces already sacked and pillaged.
128 //! The player whose cities this quest is targetting.
129 Player *d_victim_player;