1 // Copyright (C) 2003, 2004, 2005 Ulf Lorenz
2 // Copyright (C) 2004 Andrea Paternesi
3 // Copyright (C) 2007, 2008, 2009, 2014 Ben Asselstine
4 // Copyright (C) 2008 Ole Laursen
5 //
6 //  This program is free software; you can redistribute it and/or modify
7 //  it under the terms of the GNU General Public License as published by
8 //  the Free Software Foundation; either version 3 of the License, or
9 //  (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU Library General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 //  02110-1301, USA.
20 
21 #pragma once
22 #ifndef QUEST_KILL_HERO_H
23 #define QUEST_KILL_HERO_H
24 
25 #include <sigc++/trackable.h>
26 
27 #include <list>
28 #include "Quest.h"
29 #include "playerlist.h"
30 
31 class Hero;
32 class Army;
33 
34 //! A Quest to kill another Player's Hero.
35 /**
36  * A hero that receives this quest has to kill a particular Hero.  The Quest
37  * is completed when this happens, or the quest is expired if enemy Hero dies.
38  */
39 class QuestKillHero : public Quest, public sigc::trackable
40 {
41 public:
42 
43     //! Default constructor.
44     /**
45      * Make a new kill-hero quest.
46      *
47      * @param q_mgr  The quests manager to associate this quest with.
48      * @param hero   The Id of the Hero who is responsible for the quest.
49      */
50     QuestKillHero(QuestsManager& q_mgr, guint32 hero);
51 
52     //! Destructor.
~QuestKillHero()53     ~QuestKillHero() {};
54 
55     //! Loading constructor.
56     /**
57      * @param q_mgr   The quests manager to associate this quest with.
58      * @param helper  The opened saved-game file to load this quest from.
59      */
60     QuestKillHero(QuestsManager& q_mgr, XML_Helper* helper);
61 
62     // Construct from remote action.
63     QuestKillHero(QuestsManager& q_mgr, guint32 hero, guint32 victim);
64 
65 
66     // Get Methods
67 
68     //! Return a description of how well the quest to kill a hero is going.
69     Glib::ustring getProgress() const;
70 
71     //! Return a queue of strings to show when the quest is compeleted.
72     void getSuccessMsg(std::queue<Glib::ustring>& msgs) const;
73 
74     //! Return a queue of strings to show when the quest has expired.
75     void getExpiredMsg(std::queue<Glib::ustring>& msgs) const;
76 
77     //! Returns the Id of the hunted hero object.
getVictim()78     guint32 getVictim() const {return d_victim;}
79 
80 
81     // Methods that operate on the class data and do not modify the class.
82 
83     //! Saves the kill-hero quest data to an opened saved-game file.
84     bool save(XML_Helper* helper) const;
85 
86 
87     // Methods that need to be implemented from the superclass.
88 
89     //! Callback for when an Army object is killed.
90     /**
91      * This method is used to check when the Hero responsible for the
92      * quest kills the Hero that is the target of this quest.
93      *
94      * @param army           A pointer to the Army object that has been
95      *                       killed.
96      * @param heroIsCulprit  Whether or not the Hero object responsible for
97      *                       this Quest was involved with the killing of
98      *                       the given Army object.
99      */
100     void armyDied(Army *a, bool heroIsCulprit);
101 
102     //! Callback for when a City is defeated.
103     /**
104      * @note This method is not used.
105      */
106     void cityAction(City *c, CityDefeatedAction action,
107 		    bool heroIsCulprit, int gold);
108 
109 
110     // Static Methods
111 
112     //! Returns whether or not this quest is impossible.
113     /**
114      * Checks to see if any Players have a Hero to target.
115      *
116      * @param heroId  The Id of the Hero responsible for the kill-hero
117      *                quest.
118      *
119      * @return Whether or not the quest is possible.
120      */
121     static bool isFeasible(guint32 heroId);
122 
123 private:
124 
125     //! Generate a description of the Quest.
126     void initDescription();
127 
128     //! Choose a hero to be killed.
129     /**
130      * @return A pointer to the Hero object to be the target for this
131      *         quest.
132      */
133     static Hero* chooseToKill();
134 
135     //! The Id of the Hero object to be hunted and killed.
136     guint32 d_victim;
137 };
138 
139 #endif
140