map<string, map<string, int> > stealfriendly;
map<string, map<string, int> > stealhostile;
+
+ //Reset roids
+ for (RoidList::iterator roid = m_Roids.begin(); roid != m_Roids.end(); ++roid)
+ setRoids(roid->first, roids(roid->first, tick-1), tick);
+
calcOneTick(&allFriends, &allHostiles, stealfriendly, stealhostile, tick );
{
if (planetScore(tick - 1) > 0)
{
- float capping = float(planetScore(tick - 1)) / hostile->score() / 10;
+ setCapping(float(planetScore(tick - 1)) / hostile->score() / 10, tick);
- cerr << "Capping is: " << capping << endl;
+ cerr << "Capping is: " << capping(tick) << endl;
- if (capping > 0.15)
- capping = 0.15;
- if (capping > 0)
+ if (capping(tick) > 0)
{
for (RoidList::iterator roid = m_Roids.begin(); roid != m_Roids.end(); ++roid)
{
- int caproids = capping * roids(roid->first, tick - 1);
+ int caproids = capping(tick) * roids(roid->first, tick - 1);
int freepods = hostiletemp->freeFleet(unittype, 1);
cerr << "Possible to steal " << caproids << " " << roid->first << " roids\n";
caproids = freepods;
cerr << caproids << " roids stolen\n";
-
+
takeRoids(roid->first, caproids, tick);
//FIXME: Going to move this to the distribute roids section instead.. Not really move, I'll keep this, but "regenerate" the pods in the distribute ships function.
}
}
+//////////////////////////////////////////////////////////////////////////
+//
+float Planet::capping(int tick = 0)
+{
+ int ticks = m_Capping.size();
+
+ --ticks;
+
+ if (ticks < tick)
+ return 0;
+
+ return m_Capping[tick];
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+void Planet::setCapping(float capping, int tick = 0)
+{
+ int ticks = m_Capping.size();
+
+ for (int i = ticks; i <= tick; ++i)
+ {
+ m_Capping.push_back(0);
+ }
+
+ if (capping <= 0.15 && capping >= 0)
+ m_Capping[tick] = capping;
+ else
+ m_Capping[tick] = 0.15;
+}