~ubuntu-branches/ubuntu/raring/lordsawar/raring

« back to all changes in this revision

Viewing changes to src/QCitySack.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Barry deFreese, Gonéri Le Bouder
  • Date: 2008-06-17 11:15:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080617111526-yjyvu9df50zmpdo0
Tags: 0.0.9-1
[ Barry deFreese ]
* New upstream release.
  + Fixes gcc-4.3 builds so drop ftbfs_gcc-4.3_fix.diff.
  + Add new build-dependency for libgnet-dev.
* Add simple man page for new lordsawar-tile-editor.
* Add desktop file for lordsawar-tile-editor.
* Remove French translation on install.

[ Gonéri Le Bouder ]
* bump Debian Policy to 3.8.0. No change needed.
* fix wording in the 0.0.8-3 entry of the Debian changelog

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef __QUEST_CITY_SACK_H
2
 
#define __QUEST_CITY_SACK_H
 
1
//  Copyright (C) 2007, 2008 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 2 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
#ifndef QUEST_CITY_SACK_H
 
18
#define QUEST_CITY_SACK_H
3
19
 
4
20
#include <sigc++/trackable.h>
5
21
 
6
22
#include <list>
7
23
#include "Quest.h"
8
24
 
9
 
 
10
25
class City;
11
26
class XML_Helper;
12
27
 
13
 
 
14
 
/** Class describing a city sack quest
15
 
  * 
16
 
  * A hero that receives this quest has to sack a specific city to fulfill
17
 
  * it.
18
 
  */
19
 
 
 
28
//! A Quest where the Hero must sack a City owned by another Player.
 
29
/**
 
30
 * A hero that receives this quest has to sack a specific city to fulfill
 
31
 * it.  The Quest is completed when this happens, but the quest is expired if
 
32
 * the user conquers the correct city but forgets to sack the city.
 
33
 *
 
34
 * Sacking involves cashing in all of the Army production bases that the City
 
35
 * offers, except for the weakest one.
 
36
 */
20
37
class QuestCitySack : public Quest, public sigc::trackable
21
38
{
22
39
    public:
23
 
        /** \brief Constructor - create a new quest */
 
40
        //! Default constructor.
 
41
        /**
 
42
         * Make a new city sacking quest.
 
43
         *
 
44
         * @param q_mgr  The quests manager to associate this quest with.
 
45
         * @param hero   The Id of the Hero who is responsible for the quest.
 
46
         */
24
47
        QuestCitySack(QuestsManager& q_mgr, Uint32 hero);
25
48
 
26
 
        /** \brief Constructor - create a new quest from
27
 
                   saved data */
 
49
        //! Loading constructor.
 
50
        /**
 
51
         * @param q_mgr   The quests manager to associate this quest with.
 
52
         * @param helper  The opened saved-game file to load this quest from.
 
53
         */
28
54
        QuestCitySack(QuestsManager& q_mgr, XML_Helper* helper);
29
55
 
30
 
         /**
31
 
          * \brief Checks if such a quest is possible at all.
32
 
          */
33
 
         static bool isFeasible(Uint32 heroId);
34
 
 
35
 
         //! Saves the quest data.
36
 
         bool save(XML_Helper* helper) const;
37
 
 
 
56
        // Construct from remote action.
 
57
        QuestCitySack(QuestsManager& q_mgr, Uint32 hero, Uint32 target);
 
58
        
 
59
        //! Returns whether or not this quest is impossible.
38
60
        /**
39
 
         * \brief Get progress information 
40
 
         *
41
 
         * \param s here we append the progress information
 
61
         * Scans all City objects in the Citylist to see if there is one the 
 
62
         * active player can sack.
 
63
         *
 
64
         * @note This method is static because it is executed before the
 
65
         *       Quest is instantiated.  It is also called from within the
 
66
         *       instantiated Quest.
 
67
         *
 
68
         * @param heroId  The Id of the Hero responsible for the sacking quest.
 
69
         *
 
70
         * @return Whether or not the quest is possible.
42
71
         */
 
72
        static bool isFeasible(Uint32 heroId);
 
73
 
 
74
        //! Saves the sacking quest data to an opened saved-game file.
 
75
        bool save(XML_Helper* helper) const;
 
76
 
 
77
        //! Return a description of how well the city sacking quest is going.
43
78
        std::string getProgress() const;
44
79
 
45
 
        /**
46
 
         * \brief Provide the lines of the message describing
47
 
                  the quest completion.
48
 
         */
 
80
        //! Return a queue of strings to show when the quest is compeleted.
49
81
         void getSuccessMsg(std::queue<std::string>& msgs) const;
50
82
 
51
 
         /**
52
 
         * \brief Provide the lines of the message describing
53
 
                  the quest completion.
54
 
         */
 
83
        //! Return a queue of strings to show when the quest has expired.
55
84
        void getExpiredMsg(std::queue<std::string>& msgs) const;
56
85
 
57
 
 
58
 
         //! Returns the id of the city to be sacked
59
 
         Uint32 getCityId() const {return d_city;}
60
 
 
61
 
         //! Returns the city to be sacked
62
 
         City* getCity() const;
63
 
 
64
 
         void armyDied(Army *a, bool heroIsCulprit);
65
 
         void cityAction(City *c, CityDefeatedAction action, 
66
 
                               bool heroIsCulprit, int gold);
 
86
        //! Returns the id of the City object to be sacked.
 
87
        Uint32 getCityId() const {return d_city;}
 
88
 
 
89
        //! Returns a pointer to the City object to be sacked.
 
90
        City* getCity() const;
 
91
 
 
92
        //! Callback for when an Army object is killed.
 
93
        /**
 
94
         * @note This method is not used.
 
95
         */
 
96
        void armyDied(Army *a, bool heroIsCulprit);
 
97
 
 
98
        //! Callback for when a City object is defeated.
 
99
        /**
 
100
         * This method notifies the Quest that a City has fallen, and what the 
 
101
         * conquering action (pillage/sack/raze/occupy) was.  It also notifies
 
102
         * whether or not the hero responsible for this quest was involved in 
 
103
         * the conquering, and how much gold was taken as a result.
 
104
         *
 
105
         * If the city isn't sacked then the Quest is expired.
 
106
         * If the city is sacked then the Quest is completed.
 
107
         *
 
108
         * @param city           The City object that has been conquered.
 
109
         * @param action         What action was taken by the Player.  See
 
110
         *                       CityDefeatedAction for more information.
 
111
         * @param heroIsCulprit  Whether or not the Hero object associated with
 
112
         *                       this Quest object is responsible for 
 
113
         *                       conquering the given City object.
 
114
         * @param gold           How many gold pieces were taken as a result
 
115
         *                       of the action.
 
116
         */
 
117
        void cityAction(City *city, CityDefeatedAction action, 
 
118
                        bool heroIsCulprit, int gold);
67
119
    private:
68
120
 
69
 
         /** \brief Make quest description from the city we'll sack */
70
 
         void initDescription();
 
121
        //! Make a quest description about the city that needs to be sacked.
 
122
        void initDescription();
71
123
         
72
 
         /** \brief Select a victim city */
73
 
         static City* chooseToSack(Player *p);
 
124
        //! Return a pointer to a random city not owned by the given player.
 
125
        /**
 
126
         * Find a city to sack.
 
127
         *
 
128
         * Scan through all of the City objects in the Citylist for a city
 
129
         * that is not owned by the given player or by neutral.  Pick a random
 
130
         * one that has more than 1 Army production base and return it.
 
131
         *
 
132
         * @param player  The player whose City objects are exempt from being
 
133
         *                selected as a target for sacking.
 
134
         *
 
135
         * @return A pointer to a City object that can be sacked by the Hero.
 
136
         *         If no valid City objects are found, this method returns NULL.
 
137
         */
 
138
        static City* chooseToSack(Player *p);
74
139
 
75
 
         /** city id to be sacked by the hero */
76
 
         Uint32 d_city;
 
140
        //! The Id of the target City object to sack.
 
141
        Uint32 d_city;
77
142
};
78
143
 
79
144
#endif