X-Git-Url: https://ruin.nu/git/?p=hbs.git;a=blobdiff_plain;f=bs%2Fplanet.cpp;h=41d92ac51eb2ed6004bab3b01c8009a46b8fdefb;hp=4ae9c59e4d517e87b9047c7eb9b00dee837e3dad;hb=2fd4fff0f5eef1d64527b202924f16f2242691dc;hpb=e5701c8f3f1199264015c5d6e0f2a32515d5f6f8 diff --git a/bs/planet.cpp b/bs/planet.cpp index 4ae9c59..41d92ac 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -17,6 +17,7 @@ #include "planet.h" +#include using namespace std; Planet::Planet() @@ -82,7 +83,11 @@ void Planet::setRoids(std::string type, int number) // void Planet::runBattle(std::vector friendly, std::vector hostile) { - for(int tick = 1; ; ++tick) + if (hostile.size() == 0) + return; + + int skipped = 0; + for(int tick = 1; skipped < 20; ++tick) { //See who's in the battle at the current tick vector friends = calculateSide(friendly, 6, tick); @@ -90,7 +95,12 @@ void Planet::runBattle(std::vector friendly, std::vector hostile // No idea to calculate anything if noone is there.. ;) if (hostiles.size() == 0) - break; + { + skipped++; + continue; + } + else + skipped = 0; Planet allFriends; allFriends.addToThis(friends); @@ -104,7 +114,7 @@ void Planet::runBattle(std::vector friendly, std::vector hostile calcOneTick(&allFriends, &allHostiles, stealfriendly, stealhostile ); allFriends.distributeLossesGains(friends, tick); - allHostiles.distributeLossesGains(friends, tick); + allHostiles.distributeLossesGains(hostiles, tick); } } @@ -114,7 +124,7 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map unitsinit; // order units after their ininitiative for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i) - unitsinit[i->second.ETA()] = i->first; + unitsinit[i->second.initiative()] = i->first; for (map::iterator i = unitsinit.begin(); i != unitsinit.end(); ++i) { @@ -123,6 +133,8 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapsecond; + cerr << "Initiative: " << s_Units[unittype].initiative() << " with unit: " << unittype << endl; + if (s_Units[unittype].type() == "EMP") { hostiletemp->takeEMP(unittype, friendly->freeFleet(unittype, 1)); @@ -159,10 +171,10 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map