]> ruin.nu Git - hbs.git/blobdiff - bs/planet.cpp
last minute bug.. ;P
[hbs.git] / bs / planet.cpp
index 443b3b13695a31c2ba7d71854750acfcc2bd3241..c374a99ff9cc7f726fd18392cad21aeb0890a5b2 100644 (file)
@@ -144,6 +144,7 @@ void Planet::runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile
 
                allFriends.distributeLossesGains(friends, tick);
                allHostiles.distributeLossesGains(hostiles, tick);
+               allHostiles.distributeCappedRoids(hostiles, tick);
 
        /*      for (RoidList::iterator i = m_Roids.begin(); i != m_Roids.end(); ++i)
                        setRoids(i->first, roids(i->first, 1), tick);*/
@@ -192,38 +193,41 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map<std::string,
 
                if (s_Units[unittype].type() == "Pod")
                {
-                       if (m_iScore <= 0) break;
-                       float capping = float(m_iScore) / hostile->score() /  10;
-                       
-                       cerr << "Capping is: " << capping << endl;
-
-                       if (capping > 0.15)
-                               capping = 0.15;
-                       if (capping <= 0)
-                               break;
-
-                       for (RoidList::iterator roid = m_Roids.begin(); roid != m_Roids.end(); ++roid)
+                       if (m_iScore > 0)
                        {
-                               int caproids = capping * roids(roid->first, tick - 1);
-                               int freepods = hostiletemp->freeFleet(unittype, 1);
-
-                               cerr << "Possible to steal " << caproids << " " << roid->first << " roids\n";
-                               cerr << freepods << " free pods available\n";
-                               
-                               if (freepods <= 0)
-                                       break;
-                               if (freepods < caproids)
-                                       caproids = freepods;
-
-                               cerr << caproids << " roids stolen\n";
-                                       
-                               takeRoids(roid->first, caproids, tick);
-
-                               hostiletemp->killFleet(unittype, caproids, 1);
-                               int totroids = caproids + hostiletemp->resource(roid->first, 0);
-                               hostiletemp->setResource(roid->first, totroids, 1);
-                               
-                               cerr << totroids << " stolen " << roid->first << " roids\n";
+                               float capping = float(m_iScore) / hostile->score() /  10;
+                       
+                               cerr << "Capping is: " << capping << endl;
+       
+                               if (capping > 0.15)
+                                       capping = 0.15;
+                               if (capping > 0)
+                               {
+                                       for (RoidList::iterator roid = m_Roids.begin(); roid != m_Roids.end(); ++roid)
+                                       {
+                                               int caproids = capping * roids(roid->first, tick - 1);
+                                               int freepods = hostiletemp->freeFleet(unittype, 1);
+               
+                                               cerr << "Possible to steal " << caproids << " " << roid->first << " roids\n";
+                                               cerr << freepods << " free pods available\n";
+                                               
+                                               if (freepods <= 0)
+                                                       break;
+                                               if (freepods < caproids)
+                                                       caproids = freepods;
+               
+                                               cerr << caproids << " roids stolen\n";
+                                                       
+                                               takeRoids(roid->first, caproids, tick);
+               
+                                               //FIXME: Going to move this to the distribute roids section instead..
+                                               hostiletemp->killFleet(unittype, caproids, 1);
+                                               //int totroids = caproids + hostiletemp->resource(roid->first, 0);
+                                               hostiletemp->addResource(roid->first, caproids, 1);
+                                               
+                                               cerr << caproids << " stolen " << roid->first << " roids\n";
+                                       }
+                               }
                        }
                }