X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bs%2Fplanet.cpp;h=9c421ccc4b9b71abe7e58af0d96e7caed2a87f28;hb=3ae63f013b2ac281d17acec43bc054a132861d35;hp=e0cf514e0c45d7b6054afbaae1c3b3ebc99342a9;hpb=236fcf8db0fa64f8acd0a1eb81aa3ce5f2bfb3e8;p=hbs.git diff --git a/bs/planet.cpp b/bs/planet.cpp index e0cf514..9c421cc 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -48,7 +48,7 @@ int Planet::roids(std::string type, int tick = 0) const { // const... I would like [] as for const types: int ticks = m_Roids[type].size(); - vectorconst* roids; + vectorconst* roids = 0; for (RoidList::const_iterator i = m_Roids.begin(); i != m_Roids.end(); ++i) { if (i->first == type) @@ -57,6 +57,8 @@ int Planet::roids(std::string type, int tick = 0) const break; } } + if (roids == 0) + return 0; int ticks = roids->size(); @@ -76,4 +78,36 @@ void Planet::setRoids(std::string type, int number) m_Roids[type][0] = number; } +////////////////////////////////////////////////////////////////////////// +// +void Planet::runBattle(std::vector friendly, std::vector hostile) +{ + for(int tick = 1; ; ++tick) + { + //See who's in the battle at the current tick + vector friends = calculateSide(friendly, 6, tick); + vector hostiles = calcualteSide(hostile, 3, tick); + + // No idea to calculate anything if noone is there.. ;) + if (hostiles.size() == 0) + break; + + Planet allFriends; + allFriends.addToThis(friends); + + Fleet allHostiles; + allHostiles.addToThis(hostiles); + + calculateOneTick(&allFriends, &allHostiles); + + allFriends.distributeLossesGains(friends, tick); + allHostile.distributeLossesGains(friends, tick); + } +} + +////////////////////////////////////////////////////////////////////////// +// +void calcOneTick(Planet* friendly, Fleet* Hostile) +{ +}