+void Planet::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)
+{
+ map<int, string> unitsinit; // order units after their ininitiative
+ for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i)
+ unitsinit[i->second.initiative()] = i->first;
+
+ for (map<int, string>::iterator i = unitsinit.begin(); i != unitsinit.end(); ++i)
+ {
+ Fleet* hostiletemp = new Fleet(*hostile);
+ Planet* friendlytemp = new Planet(*friendly);
+
+ string unittype = i->second;
+
+ //cerr << "Initiative: " << s_Units[unittype].initiative() << " with unit: " << unittype << endl;
+
+ if (s_Units[unittype].type() == "EMP")
+ {
+ hostiletemp->takeEMP(unittype, friendly->freeFleet(unittype, 1));
+ friendlytemp->takeEMP(unittype, hostile->freeFleet(unittype, 1));
+ }
+ else if (s_Units[unittype].type() == "Steal")
+ {
+ hostiletemp->takeShoot(unittype, friendly->freeFleet(unittype, 1), stealfriendly[unittype]);
+ friendlytemp->takeShoot(unittype, hostile->freeFleet(unittype, 1), stealhostile[unittype]);
+ }
+ else
+ {
+ map<string, int> temp;
+ hostiletemp->takeShoot(unittype, friendly->freeFleet(unittype, 1), temp);
+ friendlytemp->takeShoot(unittype, hostile->freeFleet(unittype, 1), temp);
+ }
+
+ if (s_Units[unittype].type() == "Pod")
+ {
+ if (planetScore(tick - 1) > 0)
+ {
+ float capping = float(planetScore(tick - 1)) / hostile->score() / 10;
+
+ cerr << "Capping is: " << capping << endl;
+
+ if (capping > 0.15)
+ capping = 0.15;
+ if (capping > 0)
+ {
+ for (RoidList::iterator roid = m_Roids.begin(); roid != m_Roids.end(); ++roid)
+ {
+ int caproids = capping * roids(roid->first, tick - 1);
+ int freepods = hostiletemp->freeFleet(unittype, 1);
+
+ cerr << "Possible to steal " << caproids << " " << roid->first << " roids\n";
+ cerr << freepods << " free pods available\n";
+
+ if (freepods <= 0)
+ break;
+ if (freepods < caproids)
+ 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.
+ hostiletemp->killFleet(unittype, caproids, 1);
+ //int totroids = caproids + hostiletemp->resource(roid->first, 0);
+ hostiletemp->addResource(roid->first, caproids, 1);
+
+ cerr << caproids << " stolen " << roid->first << " roids\n";
+ }
+ }
+ }
+ }
+
+ //set the the objects so they point at the modified objects
+ *friendly = *friendlytemp;
+ delete friendlytemp;
+ *hostile = *hostiletemp;
+ delete hostiletemp;
+ }
+}
+
+void Planet::calculateScoreLoss(std::vector<Fleet*> friendly, int tick = 1)