initial commit, lordsawar source, slightly modified
[lordsawar] / src / QEnemyArmytype.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_ENEMY_ARMYTYPES_H
19 #define QUEST_ENEMY_ARMYTYPES_H
20
21 #include <sigc++/trackable.h>
22
23 #include <list>
24 #include "Quest.h"
25 #include "army.h"
26
27 //! A Quest to kill one army of another Player's Army objects.
28 /**
29  * A hero that receives this quest has to kill a single instance of a 
30  * particular king of Army object (e.g. Ghosts).  The Quest is completed when 
31  * this happens, and does not expire.
32  * This quest presumes that all players have the same Armyset.
33  */
34 class QuestEnemyArmytype : public Quest, public sigc::trackable
35 {
36 public:
37     //! Default constructor.
38     /**
39      * Make a new kill-armytype quest.
40      *
41      * @param q_mgr  The quests manager to associate this quest with.
42      * @param hero   The Id of the Hero who is responsible for the quest.
43      */
44     QuestEnemyArmytype(QuestsManager& q_mgr, guint32 hero);
45
46     //! Loading constructor.
47     /**
48      * @param q_mgr   The quests manager to associate this quest with.
49      * @param helper  The opened saved-game file to load this quest from.
50      */
51     QuestEnemyArmytype(QuestsManager& q_mgr, XML_Helper* helper);
52
53     // Construct from remote action.
54     QuestEnemyArmytype(QuestsManager& q_mgr, guint32 hero, guint32 type_to_kill);
55
56     // Get Methods
57
58     //! Return a description of how the quest is going.
59     std::string getProgress() const;
60
61     //! Return a queue of strings to show when the quest is compeleted.
62     void getSuccessMsg(std::queue<std::string>& msgs) const;
63
64     //! Return a queue of strings to show when the quest has expired.
65     void getExpiredMsg(std::queue<std::string>& msgs) const;
66
67     //! Returns the target army type the Hero must kill.
68     /**
69      * @return The index of the Army protoype in the Armyset belonging to
70      *         the Player who owns the Hero responsible for this Quest.
71      */
72     guint32 getArmytypeToKill() {return d_type_to_kill;}
73
74
75     // Methods that opreate on the class data and do not modify the class.
76
77     //! Saves the kill-armytype quest data to an opened saved-game file.
78     bool save(XML_Helper* helper) const;
79
80
81     // Methods that need to be implemented from the superclass.
82
83     //!Callback when an Army object is killed.
84     /**
85      * This method is used to check when the Hero kills the correct army
86      * type.
87      *
88      * @param army           A pointer to the Army object that has been
89      *                       killed.
90      * @param heroIsCulprit  Whether or not the Hero object responsible for
91      *                       this Quest was involved with the killing of
92      *                       the given Army object.
93      */
94     void armyDied(Army *a, bool heroIsCulprit);
95
96     //! Callback for when a City is defeated.
97     /**
98      * @note This method is not used.
99      */
100     void cityAction(City *c, CityDefeatedAction action, 
101                     bool heroIsCulprit, int gold);
102
103
104     // Static Methods
105
106     //! Returns whether or not this quest is impossible.
107     /**
108      * Scans all of the Stack objects for each Player in the Playerlist 
109      * for Army objects that are awardable.  Pick a random one.
110      *
111      * @param heroId  The Id of the Hero responsible for the kill-armytype
112      *                quest.
113      *
114      * @return Whether or not the quest is possible.
115      */
116     static bool isFeasible(guint32 heroId);
117
118 private:
119
120     //! Generate a description of the Quest.
121     void initDescription();
122
123     //! The kind of Army object the Hero must kill to succeed.
124     /**
125      * The index of the Army protoype in the Armyset belonging to the 
126      * Player who owns the Hero responsible for this Quest.
127      */
128     guint32 d_type_to_kill;
129 };
130
131 #endif