]> ruin.nu Git - hbs.git/blobdiff - bs/planet.cpp
Roids/score for planets are now editable
[hbs.git] / bs / planet.cpp
index e8954e16e32700fcff56cdcd50c6c168c21bfeb0..c72fb4e61c39e5b9450cac19f3c97a82ac2b723f 100644 (file)
@@ -17,6 +17,8 @@
 
 #include "planet.h"
 
+using namespace std;
+
 Planet::Planet()
 {
        m_sRace = "Planet";
@@ -26,12 +28,54 @@ Planet::Planet()
 Planet::~Planet(){
 }
 
-unsigned Planet::score(int tick = 0)
+//////////////////////////////////////////////////////////////////////////
+//
+unsigned Planet::planetScore() const
 {
        return m_iScore;
 }
 
-void Planet::setScore(unsigned i)
+//////////////////////////////////////////////////////////////////////////
+//
+void Planet::setPlanetScore(unsigned i)
 {
        m_iScore = i;
 }
+
+//////////////////////////////////////////////////////////////////////////
+//
+int Planet::roids(std::string type, int tick = 0) const
+{
+       // const... I would like [] as for const types: int ticks = m_Roids[type].size();
+       
+       vector<int>const* roids = 0;
+       for (RoidList::const_iterator i = m_Roids.begin(); i != m_Roids.end(); ++i)
+       {
+               if (i->first == type)
+               {
+                       roids = &i->second;
+                       break;
+               }
+       }
+       if (roids == 0)
+               return 0;
+
+       int ticks = roids->size();
+
+       if( ticks == 0)
+               return 0;
+       if (ticks < tick)
+               return roids->at(ticks);
+       return roids->at(tick);
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+void Planet::setRoids(std::string type, int number)
+{
+       if (m_Roids[type].size() == 0)
+               m_Roids[type].push_back(number);
+       m_Roids[type][0] = number;
+}
+
+