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_ENEMY_ARMYTYPES_H
19 #define QUEST_ENEMY_ARMYTYPES_H
21 #include <sigc++/trackable.h>
27 //! A Quest to kill one army of another Player's Army objects.
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.
34 class QuestEnemyArmytype : public Quest, public sigc::trackable
37 //! Default constructor.
39 * Make a new kill-armytype quest.
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.
44 QuestEnemyArmytype(QuestsManager& q_mgr, guint32 hero);
46 //! Loading constructor.
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.
51 QuestEnemyArmytype(QuestsManager& q_mgr, XML_Helper* helper);
53 // Construct from remote action.
54 QuestEnemyArmytype(QuestsManager& q_mgr, guint32 hero, guint32 type_to_kill);
58 //! Return a description of how the quest is going.
59 std::string getProgress() const;
61 //! Return a queue of strings to show when the quest is compeleted.
62 void getSuccessMsg(std::queue<std::string>& msgs) const;
64 //! Return a queue of strings to show when the quest has expired.
65 void getExpiredMsg(std::queue<std::string>& msgs) const;
67 //! Returns the target army type the Hero must kill.
69 * @return The index of the Army protoype in the Armyset belonging to
70 * the Player who owns the Hero responsible for this Quest.
72 guint32 getArmytypeToKill() {return d_type_to_kill;}
75 // Methods that opreate on the class data and do not modify the class.
77 //! Saves the kill-armytype quest data to an opened saved-game file.
78 bool save(XML_Helper* helper) const;
81 // Methods that need to be implemented from the superclass.
83 //!Callback when an Army object is killed.
85 * This method is used to check when the Hero kills the correct army
88 * @param army A pointer to the Army object that has been
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.
94 void armyDied(Army *a, bool heroIsCulprit);
96 //! Callback for when a City is defeated.
98 * @note This method is not used.
100 void cityAction(City *c, CityDefeatedAction action,
101 bool heroIsCulprit, int gold);
106 //! Returns whether or not this quest is impossible.
108 * Scans all of the Stack objects for each Player in the Playerlist
109 * for Army objects that are awardable. Pick a random one.
111 * @param heroId The Id of the Hero responsible for the kill-armytype
114 * @return Whether or not the quest is possible.
116 static bool isFeasible(guint32 heroId);
120 //! Generate a description of the Quest.
121 void initDescription();
123 //! The kind of Army object the Hero must kill to succeed.
125 * The index of the Army protoype in the Armyset belonging to the
126 * Player who owns the Hero responsible for this Quest.
128 guint32 d_type_to_kill;