]> ruin.nu Git - hbs.git/blob - bs/planet.h
started to work on the battle report.. almost there =)
[hbs.git] / bs / planet.h
1 /***************************************************************************
2                           planet.h  -  description
3                              -------------------
4     begin                : Wed Apr 3 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 PLANET_H
19 #define PLANET_H
20
21 #include "fleet.h"
22
23 typedef std::map<std::string, std::vector<int> > RoidList;
24 typedef std::map<int, std::map<int, std::map<std::string, std::map<std::string, std::map<std::string, int> > > > > ReportList;
25
26 /**This class is the implementation of a planet.
27  *
28  * Yes I know.. In real life you wouldn't call a planet a fleet, but this isn't
29  * real life, it's a game engine, and in this engine a planet got all the 
30  * attributes that a fleet got + some additions, so I think the inheritance
31  * is fully legal from a OOP standpoint. If it isn't, then please correct me ;)
32  *
33  * This class is doing the actual battle simulation (since battles without 
34  * planets aren't available in this game).
35   *@author Michael Andreen
36   */
37 class Planet : public Fleet  
38 {
39 public: 
40         Planet();
41         virtual ~Planet();
42
43         /** The score for the current planet. 
44          * \returns the score as an unsigned int. 
45          * \todo add a param to specify what tick to use.
46          */
47         unsigned planetScore(int tick = 0) const;
48
49         /** Sets the score for the current fleet. 
50          * \param score this param is a unsigned int holding the score
51          * \todo add a param to specify what tick to use.
52          */
53         void setPlanetScore(unsigned score, int tick = 0);
54
55         /** Adds score to the current fleet. 
56          * \param score this param is a unsigned int holding the score
57          * \todo add a param to specify what tick to use.
58          */
59         void addPlanetScore(unsigned score, int tick = 0);
60
61         /** This function is used to get the number of roids of a specific type.
62          * \param type the for this roid (for pa: metal, crystal, eonium, uninit)
63          * \param tick what tick you want to get the number from.
64          * \returns the number of the specified type at the specified tick
65          */
66         int roids(std::string type, int tick = 0) const;
67         /**     Used to set the number of roid at a specific tick
68          * \param type the for this roid (for pa: metal, crystal, eonium, uninit)
69          * \param tick what tick you want to get the number from.
70          * \param number the number of roids you want to set.
71          */
72         void setRoids(std::string type, int number, int tick = 0);
73         /** This function is used to remove a specific number of roids without
74          * knowing how many the total is.
75          * \param type the for this roid (for pa: metal, crystal, eonium, uninit)
76          * \param tick what tick you want to get the number from.
77          * \param number the number of roids you want to take.
78          */
79         void takeRoids(std::string type, int number, int tick = 0);
80
81         /** This function is used to start the batlle calculations on the current
82          * planet. It doesn't touch tick 0 on any of the fleet that fight in the
83          * battle, but all other ticks might be touched.
84          * \param friendly a vector with pointers to all friendly Fleet:s.
85          * \param hostile a vector with pointers to all hostile Fleet:s.
86          */
87         void runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile);
88
89         void calculateScoreLoss(std::vector<Fleet*> friendly, int tick = 1);
90
91         float capping(int tick = 0);
92         void setCapping(float capping, int tick = 0);
93
94         ReportList report() const;
95
96 protected:
97         /** This function is used to start the calculations of a single tick of the
98          * battle on the current planet. It's protected because it's not really meant
99          * to be used outside runBattle(), but I might reconsider it.
100          * \param friendly a pointer to the friendly fleet. 
101          * \param hostile a pointer to the hostile fleet
102          * \param stealfriendly a container used to store all the stolen units the
103          * friendly side took this tick.
104          * \param stealhostile a cointainer used to store all the stole units the 
105          * hostile side took this tick.
106          */
107         void calcOneTick(Planet* friendly, Fleet* hostile, std::map<std::string, std::map<std::string, int> >& stealfriendly, std::map<std::string, std::map<std::string, int> >&  stealhostile, int tick = 1);
108
109         std::vector <unsigned> m_Score;
110         std::vector <float> m_Capping;
111         RoidList m_Roids;
112         ReportList m_Report;
113         
114 };
115
116 #endif