1 /***************************************************************************
2 planet.cpp - description
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 ***************************************************************************/
31 //////////////////////////////////////////////////////////////////////////
33 unsigned Planet::planetScore() const
38 //////////////////////////////////////////////////////////////////////////
40 void Planet::setPlanetScore(unsigned i)
45 //////////////////////////////////////////////////////////////////////////
47 int Planet::roids(std::string type, int tick = 0) const
49 // const... I would like [] as for const types: int ticks = m_Roids[type].size();
51 vector<int>const* roids = 0;
52 for (RoidList::const_iterator i = m_Roids.begin(); i != m_Roids.end(); ++i)
63 int ticks = roids->size();
68 return roids->at(ticks);
69 return roids->at(tick);
72 //////////////////////////////////////////////////////////////////////////
74 void Planet::setRoids(std::string type, int number)
76 if (m_Roids[type].size() == 0)
77 m_Roids[type].push_back(number);
78 m_Roids[type][0] = number;
81 //////////////////////////////////////////////////////////////////////////
83 void Planet::runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile)
85 for(int tick = 1; ; ++tick)
87 //See who's in the battle at the current tick
88 vector<Fleet*> friends = calculateSide(friendly, 6, tick);
89 vector<Fleet*> hostiles = calculateSide(hostile, 3, tick);
91 // No idea to calculate anything if noone is there.. ;)
92 if (hostiles.size() == 0)
96 allFriends.addToThis(friends);
99 allHostiles.addToThis(hostiles);
101 calcOneTick(&allFriends, &allHostiles);
103 allFriends.distributeLossesGains(friends, tick);
104 allHostiles.distributeLossesGains(friends, tick);
108 //////////////////////////////////////////////////////////////////////////
110 void Planet::calcOneTick(Planet* friendly, Fleet* Hostile)