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, 2009 Ben Asselstine
5 // Copyright (C) 2007, 2008 Ole Laursen
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 3 of the License, or
10 // (at your option) any later version.
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.
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
35 //! The bitwise OR-able special bonus that the Army gives.
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.
67 //! Various kinds of statistics that an instance of Army unit has.
69 * This enumeration assists in getting and setting of statistics in
70 * an instance of an Army unit.
73 //! How strong the Army unit is in battle.
75 //! The maximum number of hitpoints that the Army unit can have.
77 //! The maximum number of moves the Army unit has.
79 //! The various Tile::Type that the Army moves efficiently in.
81 //! The special bonus the Army has (Army::Bonus).
83 //! How far the Army unit can see on a hidden map.
85 //! If the Army unit is in a boat or not.
87 //! If the Army unit is having it's movement doubled/tripled or not.
92 ArmyBase(const ArmyBase& army);
94 //! Loading constructor.
95 ArmyBase(XML_Helper* helper);
97 //! Create an empty army base.
106 //! Set how much gold this unit requires per turn.
107 void setUpkeep(guint32 upkeep){d_upkeep = upkeep;}
109 //! Set the strength of the army.
110 void setStrength(guint32 strength) {d_strength = strength;}
112 //! Set how much XP this unit is worth when killed.
113 void setXpReward(double xp_value){d_xp_value = xp_value;}
118 //! Returns how many gold pieces this Army needs per turn.
119 guint32 getUpkeep() const {return d_upkeep;}
122 //! Get the army bonus of the army.
123 guint32 getArmyBonus() const {return d_army_bonus;}
125 //! Get the move bonus.
127 * Get which kinds of terrain tiles this Army moves efficiently
130 * @return A bitwise OR-ing of the values in Tile::Type.
132 guint32 getMoveBonus() const {return d_move_bonus;}
134 //! Get the move bonus of the army.
135 guint32 getMaxMoves() const {return d_max_moves;}
137 //! Get the strength of the army.
138 guint32 getStrength() const {return d_strength;}
140 //! Get the distance this army can see on a hidden map.
142 * As this army walks on the map, it defogs the map with this radius.
144 guint32 getSight() const {return d_sight;}
146 //! Gets an easy to read string that represents the army's bonuses.
147 std::string getArmyBonusDescription() const;
149 //! Returns the number of XP that killing this Army garners it's killer.
150 double getXpReward() const {return d_xp_value;}
154 //! Convert an ArmyBase::Bonus string to a bitwise OR'd value.
156 * Converts a string containing the string representations of one
157 * or more ArmyBase::Bonus values to a bitwise OR'd value of those
158 * ArmyBase::Bonus values. The terms are separated with a pipe `|'.
160 static guint32 bonusFlagsFromString(const std::string str);
162 //! Convert a series of ArmyBase::Bonus enum values to a string.
164 * Converts a bitwise OR'd value that represents many ArmyBase::Bonus
165 * enumerated values into a string, where the terms are separated by a
168 static std::string bonusFlagsToString(const guint32 bonus);
170 //! Convert an ArmyBase::Bonus string to it's enum value.
172 * Converts a string containing a string representation of an
173 * ArmyBase::Bonus enumerated value, and converts it to it's enumerated
176 static ArmyBase::Bonus bonusFlagFromString(const std::string str);
178 //! Convert an ArmyBase::Bonus enum value to a string.
179 static std::string bonusFlagToString(const ArmyBase::Bonus bonus);
181 //! Convert a Tile::Type string to a bitwise OR'd value.
183 * Converts a string containing the string representations of one
184 * or more Tile::Type values to a bitwise OR'd value of those
185 * Tile::Type values. The terms are separated with a pipe `|'.
187 static guint32 moveFlagsFromString(const std::string str);
189 //! Convert a series of Tile::Type enumerated values to a string.
191 * Converts a bitwise OR'd value that represents many Tile::Type
192 * enumerated values into a string, where the terms are separated by a
195 static std::string moveFlagsToString(const guint32 move_bonus);
199 //! Generic method for saving Army base data.
200 bool saveData(XML_Helper* helper) const;
202 //! The amount it costs to maintain this Army unit for this turn.
204 * @note The amount is in gold pieces.
206 * This value does not change during gameplay.
208 * @note Some special units have an upkeep of 0, but usually this
209 * value is more than zero.
214 * The strength of the Army unit is the prime factor when
215 * calculating the outcome of a Fight. This value should always
216 * be 1 or more, but not exceeding 15.
218 * This value can permanently increase when the Army unit increases
221 * Temporary increases due to the Army unit being on a certain kind
222 * of terrain, or because another Army unit has conferred strength
223 * on it (see Army::Bonus) are not reflected in d_strength.
225 * This value does not decrease during gameplay.
227 //! The base strength of the Army unit.
230 //! The maximum number of movement points that this Army unit has.
232 * This value must always be above 1. Sane values are above 7.
234 * This value can be permanently increased when the Army unit
235 * increases it's level.
237 * This value does not decrease during gameplay.
239 * @note When an Army unit is having it's movement doubled, or even
240 * tripled due to a Hero carrying an Item, this value does not
241 * reflect that doubling or tripling.
245 //! How far the Army unit can see on a hidden map.
247 * When a stack is moving on a hidden map, a certain number of
248 * tiles get illuminated or unshaded. d_sight is the radius of
249 * tiles that this Army unit can illuminate.
251 * This value can be permanently increased when the Army unit
252 * increases it's level.
254 * This value does not decrease during gameplay.
258 //! The movement bonus of the Army unit.
260 * d_move_bonus represents the terrain tiles that the Army unit
261 * can travel efficiently over. Traveling efficiently entails
262 * that it only costs 2 movement points to travel over that kind
263 * of terrain, no matter what the actual terrain movement value is.
265 * The movement bonus is a bitwise OR-ing of the values in
268 * When each of the members of Tile::Type are included in the
269 * d_move_bonus value, the Army unit is flying.
271 * This value does not change during gameplay.
273 guint32 d_move_bonus;
276 * d_army_bonus represents the special abilities this Army unit has.
277 * The special abilities are enumerated in Army::Bonus.
279 * The army bonus is a bitwise OR-ing of the values in Army::Bonus.
281 * This value does not change during gameplay.
283 //! The special capbilities of the Army unit.
284 guint32 d_army_bonus;
286 //! The amount of XP this Army unit worth when killed by an assailant.
288 * When this Army unit is killed, d_xp_value is added to the killer's
291 * This value must be over 0.
293 * This value does not change during gameplay.
301 #endif // ARMY_BASE_H