X-Git-Url: https://ruin.nu/git/?p=hbs.git;a=blobdiff_plain;f=bs%2Fplanet.cpp;h=e5aba8575eaed8c659ecc58a4818ec31d2debc2c;hp=c819323d76bde827bde8414b7b8c3b620ef2355c;hb=cb2fabf93c2f6ba8b57833309038adb972f58925;hpb=e0be1e6e8f7a246acf49e1f315c8d5bc5a65bfa3 diff --git a/bs/planet.cpp b/bs/planet.cpp index c819323..e5aba85 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -154,6 +154,8 @@ void Planet::runBattle(std::vector friendly, std::vector hostile for (vector::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 @@ -237,35 +239,50 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapsecond.initiative()] = i->first; + + for (map::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 friendlyhits; + map 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 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 @@ -275,7 +292,7 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapfirst, 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"; @@ -310,6 +327,10 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map