~ubuntu-branches/ubuntu/maverick/lordsawar/maverick

« back to all changes in this revision

Viewing changes to src/QCitySack.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2010-04-10 09:29:33 UTC
  • mfrom: (1.1.9 upstream) (5.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100410092933-23uq4dxig30kmtcw
Tags: 0.1.8-1
* New upstream release.
* Add misc:Depends for -data package.
* Bump Standards Version to 3.8.4. (No changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//  Copyright (C) 2007, 2008 Ben Asselstine
 
1
//  Copyright (C) 2007, 2008, 2009 Ben Asselstine
2
2
//
3
3
//  This program is free software; you can redistribute it and/or modify
4
4
//  it under the terms of the GNU General Public License as published by
36
36
 */
37
37
class QuestCitySack : public Quest, public sigc::trackable
38
38
{
39
 
    public:
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
 
         */
47
 
        QuestCitySack(QuestsManager& q_mgr, guint32 hero);
48
 
 
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
 
         */
54
 
        QuestCitySack(QuestsManager& q_mgr, XML_Helper* helper);
55
 
 
56
 
        // Construct from remote action.
57
 
        QuestCitySack(QuestsManager& q_mgr, guint32 hero, guint32 target);
58
 
        
59
 
        //! Returns whether or not this quest is impossible.
60
 
        /**
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.
71
 
         */
72
 
        static bool isFeasible(guint32 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.
78
 
        std::string getProgress() const;
79
 
 
80
 
        //! Return a queue of strings to show when the quest is compeleted.
81
 
         void getSuccessMsg(std::queue<std::string>& msgs) const;
82
 
 
83
 
        //! Return a queue of strings to show when the quest has expired.
84
 
        void getExpiredMsg(std::queue<std::string>& msgs) const;
85
 
 
86
 
        //! Returns the id of the City object to be sacked.
87
 
        guint32 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);
119
 
    private:
120
 
 
121
 
        //! Make a quest description about the city that needs to be sacked.
122
 
        void initDescription();
123
 
         
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);
139
 
 
140
 
        //! The Id of the target City object to sack.
141
 
        guint32 d_city;
 
39
public:
 
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
     */
 
47
    QuestCitySack(QuestsManager& q_mgr, guint32 hero);
 
48
 
 
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
     */
 
54
    QuestCitySack(QuestsManager& q_mgr, XML_Helper* helper);
 
55
 
 
56
    // Construct from remote action.
 
57
    QuestCitySack(QuestsManager& q_mgr, guint32 hero, guint32 target);
 
58
 
 
59
    // Get Methods
 
60
 
 
61
    //! Return a description of how well the city sacking quest is going.
 
62
    std::string getProgress() const;
 
63
 
 
64
    //! Return a queue of strings to show when the quest is compeleted.
 
65
    void getSuccessMsg(std::queue<std::string>& msgs) const;
 
66
 
 
67
    //! Return a queue of strings to show when the quest has expired.
 
68
    void getExpiredMsg(std::queue<std::string>& msgs) const;
 
69
 
 
70
    //! Returns the id of the City object to be sacked.
 
71
    guint32 getCityId() const {return d_city;}
 
72
 
 
73
 
 
74
    // Methods that operate on the class data but do not modify the class.
 
75
 
 
76
    //! Saves the sacking quest data to an opened saved-game file.
 
77
    bool save(XML_Helper* helper) const;
 
78
 
 
79
    //! Returns a pointer to the City object to be sacked.
 
80
    City* getCity() const;
 
81
 
 
82
 
 
83
    // Methods that need to be implemented from the superclass.
 
84
 
 
85
    //! Callback for when an Army object is killed.
 
86
    /**
 
87
     * @note This method is not used.
 
88
     */
 
89
    void armyDied(Army *a, bool heroIsCulprit);
 
90
 
 
91
    //! Callback for when a City object is defeated.
 
92
    /**
 
93
     * This method notifies the Quest that a City has fallen, and what the 
 
94
     * conquering action (pillage/sack/raze/occupy) was.  It also notifies
 
95
     * whether or not the hero responsible for this quest was involved in 
 
96
     * the conquering, and how much gold was taken as a result.
 
97
     *
 
98
     * If the city isn't sacked then the Quest is expired.
 
99
     * If the city is sacked then the Quest is completed.
 
100
     *
 
101
     * @param city           The City object that has been conquered.
 
102
     * @param action         What action was taken by the Player.  See
 
103
     *                       CityDefeatedAction for more information.
 
104
     * @param heroIsCulprit  Whether or not the Hero object associated with
 
105
     *                       this Quest object is responsible for 
 
106
     *                       conquering the given City object.
 
107
     * @param gold           How many gold pieces were taken as a result
 
108
     *                       of the action.
 
109
     */
 
110
    void cityAction(City *city, CityDefeatedAction action, 
 
111
                    bool heroIsCulprit, int gold);
 
112
 
 
113
 
 
114
    // Static Methods
 
115
 
 
116
    //! Returns whether or not this quest is impossible.
 
117
    /**
 
118
     * Scans all City objects in the Citylist to see if there is one the 
 
119
     * active player can sack.
 
120
     *
 
121
     * @note This method is static because it is executed before the
 
122
     *       Quest is instantiated.  It is also called from within the
 
123
     *       instantiated Quest.
 
124
     *
 
125
     * @param heroId  The Id of the Hero responsible for the sacking quest.
 
126
     *
 
127
     * @return Whether or not the quest is possible.
 
128
     */
 
129
    static bool isFeasible(guint32 heroId);
 
130
 
 
131
private:
 
132
 
 
133
    //! Make a quest description about the city that needs to be sacked.
 
134
    void initDescription();
 
135
 
 
136
    //! Return a pointer to a random city not owned by the given player.
 
137
    /**
 
138
     * Find a city to sack.
 
139
     *
 
140
     * Scan through all of the City objects in the Citylist for a city
 
141
     * that is not owned by the given player or by neutral.  Pick a random
 
142
     * one that has more than 1 Army production base and return it.
 
143
     *
 
144
     * @param player  The player whose City objects are exempt from being
 
145
     *                selected as a target for sacking.
 
146
     *
 
147
     * @return A pointer to a City object that can be sacked by the Hero.
 
148
     *         If no valid City objects are found, this method returns NULL.
 
149
     */
 
150
    static City* chooseToSack(Player *p);
 
151
 
 
152
    //! The Id of the target City object to sack.
 
153
    guint32 d_city;
142
154
};
143
155
 
144
156
#endif