1 // Copyright (C) 2007, 2008, 2009, 2014, 2015 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 #pragma once 19 #ifndef QUEST_PILLAGE_GOLD_H 20 #define QUEST_PILLAGE_GOLD_H 21 22 #include <sigc++/trackable.h> 23 24 #include <list> 25 #include "Quest.h" 26 27 class City; 28 class Army; 29 30 //! A Quest to accrue an amount of gold pieces from another Player. 31 /** 32 * The Hero is required to conquer cities and obtain a given amount of gold 33 * pieces from a victim Player. Sacking and pillaging means to cash-in Army 34 * production bases from conquered cities. 35 * 36 * The quest succeeds when the Player successfully accrues the given amount 37 * of gold pieces. This quest never expires. 38 */ 39 class QuestPillageGold : public Quest, public sigc::trackable 40 { 41 public: 42 //! Default constructor. 43 /** 44 * Make a new sack and pillage quest. 45 * 46 * @param q_mgr The quests manager to associate this quest with. 47 * @param hero The Id of the Hero who is responsible for the quest. 48 */ 49 QuestPillageGold(QuestsManager& q_mgr, guint32 hero); 50 51 //! Destructor. ~QuestPillageGold()52 ~QuestPillageGold() {}; 53 54 //! Loading constructor. 55 /** 56 * @param q_mgr The quests manager to associate this quest with. 57 * @param helper The opened saved-game file to load this quest from. 58 */ 59 QuestPillageGold(QuestsManager& q_mgr, XML_Helper* helper); 60 61 // Construct from remote action. 62 QuestPillageGold(QuestsManager& q_mgr, guint32 hero, guint32 gold); 63 64 65 // Get Methods 66 67 //! Return a description of how many gold pieces have been accrued. 68 Glib::ustring getProgress() const; 69 70 //! Return a queue of strings to show when the quest is compeleted. 71 void getSuccessMsg(std::queue<Glib::ustring>& msgs) const; 72 73 //! Return a queue of strings to show when the quest has expired. 74 void getExpiredMsg(std::queue<Glib::ustring>& msgs) const; 75 76 //! Returns the amount of gold to be pillaged. getGoldToPillage()77 guint32 getGoldToPillage() {return d_to_pillage;} 78 79 80 // Methods that operate on the class data and do not modify the class. 81 82 //! Saves the sack and pillage quest data to an opened saved-game file. 83 bool save(XML_Helper* helper) const; 84 85 86 // Methods that need to be implemented from the superclass. 87 88 //! Callback for when an Army object is killed. 89 /** 90 * @note This method is not used. 91 */ 92 void armyDied(Army *a, bool heroIsCulprit); 93 94 //! Callback for when a City object is defeated. 95 /** 96 * This method notifies the Quest that a City has fallen, and what the 97 * conquering action (pillage/sack/raze/occupy) was. It also notifies 98 * whether or not the hero responsible for this quest was involved in 99 * the conquering, and how much gold was taken as a result. 100 * 101 * The amount of gold is added to Quest_Pillage::d_pillaged. 102 * 103 * @param city The City object that has been conquered. 104 * @param action What action was taken by the Player. See 105 * CityDefeatedAction for more information. 106 * @param heroIsCulprit Whether or not the Hero object associated with 107 * this Quest object is responsible for 108 * conquering the given City object. 109 * @param gold How many gold pieces were taken as a result 110 * of the action. 111 */ 112 void cityAction(City *city, CityDefeatedAction action, 113 bool heroIsCulprit, int gold); 114 115 116 // Static Methods 117 118 //! Returns that this quest is feasible. 119 static bool isFeasible(guint32 heroId); 120 121 private: 122 123 //! Generate a description of the Quest. 124 void initDescription(); 125 126 // DATA 127 128 //! The amount of gold pieces to sack and pillage to succeed. 129 guint32 d_to_pillage; 130 131 //! The number of gold pieces already sacked and pillaged. 132 guint32 d_pillaged; 133 134 //! The player whose cities this quest is targetting. 135 Player *d_victim_player; 136 137 }; 138 139 #endif 140