for (vector<Fleet*>::iterator i = hostile.begin(); i != hostile.end(); ++i)
(*i)->resetTicks();
+ m_Report.clear();
+
for(int tick = 1; skipped < 20; ++tick)
{
//See who's in the battle at the current tick
- vector<Fleet*> friends = calculateSide(friendly, 6, tick);
- vector<Fleet*> hostiles = calculateSide(hostile, 3, tick);
+ vector<Fleet*> friends = calculateSide(friendly, tick);
+ vector<Fleet*> hostiles = calculateSide(hostile, tick);
// No idea to calculate anything if noone is there.. ;)
if (hostiles.size() == 0)
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;
+ int init = i->first;
+
+ int freefriendly = friendly->freeFleet(unittype, 1);
+ int freehostile = hostile->freeFleet(unittype, 1);
+
+ if ( freefriendly <= 0 && freehostile <= 0)
+ continue;
//cerr << "Initiative: " << s_Units[unittype].initiative() << " with unit: " << unittype << endl;
+
+ map<string, int> friendlyhits;
+ map<string, int> hostilehits;
if (s_Units[unittype].type() == "EMP")
{
- hostiletemp->takeEMP(unittype, friendly->freeFleet(unittype, 1));
- friendlytemp->takeEMP(unittype, hostile->freeFleet(unittype, 1));
+ hostiletemp->takeEMP(unittype, freefriendly, friendlyhits);
+ friendlytemp->takeEMP(unittype, freehostile, hostilehits);
}
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]);
+ hostiletemp->takeShoot(unittype, freefriendly, stealfriendly[unittype]);
+ friendlytemp->takeShoot(unittype, freehostile, stealhostile[unittype]);
+
+ friendlyhits = stealfriendly[unittype];
+ hostilehits = stealhostile[unittype];
friendlytemp->calculateLostStealships(unittype, stealfriendly[unittype], 1);
hostiletemp->calculateLostStealships(unittype, stealhostile[unittype], 1);
}
else
{
- map<string, int> temp;
- hostiletemp->takeShoot(unittype, friendly->freeFleet(unittype, 1), temp);
- friendlytemp->takeShoot(unittype, hostile->freeFleet(unittype, 1), temp);
+ hostiletemp->takeShoot(unittype, freefriendly, friendlyhits);
+ friendlytemp->takeShoot(unittype, freehostile, hostilehits);
}
+
if (s_Units[unittype].type() == "Pod")
{
//FIXME: Prolly need to recode the whole capping section for r7, due to multiple pods thingy
{
for (RoidList::iterator roid = m_Roids.begin(); roid != m_Roids.end(); ++roid)
{
- int caproids = capping(tick) * roids(roid->first, tick - 1);
+ int caproids = int(capping(tick) * roids(roid->first, tick - 1));
//int freepods = hostiletemp->freeFleet(unittype, 1);
cerr << "Possible to steal " << caproids << " " << roid->first << " roids\n";
return;
}
+ if (freefriendly > 0)
+ {
+ m_Report[tick][init]["Friendly"][unittype] = friendlyhits;
+ m_Report[tick][init]["Friendly"][unittype]["000"] = freefriendly;
+ }
+ if (freehostile > 0)
+ {
+ m_Report[tick][init]["Hostile"][unittype] = hostilehits;
+ m_Report[tick][init]["Hostile"][unittype]["000"] = freehostile;
+ }
//set the the objects so they point at the modified objects
*friendly = *friendlytemp;
else
m_Capping[tick] = 0;
}
+
+//////////////////////////////////////////////////////////////////////////
+//
+ReportList Planet::report() const
+{
+ return m_Report;
+}