]> ruin.nu Git - hbs.git/blob - bs/fleet.h
ca2fddfdc616dde9be124c5932b1c6e77c559df2
[hbs.git] / bs / fleet.h
1 /***************************************************************************
2                           fleet.h  -  description
3                              -------------------
4     begin                : Tue Jan 22 2002
5     copyright            : (C) 2002 by Michael Andreen
6     email                : whale@linux.nu
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #ifndef FLEET_H
19 #define FLEET_H
20
21 #include <map>
22 #include <ext/hash_map>
23 #include <string>
24 #include <vector>
25
26 #include "unittype.h"
27  template<typename T> class MyComp { public: bool operator()(T,T) { return false; } };
28
29 typedef std::map<std::string, UnitType> UnitList;
30 //!This is the engine for the whole battlesystem.
31 /**This is the engine for the whole battlesystem.
32   *     One of the few parts that I plan make fully portable.
33   *\todo LOTS (I think ;)
34   *@author Michael Andreen
35   */
36 class Fleet 
37 {
38 public: 
39         Fleet();
40         ~Fleet();
41
42         /**Sets the name that represents this fleet. Might be different a name
43          * like foobar or some coordinates like 1:1:1. The name doesn't have to be unique,
44          * since it's up to the rest of the program to handle that part.
45          * \see Name
46          */
47         void   setName(std::string sName);
48         /**Returns the name of this fleet.
49          * \see setName
50          */
51         std::string Name() const;
52
53         /**The race string decides what type of ships this fleet can have.
54          * The values must be feeded into this class.
55          * \param sRace This is just the name of the race. It's case-sensitive.
56          * \return If the race is available this function returns true, if not false is returned. The race is set in both cases though.
57          * \see Race
58          */
59         bool   setRace(std::string sRace);
60         /**Just returns what race this fleet belongs to.. 
61          * \return The race, represented as a string.
62          * \see setRace
63          */
64         std::string Race() const;
65
66         std::vector<int> RacesAllowed() const;
67
68         /**Returns the total number of ships in this fleet
69          */
70         int NumberOfShips() const;
71
72         /**Sets the estimated time of arrival. The time as a single integer,
73          * in relation to the current time. For example if the current time is
74          * 10, and the arrival is at 12, then the eta is 2.
75          */
76         void setETA(int eta);
77         /**Return the estimated time of arrival. It's counted from the current time (tick).
78          */
79         int  ETA() const;
80
81         static void setRaces(std::map<std::string, std::vector<int> >& races);
82         static void setUnits(UnitList& units);
83
84         static const std::map<std::string, std::vector<int> >& Races();
85         static const UnitList& Units();
86
87 protected:
88         std::string     m_sName;
89         std::string     m_sRace;
90         int         m_iETA;
91         std::map<std::string, std::vector<int> >        m_Fleet;
92
93         static UnitList s_Units;
94         static std::map<std::string, std::vector<int> > s_Races;
95 };
96
97 #endif