]> ruin.nu Git - hbs.git/blobdiff - bs/fleet.h
solved an evil bug in Fleet::distributeLossesGains and some other stuff
[hbs.git] / bs / fleet.h
index 3bdd4ce5719042c6e7d6818d0d41ccf151d0dc21..74e4e8653404d7e6264aee6d3e646290e8be5e38 100644 (file)
 #define FLEET_H
 
 #include <map>
+#include <ext/hash_map>
 #include <string>
+#include <vector>
 
 #include "unittype.h"
-
-//!This is the engine for the whole battlesystem.
-/**This is the engine for the whole battlesystem.
+ template<typename T> class MyComp { public: bool operator()(T,T) { return false; } };
+typedef std::map<std::string, std::vector<int> > FleetList;
+typedef std::map<std::string, UnitType>        UnitList;
+typedef std::map<std::string, std::vector<int> > RaceList;
+typedef std::map<std::string, std::vector<int> > ResourceList;
+typedef std::map<std::string, int> ArmorList;
+//! An abstraction of a fleet and the engine for the battle simulation.
+/**This class and it's derivates is  the engine for the whole battlesystem.
   *    One of the few parts that I plan make fully portable.
   *\todo LOTS (I think ;)
   *@author Michael Andreen
   */
-
 class Fleet 
 {
 public: 
        Fleet();
-       ~Fleet();
+       virtual ~Fleet();
+
+       /**Sets the name that represents this fleet. Might be different a name
+        * like foobar or some coordinates like 1:1:1. The name doesn't have to be unique,
+        * since it's up to the rest of the program to handle that part.
+        * \see Name
+        */
+       void   setName(std::string sName);
+       /**Returns the name of this fleet.
+        * \see setName
+        */
+       std::string name() const;
+
+       /**The race string decides what type of ships this fleet can have.
+        * The values must be feeded into this class.
+        * \param sRace This is just the name of the race. It's case-sensitive.
+        * \return If the race is available this function returns true, if not false is returned. The race is set in both cases though.
+        * \see Race
+        */
+       bool   setRace(std::string sRace);
+       /**Just returns what race this fleet belongs to.. 
+        * \return The race, represented as a string.
+        * \see setRace
+        */
+       std::string race() const;
+
+       std::vector<int> RacesAllowed() const;
+
+       /**Returns the total number of ships in this fleet
+        */
+       int numberOfShips() const;
+
+       /**Sets the estimated time of arrival. The time as a single integer,
+        * in relation to the current time. For example if the current time is
+        * 10, and the arrival is at 12, then the eta is 2.
+        */
+       void setETA(int eta);
+       /**Return the estimated time of arrival. It's counted from the current time (tick).
+        */
+       int  ETA() const;
+
+
+       /**Returns the score. This value is the total resources spent on this fleet
+        * devided with 10.
+        * \param tick tells the function what tick you want the score from. 0 is 
+        * initial score before the fleet has landed.
+        */
+       unsigned score(int tick = 0) const;
+
+       void setFleet(std::string unittype, int number, int tick = 0);
+       int      fleet(std::string unittype, int tick = 0);
+
+       int freeFleet(std:: string unittype, int tick = 0);
+       
+       static void setRaces(RaceList& races);
+       static void setUnits(UnitList& units);
+
+       static const RaceList& Races();
+       static const UnitList& Units();
+
+       void addToThis(std::vector<Fleet*> fleets, int tick = 0);
+
+       void distributeLossesGains(std::vector<Fleet*> fleets, int tick = 0);
+
+       std::vector<Fleet*> calculateSide(std::vector<Fleet*> fleets, int stays = 0, int tick = 0);
+
+       void killFleet(std::string unittype, int number, int tick = 0);
+
+       void setResource(std::string type, int number, int tick = 0);
+       int resource(std::string type, int tick = 0)const;
+       
+       void takeShoot(std::string unittype, int number, std::map<std::string, int>& hitunits);
+       void takeEMP(std::string unittype, int number);
+
+       void printFleet();
+protected:
+
+
+       std::string     m_sName;
+       std::string     m_sRace;
+       int         m_iETA;
+       FleetList       m_Fleet;
+       FleetList       m_BlockedFleet;
+       ResourceList m_Resources;
+       ArmorList       m_Armor;
+       
 
-private:
-       std::string     m_Name;
-       std::string     m_Race;
-       std::map<std::string, std::vector<int> >        m_Fleet;
 
-       static std::map<std::string, UnitType>  m_Units;
+       static UnitList s_Units;
+       static RaceList s_Races;
 };
 
 #endif