1 /***************************************************************************
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 ***************************************************************************/
23 typedef std::map<std::string, std::vector<int> > RoidList;
25 /**This class is the implementation of a planet.
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 ;)
32 * This class is doing the actual battle simulation (since battles without
33 * planets aren't available in this game).
34 *@author Michael Andreen
36 class Planet : public Fleet
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.
46 unsigned planetScore(int tick = 0) const;
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.
52 void setPlanetScore(unsigned score, int tick = 0);
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.
58 void addPlanetScore(unsigned score, int tick = 0);
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
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.
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.
78 void takeRoids(std::string type, int number, int tick = 0);
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.
86 void runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile);
88 void calculateScoreLoss(std::vector<Fleet*> friendly, int tick = 1);
90 float capping(int tick = 0);
91 void setCapping(float capping, int tick = 0);
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.
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 = 1);
106 std::vector <unsigned> m_Score;
107 std::vector <float> m_Capping;