]> ruin.nu Git - hbs.git/blob - bs/planet.cpp
e0cf514e0c45d7b6054afbaae1c3b3ebc99342a9
[hbs.git] / bs / planet.cpp
1 /***************************************************************************
2                           planet.cpp  -  description
3                              -------------------
4     begin                : Wed Apr 3 2002
5     copyright            : (C) 2002 by Michael Andreen
6     email                : whale@linux.nu
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #include "planet.h"
19
20 using namespace std;
21
22 Planet::Planet()
23 {
24         m_sRace = "Planet";
25         m_iScore = 0;
26 }
27
28 Planet::~Planet(){
29 }
30
31 //////////////////////////////////////////////////////////////////////////
32 //
33 unsigned Planet::planetScore() const
34 {
35         return m_iScore;
36 }
37
38 //////////////////////////////////////////////////////////////////////////
39 //
40 void Planet::setPlanetScore(unsigned i)
41 {
42         m_iScore = i;
43 }
44
45 //////////////////////////////////////////////////////////////////////////
46 //
47 int Planet::roids(std::string type, int tick = 0) const
48 {
49         // const... I would like [] as for const types: int ticks = m_Roids[type].size();
50         
51         vector<int>const* roids;
52         for (RoidList::const_iterator i = m_Roids.begin(); i != m_Roids.end(); ++i)
53         {
54                 if (i->first == type)
55                 {
56                         roids = &i->second;
57                         break;
58                 }
59         }
60
61         int ticks = roids->size();
62
63         if( ticks == 0)
64                 return 0;
65         if (ticks < tick)
66                 return roids->at(ticks);
67         return roids->at(tick);
68 }
69
70 //////////////////////////////////////////////////////////////////////////
71 //
72 void Planet::setRoids(std::string type, int number)
73 {
74         if (m_Roids[type].size() == 0)
75                 m_Roids[type].push_back(number);
76         m_Roids[type][0] = number;
77 }
78
79