~ubuntu-branches/ubuntu/saucy/lordsawar/saucy

« back to all changes in this revision

Viewing changes to src/armybase.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Barry deFreese
  • Date: 2008-12-20 13:52:12 UTC
  • mfrom: (1.1.6 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20081220135212-noeb2w3y98ebo7o9
Tags: 0.1.4-1
[ Barry deFreese ]
* New upstream release.
* Move 0.0.8-2.1 changelog entry to correct point in changelog.
* Make lordsawar-data suggest lordsawar.
* Update my e-mail address.
* Add build-depends on intltool, uuid-dev, and libboost-dev.
* Don't install locales since there are no translations currently.
* Add simple man page for new lordsawar-pbm binary.
* Drop gcc4.3 patches as they have been fixed upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2000, 2001, 2003 Michael Bartl
 
2
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Ulf Lorenz
 
3
// Copyright (C) 2004, 2005 Andrea Paternesi
 
4
// Copyright (C) 2007, 2008 Ben Asselstine
 
5
// Copyright (C) 2007, 2008 Ole Laursen
 
6
//
 
7
//  This program is free software; you can redistribute it and/or modify
 
8
//  it under the terms of the GNU General Public License as published by
 
9
//  the Free Software Foundation; either version 2 of the License, or
 
10
//  (at your option) any later version.
 
11
//
 
12
//  This program is distributed in the hope that it will be useful,
 
13
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
//  GNU Library General Public License for more details.
 
16
//
 
17
//  You should have received a copy of the GNU General Public License
 
18
//  along with this program; if not, write to the Free Software
 
19
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
 
20
//  02110-1301, USA.
 
21
 
 
22
#ifndef ARMY_BASE_H
 
23
#define ARMY_BASE_H
 
24
 
 
25
#include <SDL.h>
 
26
#include <string>
 
27
 
 
28
 
 
29
class XML_Helper;
 
30
 
 
31
class ArmyBase
 
32
{
 
33
    public:
 
34
 
 
35
        //! The bitwise OR-able special bonus that the Army gives.
 
36
        enum Bonus {
 
37
          //! Provides +1 strength to the Army when positioned in the open.
 
38
          ADD1STRINOPEN      = 0x00000001,
 
39
          //! Provides +2 strength to the Army when positioned in the open.
 
40
          ADD2STRINOPEN      = 0x00000002,
 
41
          //! Provides +1 strength to the Army when positioned in the forest.
 
42
          ADD1STRINFOREST    = 0x00000004,
 
43
          //! Provides +1 strength to the Army when positioned in the hills.
 
44
          ADD1STRINHILLS     = 0x00000008, 
 
45
          //! Provides +1 strength to the Army when positioned in a City.
 
46
          ADD1STRINCITY      = 0x00000010,
 
47
          //! Provides +2 strength to the Army when positioned in a City.
 
48
          ADD2STRINCITY      = 0x00000020,
 
49
          //! Provides +1 strength to the Stack when positioned in the hills.
 
50
          ADD1STACKINHILLS   = 0x00000040,
 
51
          //! Negate any City bonuses from an enemy Stack during a Fight.
 
52
          SUBALLCITYBONUS    = 0x00000080,
 
53
          //! Negates 1 strength point from an enemy Stack during a Fight.
 
54
          SUB1ENEMYSTACK     = 0x00000100,
 
55
          //! Provides +1 strength to all Army units in the Stack.
 
56
          ADD1STACK          = 0x00000200,
 
57
          //! Provides +2 strength to all Army units in the Stack.
 
58
          ADD2STACK          = 0x00000400,
 
59
          //! Negate all non-Hero bonuses in an enemy Stack during a Fight.
 
60
          SUBALLNONHEROBONUS = 0x00000800,
 
61
          //! Negate all Hero bonuses in an enemy Stack during a Fight.
 
62
          SUBALLHEROBONUS    = 0x00001000, //0 enemy hero bonus
 
63
          //! Provides a +1 strength to all Army units in a fortified Stack.
 
64
          FORTIFY            = 0x00002000,
 
65
        };
 
66
        static Uint32 bonusFlagsFromString(const std::string str);
 
67
        static std::string bonusFlagsToString(const Uint32 bonus);
 
68
        static ArmyBase::Bonus bonusFlagFromString(const std::string str);
 
69
        static std::string bonusFlagToString(const ArmyBase::Bonus bonus);
 
70
        
 
71
        //! Various kinds of statistics that an instance of Army unit has.
 
72
        /**
 
73
         * This enumeration assists in getting and setting of statistics in
 
74
         * an instance of an Army unit.
 
75
         */
 
76
        enum Stat {
 
77
          //! How strong the Army unit is in battle.
 
78
          STRENGTH = 0,
 
79
          //! The maximum number of hitpoints that the Army unit can have.
 
80
          HP = 3,
 
81
          //! The maximum number of moves the Army unit has.
 
82
          MOVES = 4,
 
83
          //! The various Tile::Type that the Army moves efficiently in.
 
84
          MOVE_BONUS = 5,
 
85
          //! The special bonus the Army has (Army::Bonus).
 
86
          ARMY_BONUS = 6,
 
87
          //! How far the Army unit can see on a hidden map.
 
88
          SIGHT = 7,
 
89
          //! If the Army unit is in a boat or not.
 
90
          SHIP = 8,
 
91
          //! If the Army unit is having it's movement doubled/tripled or not.
 
92
          MOVES_MULTIPLIER = 9,
 
93
        };
 
94
 
 
95
        static Uint32 moveFlagsFromString(const std::string str);
 
96
        static std::string moveFlagsToString(const Uint32 move_bonus);
 
97
 
 
98
        //! Copy constructor.
 
99
        ArmyBase(const ArmyBase& army);
 
100
 
 
101
        //! Loading constructor.
 
102
        ArmyBase(XML_Helper* helper);
 
103
        
 
104
        //! Create an empty army base.
 
105
        ArmyBase();
 
106
 
 
107
        //! Destructor.
 
108
        ~ArmyBase();
 
109
 
 
110
        // Set functions:
 
111
        
 
112
        //! Set how much gold this unit requires per turn.
 
113
        void setUpkeep(Uint32 upkeep){d_upkeep = upkeep;}
 
114
        
 
115
        //! Set the strength of the army.
 
116
        void setStrength(Uint32 strength) {d_strength = strength;}
 
117
 
 
118
        // Get functions
 
119
        
 
120
        //! Returns how many gold pieces this Army needs per turn.
 
121
        Uint32 getUpkeep() const {return d_upkeep;}
 
122
        
 
123
 
 
124
        //! Get the army bonus of the army.
 
125
        Uint32 getArmyBonus() const {return d_army_bonus;}
 
126
 
 
127
        //! Get the move bonus.
 
128
        /**
 
129
         * Get which kinds of terrain tiles this Army moves efficiently 
 
130
         * over top of.
 
131
         *
 
132
         * @return A bitwise OR-ing of the values in Tile::Type.
 
133
         */
 
134
        Uint32 getMoveBonus() const {return d_move_bonus;}
 
135
 
 
136
        //! Get the move bonus of the army.
 
137
        Uint32 getMaxMoves() const {return d_max_moves;}
 
138
 
 
139
        //! Get the strength of the army.
 
140
        Uint32 getStrength() const {return d_strength;}
 
141
 
 
142
        //! Get the distance this army can see on a hidden map.
 
143
        Uint32 getSight() const {return d_sight;}
 
144
 
 
145
        std::string getArmyBonusDescription() const;
 
146
 
 
147
        //! Set how much XP this unit is worth when killed.
 
148
        void setXpReward(double xp_value){d_xp_value = xp_value;}
 
149
 
 
150
        //! Returns the number of XP that killing this Army garners it's killer.
 
151
        double getXpReward() const {return d_xp_value;}
 
152
    protected:
 
153
 
 
154
        //! Generic method for saving Army base data.
 
155
        bool saveData(XML_Helper* helper) const;
 
156
 
 
157
        //! The amount it costs to maintain this Army unit for this turn.
 
158
        /**
 
159
         * @note The amount is in gold pieces.
 
160
         *
 
161
         * This value does not change during gameplay.
 
162
         *
 
163
         * @note Some special units have an upkeep of 0, but usually this
 
164
         * value is more than zero.
 
165
         */
 
166
        Uint32 d_upkeep;
 
167
 
 
168
        /**
 
169
         * The strength of the Army unit is the prime factor when 
 
170
         * calculating the outcome of a Fight.  This value should always
 
171
         * be 1 or more, but not exceeding 15.
 
172
         *
 
173
         * This value can permanently increase when the Army unit increases
 
174
         * it's level.
 
175
         *
 
176
         * Temporary increases due to the Army unit being on a certain kind 
 
177
         * of terrain, or because another Army unit has conferred strength 
 
178
         * on it (see Army::Bonus) are not reflected in d_strength.
 
179
         *
 
180
         * This value does not decrease during gameplay.
 
181
         */
 
182
        //! The base strength of the Army unit.
 
183
        Uint32 d_strength;
 
184
 
 
185
        //! The maximum number of movement points that this Army unit has.
 
186
        /**
 
187
         * This value must always be above 1.  Sane values are above 7.
 
188
         *
 
189
         * This value can be permanently increased when the Army unit 
 
190
         * increases it's level.
 
191
         *
 
192
         * This value does not decrease during gameplay.
 
193
         *
 
194
         * @note When an Army unit is having it's movement doubled, or even
 
195
         * tripled due to a Hero carrying an Item, this value does not 
 
196
         * reflect that doubling or tripling.
 
197
         */
 
198
        Uint32 d_max_moves;
 
199
 
 
200
        //! How far the Army unit can see on a hidden map.
 
201
        /**
 
202
         * When a stack is moving on a hidden map, a certain number of
 
203
         * tiles get illuminated or unshaded.  d_sight is the radius of
 
204
         * tiles that this Army unit can illuminate.
 
205
         *
 
206
         * This value can be permanently increased when the Army unit 
 
207
         * increases it's level.
 
208
         *
 
209
         * This value does not decrease during gameplay.
 
210
         */
 
211
        Uint32 d_sight;
 
212
 
 
213
        //! The movement bonus of the Army unit.
 
214
        /**
 
215
         * d_move_bonus represents the terrain tiles that the Army unit
 
216
         * can travel efficiently over.  Traveling efficiently entails
 
217
         * that it only costs 2 movement points to travel over that kind
 
218
         * of terrain, no matter what the actual terrain movement value is.
 
219
         *
 
220
         * The movement bonus is a bitwise OR-ing of the values in 
 
221
         * Tile::Type.
 
222
         *
 
223
         * When each of the members of Tile::Type are included in the
 
224
         * d_move_bonus value, the Army unit is flying.
 
225
         *
 
226
         * This value does not change during gameplay.
 
227
         */
 
228
        Uint32 d_move_bonus;
 
229
 
 
230
        /**
 
231
         * d_army_bonus represents the special abilities this Army unit has.
 
232
         * The special abilities are enumerated in Army::Bonus.
 
233
         *
 
234
         * The army bonus is a bitwise OR-ing of the values in Army::Bonus.
 
235
         *
 
236
         * This value does not change during gameplay.
 
237
         */
 
238
        //! The special capbilities of the Army unit.
 
239
        Uint32 d_army_bonus;
 
240
 
 
241
        //! The amount of XP this Army unit worth when killed by an assailant.
 
242
        /**
 
243
         * When this Army unit is killed, d_xp_value is added to the killer's
 
244
         * experience points.
 
245
         *
 
246
         * This value must be over 0.
 
247
         *
 
248
         * This value does not change during gameplay.
 
249
         */
 
250
        double d_xp_value;
 
251
 
 
252
 
 
253
    private:
 
254
};
 
255
 
 
256
#endif // ARMY_BASE_H