]> ruin.nu Git - hbs.git/commitdiff
BSDoc should now create a friendly and a hostile vector for the battle simulation...
authorMichael Andreen <harv@ruin.nu>
Sun, 7 Apr 2002 23:23:15 +0000 (23:23 +0000)
committerMichael Andreen <harv@ruin.nu>
Sun, 7 Apr 2002 23:23:15 +0000 (23:23 +0000)
bs/bsdoc.cpp
bs/fleet.h
bs/planet.cpp
bs/planet.h

index d7e04ce336f0e3253c04af305ae94952b0942d1b..9d3c21ba8c10323052bdd8a28be1282dadbbc8ea 100644 (file)
@@ -146,6 +146,22 @@ void BSDoc::removeFleet(QString battle, QString group, QString fleet)
 //
 void BSDoc::runBattleSimulation()
 {
+       for(BattleList::iterator i = m_Battles.begin(); i != m_Battles.end(); ++i)
+       {
+               map<QString, vector<Fleet*> > battle;
+               for (map<QString, map<QString, Fleet*> >::iterator j = i->second.begin(); j != i->second.end(); ++j)
+               {
+                       for (map<QString, Fleet*>::iterator k = j->second.begin(); k != j->second.end(); ++k)
+                               battle[j->first].push_back(k->second);
+               }
+
+               Planet* pl = dynamic_cast<Planet*>(i->second["Friendly"]["Home Planet"]);
+
+               if (pl)
+               {
+                       pl->runBattle(battle["Friendly"], battle["Hostile"]);
+               }
+       }
 
        emit documentChanged();
 }
index 9a0995a23127e7d2f359580309f1c791245285f7..e27c1bf834b88a1c351694f70401aa76be633439 100644 (file)
@@ -28,8 +28,8 @@
 typedef std::map<std::string, std::vector<int> > FleetList;
 typedef std::map<std::string, UnitType>        UnitList;
 typedef std::map<std::string, std::vector<int> > RaceList;
-//!This is the engine for the whole battlesystem.
-/**This is the engine for the whole battlesystem.
+//! An abstraction of a fleet and the engine for the battle simulation.
+/**This class and it's derivates is  the engine for the whole battlesystem.
   *    One of the few parts that I plan make fully portable.
   *\todo LOTS (I think ;)
   *@author Michael Andreen
index 81d7daa4f09e66438844be23bc52d6b3f5e65200..69cfd7a432c2aee7edeb72f0d545126b6560b26c 100644 (file)
@@ -80,7 +80,7 @@ void Planet::setRoids(std::string type, int number)
 
 //////////////////////////////////////////////////////////////////////////
 //
-void runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile)
+void Planet::runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile)
 {
 }
 
index e59007ceebbc46c307d78cc84d96122deb092203..a836577157beb625a5401474e149829331ef9351 100644 (file)
@@ -28,6 +28,9 @@ typedef std::map<std::string, std::vector<int> > RoidList;
  * real life, it's a game engine, and in this engine a planet got all the 
  * attributes that a fleet got + some additions, so I think the inheritance
  * is fully legal from a OOP standpoint. If it isn't, then please correct me ;)
+ *
+ * This class is doing the actual battle simulation (since battles without 
+ * planets aren't available in this game).
   *@author Michael Andreen
   */