initial commit, lordsawar source, slightly modified
[lordsawar] / src / bridge.h
1 //  Copyright (C) 2007, 2008 Ben Asselstine
2 //
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.
7 //
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.
12 //
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 
16 //  02110-1301, USA.
17
18 #ifndef BRIDGE_H
19 #define BRIDGE_H
20
21 #include "Location.h"
22
23 //! A bridge on the game map.
24 /** 
25  * A bridge is a place on the map that simultaneously acts like a Road object
26  * and a Port object.  Stack objects can move more efficiently on a bridge
27  * tile, and the Stack can also use it as a jumping off point into the water.
28  * A bridge object is built on a Tile with a terrain kind of Tile::WATER.
29  */
30 class Bridge: public Location
31 {
32     public:
33         //! The xml tag of this object in a saved-game file.
34         static std::string d_tag; 
35
36         enum Type 
37           {
38             CONNECTS_TO_EAST = 0,
39             CONNECTS_TO_NORTH = 1,
40             CONNECTS_TO_WEST = 2,
41             CONNECTS_TO_SOUTH = 3,
42           };
43         static std::string bridgeTypeToString(const Bridge::Type type);
44         static Bridge::Type bridgeTypeFromString(const std::string str);
45
46         //! Default constructor.
47         /**
48          * @param pos          The location of the bridge.
49          * @param type         The type of bridge.  0=e,1=n, 2=w, 3=s.
50          */
51         Bridge(Vector<int> pos, int type = 0);
52
53         //! Copy constructor.
54         Bridge(const Bridge&);
55
56         Bridge(const Bridge&, Vector<int> pos);
57
58         //! Loading constructor.
59         /**
60          * Load the bridge from the opened saved-game file.
61          * @param helper  The opened saved-game file to load the bridge from.
62          */
63         Bridge(XML_Helper* helper);
64         //! Destructor.
65         ~Bridge();
66
67         //! Returns the type of the bridge.
68         int getType() {return d_type;};
69
70         //! Sets the type of the bridge.
71         void setType(int type) {d_type = type;};
72
73         //! Save the bridge data to the opened saved-game file.
74         bool save(XML_Helper* helper) const;
75
76     protected:
77         //! The type of the bridge.
78         /**
79          * The type of the bridge refers to it's look on the map.  It can be
80          * one of the following values:
81          *
82          * 0 = The bridge connects to a road to the west, and another bridge
83          *     to the east.
84          * 1 = The bridge connects to a road to the south, and another bridge
85          *     to the north.
86          * 2 = The bridge connects to a road to the east, and another bridge
87          *     to the west.
88          * 3 = The bridge connects to a road to the north, and another bridge
89          *     to the south.
90          */
91         int d_type;
92
93 };
94
95 #endif // BRIDGE_H