]> ruin.nu Git - hbs.git/blobdiff - bs/bsdoc.cpp
changed my internal structure from Fleet to Fleet*
[hbs.git] / bs / bsdoc.cpp
index 57811c70417188fd0d0914b170d815546fd7c429..5bf5f46863c6c28ec325cabca60f5b99703449e5 100644 (file)
  *                                                                         *
  ***************************************************************************/
 
-#include "bcdoc.h"
+#include "bsdoc.h"
 
-BcDoc::BcDoc()
+#include "planet.h"
+
+using namespace std;
+
+BSDoc::BSDoc()
 {
   modified = false;
 }
 
-BcDoc::~BcDoc()
+BSDoc::~BSDoc()
 {
 }
 
-void BcDoc::newDoc()
+void BSDoc::newDoc()
 {
 }
 
-bool BcDoc::save()
+bool BSDoc::save()
 {
   return true;
 }
 
-bool BcDoc::saveAs(const QString &filename)
+bool BSDoc::saveAs(const QString &filename)
 {
+       QString test = filename;
   return true;
 }
 
-bool BcDoc::load(const QString &filename)
+bool BSDoc::load(const QString &filename)
 {
-  emit documentChanged();
+  QString test = filename;
+       emit documentChanged();
   return true;
 }
 
-bool BcDoc::isModified() const
+bool BSDoc::isModified() const
 {
   return modified;
 }
+
+///////////////////////////////////////////////////////////////////////////
+//
+
+int BSDoc::newBattle(QString name)
+{
+       m_Battles[name]["Friendly"]["Home Planet"] = new Planet();;
+       m_Battles[name]["Friendly"]["Home Fleet"] = new Fleet();
+       m_Battles[name]["Hostile"];
+
+       //Planet* pl = dynamic_cast<Planet*>(m_Battles[name]["Friendly"]["Home Planet"]);
+       modified = true;
+       emit documentChanged();
+       return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////
+//
+
+const BattleList& BSDoc::battles() const
+{
+       return m_Battles;
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+const Fleet* BSDoc::specificFleet(QString battle, QString group, QString fleet) const
+{
+       for (BattleList::const_iterator i = m_Battles.begin(); i != m_Battles.end(); ++i)
+       {
+               if (i->first == battle)
+               {
+                       for (map<QString, map<QString, Fleet*> >::const_iterator j = i->second.begin(); j != i->second.end(); j++)
+                       {
+                               if (j->first == group)
+                               {
+                                       for (map<QString, Fleet*>::const_iterator k = j->second.begin(); k != j->second.end(); ++k)
+                                       {
+                                               if (k->first == fleet)
+                                               {
+                                                       return k->second;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       return '\0';
+}
+
+