1 // Copyright (C) 2007, 2008, 2009 Ben Asselstine
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 3 of the License, or
6 // (at your option) any later version.
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.
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
18 #ifndef VECTOREDUNIT_H
19 #define VECTOREDUNIT_H
22 #include <sigc++/trackable.h>
23 #include "armyprodbase.h"
25 #include "LocationBox.h"
27 //! An Army that is being vectored to another city.
29 * When Army objects are "vectored" to another city, they disappear for two
30 * turns. While an Army is "in the air", it is represented in one of these
33 class VectoredUnit: public Ownable, public LocationBox, public sigc::trackable
36 //! The xml tag of this object in a saved-game file.
37 static std::string d_tag;
39 //! Default constructor.
41 * Make a new vectored unit.
43 * @param pos The position of the source of the vectored unit.
44 * @param dest The destination location for the unit.
45 * @param army The Army prototype that is being vectored.
46 * @param duration How many turns it takes for the armytype to
48 * @param player The player that owns the vectored Army unit.
50 VectoredUnit(Vector<int> pos, Vector<int> dest, ArmyProdBase *army,
51 int duration, Player *player);
55 * Make a new vectored unit by copying it from another one.
57 VectoredUnit(const VectoredUnit&);
59 //! Loading constructor.
61 * Make a new vectored unit by loading from an opened saved-game file.
62 * This method loads the lordsawar.vectoredunitlist.vectoredunit XML
63 * entities in the saved-game file.
65 * @param helper The opened-saved game file to load the vectored unit
68 VectoredUnit(XML_Helper* helper);
75 //! Return the position of the destination for this vectored unit.
77 * @return The position of a tile on the game map where the vectored
78 * unit will show up (eventually).
80 Vector<int>getDestination() const {return d_destination;};
82 //! Return how long it will take for the vectored unit to arrive.
84 * Returns the number of turns that it takes for this vectored unit
85 * to show up at the destination position on the game map.
87 int getDuration () const { return d_duration; };
89 //! Return a pointer to the Army prototype that is being vectored.
91 * @return A pointer to an Army in an Armyset.
93 ArmyProdBase *getArmy() const { return d_army; };
98 //! Set the position of the destination target for this vectored unit.
100 * @param dest The position of a tile on the game map to have the
101 * vectored unit show up at.
103 void setDestination(Vector<int>dest) {d_destination = dest;};
105 //! Sets how long it will take for the vectored unit to arrive.
107 * @param duration The number of turns to take before showing up at
108 * the destination posititon on the game map.
110 void setDuration(int duration) {d_duration = duration;};
112 //! Set the Army prototype that is being vectored.
113 void setArmy(ArmyProdBase *army) {d_army = army;}
116 // Methods that operate on class data but do not modify the class
118 //! Saves the vectored unit data to an opened saved-game file.
119 bool save(XML_Helper* helper) const;
121 //! Called when a vectored unit arrives at the destination.
122 Army *armyArrives() const;
125 // Methods that operate on class data and modify the class.
127 //! Process the vectored unit at the start of a new turn.
129 * @return True when this vectored unit has shown up at the destination
130 * position on the game map. Otherwise false.
138 //! The position on the game map that this vectored unit is going to.
139 Vector<int> d_destination;
141 //! A pointer to the Army prototype to vector.
142 ArmyProdBase *d_army;
144 //! The number of turns remaining until the Army shows up.
148 #endif // VECTOREDUNIT_H