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;
24 typedef std::map<int, std::map<int, std::map<std::string, std::map<std::string, std::map<std::string, int> > > > > ReportList;
26 /**This class is the implementation of a planet.
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 ;)
33 * This class is doing the actual battle simulation (since battles without
34 * planets aren't available in this game).
35 *@author Michael Andreen
37 class Planet : public Fleet
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.
47 unsigned planetScore(int tick = 0) const;
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.
53 void setPlanetScore(unsigned score, int tick = 0);
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.
59 void addPlanetScore(unsigned score, int tick = 0);
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
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.
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.
79 void takeRoids(std::string type, int number, int tick = 0);
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.
87 void runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile);
89 void calculateScoreLoss(std::vector<Fleet*> friendly, int tick = 1);
91 float capping(int tick = 0);
92 void setCapping(float capping, int tick = 0);
94 ReportList report() const;
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.
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);
109 std::vector <unsigned> m_Score;
110 std::vector <float> m_Capping;