1 // Copyright (C) 2007, 2008 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
23 //! A bridge on the game map.
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.
30 class Bridge: public Location
33 //! The xml tag of this object in a saved-game file.
34 static std::string d_tag;
39 CONNECTS_TO_NORTH = 1,
41 CONNECTS_TO_SOUTH = 3,
43 static std::string bridgeTypeToString(const Bridge::Type type);
44 static Bridge::Type bridgeTypeFromString(const std::string str);
46 //! Default constructor.
48 * @param pos The location of the bridge.
49 * @param type The type of bridge. 0=e,1=n, 2=w, 3=s.
51 Bridge(Vector<int> pos, int type = 0);
54 Bridge(const Bridge&);
56 Bridge(const Bridge&, Vector<int> pos);
58 //! Loading constructor.
60 * Load the bridge from the opened saved-game file.
61 * @param helper The opened saved-game file to load the bridge from.
63 Bridge(XML_Helper* helper);
67 //! Returns the type of the bridge.
68 int getType() {return d_type;};
70 //! Sets the type of the bridge.
71 void setType(int type) {d_type = type;};
73 //! Save the bridge data to the opened saved-game file.
74 bool save(XML_Helper* helper) const;
77 //! The type of the bridge.
79 * The type of the bridge refers to it's look on the map. It can be
80 * one of the following values:
82 * 0 = The bridge connects to a road to the west, and another bridge
84 * 1 = The bridge connects to a road to the south, and another bridge
86 * 2 = The bridge connects to a road to the east, and another bridge
88 * 3 = The bridge connects to a road to the north, and another bridge