initial commit, lordsawar source, slightly modified
[lordsawar] / src / QPillageGold.h
1 //  Copyright (C) 2007, 2008, 2009 Ben Asselstine
2 //
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.
7 //
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.
12 //
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 
16 //  02110-1301, USA.
17
18 #ifndef QUEST_PILLAGE_GOLD_H
19 #define QUEST_PILLAGE_GOLD_H
20
21 #include <sigc++/trackable.h>
22
23 #include <list>
24 #include "Quest.h"
25 #include "city.h"
26
27 //! A Quest to accrue an amount of gold pieces from another Player.
28 /**
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.
32  *
33  * The quest succeeds when the Player successfully accrues the given amount
34  * of gold pieces.  This quest never expires.
35  */
36 class QuestPillageGold : public Quest, public sigc::trackable
37 {
38     public:
39         //! Default constructor.
40         /**
41          * Make a new sack and pillage quest.
42          *
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.
45          */
46         QuestPillageGold(QuestsManager& q_mgr, guint32 hero);
47
48         //! Loading constructor.
49         /**
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.
52          */
53         QuestPillageGold(QuestsManager& q_mgr, XML_Helper* helper);
54      
55         // Construct from remote action.
56         QuestPillageGold(QuestsManager& q_mgr, guint32 hero, guint32 gold);
57
58
59         // Get Methods
60
61         //! Return a description of how many gold pieces have been accrued.
62         std::string getProgress() const;
63
64         //! Return a queue of strings to show when the quest is compeleted.
65         void getSuccessMsg(std::queue<std::string>& msgs) const;
66
67         //! Return a queue of strings to show when the quest has expired.
68         void getExpiredMsg(std::queue<std::string>& msgs) const;
69
70         //! Returns the amount of gold to be pillaged.
71         guint32 getGoldToPillage() {return d_to_pillage;}
72          
73
74         // Methods that operate on the class data and do not modify the class.
75         
76         //! Saves the sack and pillage quest data to an opened saved-game file.
77         bool save(XML_Helper* helper) const;
78
79
80         // Methods that need to be implemented from the superclass.
81
82         //! Callback for when an Army object is killed.
83         /**
84          * @note This method is not used.
85          */
86         void armyDied(Army *a, bool heroIsCulprit);
87
88         //! Callback for when a City object is defeated.
89         /**
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.
94          *
95          * The amount of gold is added to Quest_Pillage::d_pillaged.
96          *
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
104          *                       of the action.
105          */
106         void cityAction(City *city, CityDefeatedAction action, 
107                         bool heroIsCulprit, int gold);
108
109
110         // Static Methods
111
112         //! Returns that this quest is feasible.
113         static bool isFeasible(guint32 heroId) {return true;}
114
115     private:
116
117         //! Generate a description of the Quest.
118         void initDescription();
119
120         // DATA
121
122         //! The amount of gold pieces to sack and pillage to succeed.
123         guint32 d_to_pillage;
124
125         //! The number of gold pieces already sacked and pillaged.
126         guint32 d_pillaged;
127
128         //! The player whose cities this quest is targetting.
129         Player *d_victim_player;
130
131 };
132
133 #endif