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() 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);
54 /** This function is used to get the number of roids of a specific type.
55 * \param type the for this roid (for pa: metal, crystal, eonium, uninit)
56 * \param tick what tick you want to get the number from.
57 * \returns the number of the specified type at the specified tick
59 int roids(std::string type, int tick = 0) const;
60 /** Used to set the number of roid at a specific tick
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 * \param number the number of roids you want to set.
65 void setRoids(std::string type, int number, int tick = 0);
66 /** This function is used to remove a specific number of roids without
67 * knowing how many the total is.
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 take.
72 void takeRoids(std::string type, int number, int tick = 0);
74 /** This function is used to start the batlle calculations on the current
75 * planet. It doesn't touch tick 0 on any of the fleet that fight in the
76 * battle, but all other ticks might be touched.
77 * \param friendly a vector with pointers to all friendly Fleet:s.
78 * \param hostile a vector with pointers to all hostile Fleet:s.
80 void runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile);
83 /** This function is used to start the calculations of a single tick of the
84 * battle on the current planet. It's protected because it's not really meant
85 * to be used outside runBattle(), but I might reconsider it.
86 * \param friendly a pointer to the friendly fleet.
87 * \param hostile a pointer to the hostile fleet
88 * \param stealfriendly a container used to store all the stolen units the
89 * friendly side took this tick.
90 * \param stealhostile a cointainer used to store all the stole units the
91 * hostile side took this tick.
93 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);