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
30 #include "armyprotobase.h"
35 class ArmyProto : public ArmyProtoBase
38 //! The xml tag of this object in an armyset configuration file.
39 static std::string d_tag;
42 ArmyProto(const ArmyProto& armyproto);
44 //! Loading constructor.
45 ArmyProto(XML_Helper* helper);
47 //! Default constructor. Create an empty army prototype.
56 //! Sets the filename of the image.
57 void setImageName(Shield::Colour c,std::string name) {d_image_name[c] = name;}
59 //! Set the basic image of the Army.
60 void setImage(Shield::Colour c, PixMask* image) {d_image[c] = image;};
62 //! Set the image mask of the unit type (for player colours).
63 void setMask(Shield::Colour c, PixMask* mask) {d_mask[c] = mask;};
65 //! Sets whether or not this Army prototype can found in a ruin.
66 void setDefendsRuins(bool defends) {d_defends_ruins = defends; }
69 * Sets whether or not this Army prototype can be a reward for
70 * Quest, or if Army units of this kind can accompany a new
71 * Hero when one emerges in a City.
73 //! Sets the awardable state of an Army prototype.
74 void setAwardable (bool awardable) {d_awardable = awardable; }
76 //! Sets the gender of the army prototype.
77 void setGender(Hero::Gender g) {d_gender = g;};
82 //! Returns the basename of the picture's filename
84 * Returns the filename that holds the image for this Army.
85 * The filename does not have a path, and the filename does
86 * not have an extension (e.g. .png).
88 std::string getImageName(Shield::Colour c) const {return d_image_name[c];}
90 //! Get the image of the army prototype.
91 PixMask* getImage(Shield::Colour c) const {return d_image[c];};
93 //! Returns the mask (read-only) for player colors.
94 PixMask* getMask(Shield::Colour c) const {return d_mask[c];}
96 //! Gets whether or not this army type can found in a ruin.
97 bool getDefendsRuins() const {return d_defends_ruins; }
100 * Gets whether or not this army can be a reward for completing a
101 * Quest, or if an Army unit of this type can accompany a new
102 * Hero when one emerges in a City.
104 //! Gets the awardable state of the Army.
105 bool getAwardable() const {return d_awardable; }
107 //! Returns whether or not the Army prototype is a Hero.
108 bool isHero() const {return d_gender != Hero::NONE;};
110 //! Returns the gender of the army prototype.
111 Hero::Gender getGender() const {return d_gender;};
113 // Methods that operate on class data and modify the class.
115 //! Load the pictures associated with this ArmyProto object.
116 void instantiateImages(Armyset *armyset);
118 //! Load the ArmyProto image in the given filename.
119 bool instantiateImages(int tilesize, Shield::Colour c, std::string image_filename);
121 //! Destroy the images associated with this ArmyProto object.
122 void uninstantiateImages();
124 // Methods that operate on class data and do not modify the class.
126 //! Saves the Army prototype to an opened armyset file.
127 virtual bool save(XML_Helper* helper) const;
131 //! Create an ArmyProto object that can walk well in hills and forest.
132 static ArmyProto * createScout();
134 //! Create an ArmyProto object that can fly.
135 static ArmyProto * createBat();
139 //! Callback to read this object from an opened file.
140 bool saveData(XML_Helper* helper) const;
144 //! The picture of the Army prototype.
146 * There is an image for each player, plus the neutral player.
148 PixMask* d_image[MAX_PLAYERS + 1];
150 //! The mask portion of the Army prototype picture.
151 PixMask* d_mask[MAX_PLAYERS + 1];
153 //! Whether or not the Army prototype can defend a Ruin.
155 * Some Army unit can be the guardian of a Ruin. Hero units fight
156 * a single Army unit of this kind when they search a Ruin.
157 * d_defends_ruin indicates whether this Army unit can defend a Ruin
160 * This value does not change during gameplay.
162 bool d_defends_ruins;
164 //! The awardable status of the Army prototype.
166 * Whether or not this Army prototype can be a reward for a Quest,
167 * or if Army units of this kind can accompany a new Hero when one
170 * This value does not change during gameplay.
174 //! The basename of the file containing the image for this Army proto.
176 * This value does not contain a path, and does not contain an
177 * extension (e.g. .png).
179 * There is an image filename for each player, plus the neutral player.
181 std::string d_image_name[MAX_PLAYERS + 1];
183 //! The gender of this object.
185 * Heroes have genders, and regular armies do not.
187 Hero::Gender d_gender;
190 #endif // ARMY_PROTO_H