1 /***************************************************************************
4 begin : Tue Jan 22 2002
5 copyright : (C) 2002 by Michael Andreen
7 ***************************************************************************/
9 /***************************************************************************
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. *
16 ***************************************************************************/
22 #include <ext/hash_map>
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 typedef std::map<std::string, std::vector<int> > ResourceList;
32 //! An abstraction of a fleet and the engine for the battle simulation.
33 /**This class and it's derivates is the engine for the whole battlesystem.
34 * One of the few parts that I plan make fully portable.
35 *\todo LOTS (I think ;)
36 *@author Michael Andreen
44 /**Sets the name that represents this fleet. Might be different a name
45 * like foobar or some coordinates like 1:1:1. The name doesn't have to be unique,
46 * since it's up to the rest of the program to handle that part.
49 void setName(std::string sName);
50 /**Returns the name of this fleet.
53 std::string name() const;
55 /**The race string decides what type of ships this fleet can have.
56 * The values must be feeded into this class.
57 * \param sRace This is just the name of the race. It's case-sensitive.
58 * \return If the race is available this function returns true, if not false is returned. The race is set in both cases though.
61 bool setRace(std::string sRace);
62 /**Just returns what race this fleet belongs to..
63 * \return The race, represented as a string.
66 std::string race() const;
68 std::vector<int> RacesAllowed() const;
70 /**Returns the total number of ships in this fleet
72 int numberOfShips() const;
74 /**Sets the estimated time of arrival. The time as a single integer,
75 * in relation to the current time. For example if the current time is
76 * 10, and the arrival is at 12, then the eta is 2.
79 /**Return the estimated time of arrival. It's counted from the current time (tick).
84 /**Returns the score. This value is the total resources spent on this fleet
86 * \param tick tells the function what tick you want the score from. 0 is
87 * initial score before the fleet has landed.
89 unsigned score(int tick = 0) const;
91 void setFleet(std::string unittype, int number, int tick = 0);
92 int fleet(std::string unittype, int tick = 0);
94 int freeFleet(std:: string unittype, int tick = 0);
96 static void setRaces(RaceList& races);
97 static void setUnits(UnitList& units);
99 static const RaceList& Races();
100 static const UnitList& Units();
102 void addToThis(std::vector<Fleet*> fleets, int tick = 0);
104 void distributeLossesGains(std::vector<Fleet*> fleets, int tick = 0);
106 std::vector<Fleet*> calculateSide(std::vector<Fleet*> fleets, int stays = 0, int tick = 0);
108 void takeShoot(std::string unittype, int number, std::map<std::string, int>& hitunits);
109 void takeEMP(std::string unittype, int number);
110 void killFleet(std::string unittype, int number, int tick = 0);
112 void setResource(std::string type, int number, int tick = 0);
113 int resource(std::string type, int tick = 0)const;
122 FleetList m_BlockedFleet;
123 ResourceList m_Resources;
126 static UnitList s_Units;
127 static RaceList s_Races;