]> ruin.nu Git - hbs.git/blobdiff - bs/planet.cpp
The work on the combat algorithm is going forward, nothing worth compiling yet though.
[hbs.git] / bs / planet.cpp
index 69cfd7a432c2aee7edeb72f0d545126b6560b26c..9c421ccc4b9b71abe7e58af0d96e7caed2a87f28 100644 (file)
@@ -81,6 +81,33 @@ void Planet::setRoids(std::string type, int number)
 //////////////////////////////////////////////////////////////////////////
 //
 void Planet::runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile)
+{
+       for(int tick = 1; ; ++tick)
+       {
+               //See who's in the battle at the current tick
+               vector<Fleet*> friends = calculateSide(friendly, 6, tick);
+               vector<Fleet*> 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)
 {
 }