]> ruin.nu Git - hbs.git/blob - bs/fleet.cpp
initial commit of the BSConf class.
[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         m_iETA = 0;
29 }
30 Fleet::~Fleet(){
31 }
32
33 //////////////////////////////////////////////////////////////////////////
34 //
35 void Fleet::setName(string sName)
36 {
37         m_sName = sName;
38 }
39
40 //////////////////////////////////////////////////////////////////////////
41 //
42 string Fleet::Name()
43 {
44         return m_sName;
45 }
46
47 //////////////////////////////////////////////////////////////////////////
48 //
49 /** This function first sets the race, then it iterates through the the 
50  * s_Races and checks if it finds the race it returns true, if it reaches
51  * the end without finding it it returns false.
52  */
53 bool Fleet::setRace(std::string sRace)
54 {
55         m_sRace = sRace;
56         for (map<string, vector<int> >::iterator i = s_Races.begin(); i != s_Races.end(); i++)
57         {
58                 if (m_sRace == (*i).first)
59                         return true;
60         }
61         return false;
62 }
63
64 //////////////////////////////////////////////////////////////////////////
65 //
66 string Fleet::Race()
67 {
68         return m_sRace;
69 }
70
71 //////////////////////////////////////////////////////////////////////////
72 //
73 /** This function iterates through m_Fleet and adds all numbers together to
74  * produce a total.
75  */
76 int Fleet::NumberOfShips()
77 {
78         int total = 0;
79
80         for (map<string, vector<int> >::iterator i = m_Fleet.begin(); i != m_Fleet.end(); i++)
81         {
82                 total += m_Fleet[(*i).first][0];
83         }
84
85         return total;
86 }
87
88 //////////////////////////////////////////////////////////////////////////
89 //
90 void Fleet::setETA(int eta)
91 {
92         m_iETA = eta;
93 }
94
95 //////////////////////////////////////////////////////////////////////////
96 //
97 int  Fleet::ETA()
98 {
99         return m_iETA;
100 }
101
102