]> ruin.nu Git - hbs.git/blob - bs/fleet.h
f1d96affc4fb1264464f704c55db3262eb5b4646
[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 typedef std::map<std::string, std::vector<int> > FleetList;
29 typedef std::map<std::string, UnitType> UnitList;
30 typedef std::map<std::string, std::vector<int> > RaceList;
31 //! An abstraction of a fleet and the engine for the battle simulation.
32 /**This class and it's derivates is  the engine for the whole battlesystem.
33   *     One of the few parts that I plan make fully portable.
34   *\todo LOTS (I think ;)
35   *@author Michael Andreen
36   */
37 class Fleet 
38 {
39 public: 
40         Fleet();
41         virtual ~Fleet();
42
43         /**Sets the name that represents this fleet. Might be different a name
44          * like foobar or some coordinates like 1:1:1. The name doesn't have to be unique,
45          * since it's up to the rest of the program to handle that part.
46          * \see Name
47          */
48         void   setName(std::string sName);
49         /**Returns the name of this fleet.
50          * \see setName
51          */
52         std::string name() const;
53
54         /**The race string decides what type of ships this fleet can have.
55          * The values must be feeded into this class.
56          * \param sRace This is just the name of the race. It's case-sensitive.
57          * \return If the race is available this function returns true, if not false is returned. The race is set in both cases though.
58          * \see Race
59          */
60         bool   setRace(std::string sRace);
61         /**Just returns what race this fleet belongs to.. 
62          * \return The race, represented as a string.
63          * \see setRace
64          */
65         std::string race() const;
66
67         std::vector<int> RacesAllowed() const;
68
69         /**Returns the total number of ships in this fleet
70          */
71         int numberOfShips() const;
72
73         /**Sets the estimated time of arrival. The time as a single integer,
74          * in relation to the current time. For example if the current time is
75          * 10, and the arrival is at 12, then the eta is 2.
76          */
77         void setETA(int eta);
78         /**Return the estimated time of arrival. It's counted from the current time (tick).
79          */
80         int  ETA() const;
81
82
83         /**Returns the score. This value is the total resources spent on this fleet
84          * devided with 10.
85          * \param tick tells the function what tick you want the score from. 0 is 
86          * initial score before the fleet has landed.
87          */
88         unsigned score(int tick = 0) const;
89
90         void setFleet(std::string unittype, int number);
91         int      fleet(std::string unittype, int tick = 0);
92         
93         static void setRaces(RaceList& races);
94         static void setUnits(UnitList& units);
95
96         static const RaceList& Races();
97         static const UnitList& Units();
98
99         void addToThis(std::vector<Fleet*> fleets, int tick = 0);
100
101         void distributeLossesGains(std::vector<Fleet*> fleets, int tick = 0);
102
103         std::vector<Fleet*> calculateSide(std::vector<Fleet*> fleets, int stays = 0, int tick = 0);
104
105
106 protected:
107
108
109         std::string     m_sName;
110         std::string     m_sRace;
111         int         m_iETA;
112         FleetList       m_Fleet;
113
114         static UnitList s_Units;
115         static RaceList s_Races;
116 };
117
118 #endif