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 typedef std::map<std::string, int> ArmorList;
33 //! An abstraction of a fleet and the engine for the battle simulation.
34 /**This class and it's derivates is the engine for the whole battlesystem.
35 * One of the few parts that I plan make fully portable.
36 *\todo LOTS (I think ;)
37 *@author Michael Andreen
45 /**Sets the name that represents this fleet. Might be different a name
46 * like foobar or some coordinates like 1:1:1. The name doesn't have to be unique,
47 * since it's up to the rest of the program to handle that part.
50 void setName(std::string sName);
51 /**Returns the name of this fleet.
54 std::string name() const;
56 /**The race string decides what type of ships this fleet can have.
57 * The values must be feeded into this class.
58 * \param sRace This is just the name of the race. It's case-sensitive.
59 * \return If the race is available this function returns true, if not false is returned. The race is set in both cases though.
62 bool setRace(std::string sRace);
63 /**Just returns what race this fleet belongs to..
64 * \return The race, represented as a string.
67 std::string race() const;
69 std::vector<int> RacesAllowed() const;
71 /**Returns the total number of ships in this fleet
73 int numberOfShips() const;
75 /**Sets the estimated time of arrival. The time as a single integer,
76 * in relation to the current time. For example if the current time is
77 * 10, and the arrival is at 12, then the eta is 2.
80 /**Return the estimated time of arrival. It's counted from the current time (tick).
85 /**Returns the score. This value is the total resources spent on this fleet
87 * \param tick tells the function what tick you want the score from. 0 is
88 * initial score before the fleet has landed.
90 unsigned score(int tick = 0) const;
92 void setFleet(std::string unittype, int number, int tick = 0);
93 int fleet(std::string unittype, int tick = 0);
95 int freeFleet(std:: string unittype, int tick = 0);
97 static void setRaces(RaceList& races);
98 static void setUnits(UnitList& units);
100 static const RaceList& Races();
101 static const UnitList& Units();
103 void addToThis(std::vector<Fleet*> fleets, int tick = 0);
105 void distributeLossesGains(std::vector<Fleet*> fleets, int tick = 0);
107 void distributeCappedRoids(std::vector<Fleet*> fleets, int tick = 0);
109 std::vector<Fleet*> calculateSide(std::vector<Fleet*> fleets, int stays = 0, int tick = 0);
111 void killFleet(std::string unittype, int number, int tick = 0);
113 void blockFleet(std::string unittype, int number, int tick = 0);
115 void setResource(std::string type, int number, int tick = 0);
116 void addResource(std::string type, int number, int tick = 0);
117 int resource(std::string type, int tick = 0)const;
119 void takeShoot(std::string unittype, int number, std::map<std::string, int>& hitunits);
120 void takeEMP(std::string unittype, int number);
130 FleetList m_BlockedFleet;
131 ResourceList m_Resources;
136 static UnitList s_Units;
137 static RaceList s_Races;