]> ruin.nu Git - hbs.git/blob - bs/fleet.cpp
4989573d87f069b3e3bd6e27c4b009e9a0e7268c
[hbs.git] / bs / fleet.cpp
1 /***************************************************************************
2                           fleet.cpp  -  description
3                              -------------------
4     begin                : Tue Jan 22 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 "fleet.h"
19
20 using namespace std;
21
22 //Static variables
23 map<string, vector<int> > Fleet::s_Races;
24 map<string, UnitType > Fleet::s_Units;
25
26 Fleet::Fleet()
27 {
28 }
29 Fleet::~Fleet(){
30 }
31
32 //////////////////////////////////////////////////////////////////////////
33 //
34 void Fleet::setName(string sName)
35 {
36         m_sName = sName;
37 }
38
39 //////////////////////////////////////////////////////////////////////////
40 //
41 string Fleet::Name()
42 {
43         return m_sName;
44 }
45
46 //////////////////////////////////////////////////////////////////////////
47 //
48 /** This function first sets the race, then it iterates through the the 
49  * s_Races and checks if it finds the race it returns true, if it reaches
50  * the end without finding it it returns false.
51  */
52 bool Fleet::setRace(std::string sRace)
53 {
54         m_sRace = sRace;
55         for (map<string, vector<int> >::iterator i = s_Races.begin(); i != s_Races.end(); i++)
56         {
57                 if (m_sRace == (*i).first)
58                         return true;
59         }
60         return false;
61 }
62
63 //////////////////////////////////////////////////////////////////////////
64 //
65 string Fleet::Race()
66 {
67         return m_sRace;
68 }
69
70 //////////////////////////////////////////////////////////////////////////
71 //
72 /** This function iterates through m_Fleet and adds all numbers together to
73  * produce a total.
74  */
75 int Fleet::NumberOfShips()
76 {
77         int total = 0;
78
79         for (map<string, vector<int> >::iterator i = m_Fleet.begin(); i != m_Fleet.end(); i++)
80         {
81                 total += m_Fleet[(*i).first][0];
82         }
83
84         return total;
85 }
86