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