]> ruin.nu Git - hbs.git/blob - bs/unittype.cpp
Can now load the stats and race configurations..
[hbs.git] / bs / unittype.cpp
1 /***************************************************************************
2                           unittype.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 "unittype.h"
19 #include <iostream>
20 using namespace std;
21
22 //////////////////////////////////////////////////////////////////////////
23 //
24
25 UnitType::UnitType()
26 {
27 }
28 //////////////////////////////////////////////////////////////////////////
29 //
30 UnitType::~UnitType(){
31 }
32
33
34 //////////////////////////////////////////////////////////////////////////
35 //
36 void UnitType::setName(string sName)
37 {
38         m_sName = sName;
39 }
40
41 //////////////////////////////////////////////////////////////////////////
42 //
43 string UnitType::Name()
44 {
45         return m_sName;
46 }
47
48 //////////////////////////////////////////////////////////////////////////
49 //
50 void UnitType::setRace(int iRace)
51 {
52         m_iRace = iRace;
53 }
54
55 //////////////////////////////////////////////////////////////////////////
56 //
57 int UnitType::Race()
58 {
59         return m_iRace;
60 }
61
62 //////////////////////////////////////////////////////////////////////////
63 //
64 void UnitType::setClass(string sClass)
65 {
66         m_sClass = sClass;
67 }
68
69 //////////////////////////////////////////////////////////////////////////
70 //
71 string UnitType::Class()
72 {
73         return m_sClass;
74 }
75
76 //////////////////////////////////////////////////////////////////////////
77 //
78 void UnitType::setTarget(vector<string> Target)
79 {
80         m_vTarget = Target;
81 }
82
83 //////////////////////////////////////////////////////////////////////////
84 //
85 void UnitType::addTarget(string target)
86 {
87         m_vTarget.push_back(target);
88 }
89
90 //////////////////////////////////////////////////////////////////////////
91 //
92 /** This function iterates through the list until it finds the right positition.
93  * If it finds the position it inserts the target there, if it reaches the end 
94  * before it finds the correct possition it adds the target to the end. 
95  */
96 void UnitType::insTarget(string target, int index = 0)
97 {
98
99         vector<string>::iterator i = m_vTarget.begin(); 
100
101         for (int j = 0; j < index; j++, i++)
102         {
103                 if (i == m_vTarget.end())
104                 {
105                         m_vTarget.push_back(target);
106                         return;
107                 }
108         }
109
110         m_vTarget.insert(i, target);
111 }
112
113 //////////////////////////////////////////////////////////////////////////
114 //
115 vector<string> UnitType::Target()
116 {
117         return m_vTarget;
118 }
119
120 //////////////////////////////////////////////////////////////////////////
121 //
122 string UnitType::Target(int index)
123 {
124         return m_vTarget[index];
125 }
126
127 //////////////////////////////////////////////////////////////////////////
128 //
129 void UnitType::setInitiative(int iInit)
130 {
131         m_iInitiative = iInit;
132 }
133
134 //////////////////////////////////////////////////////////////////////////
135 //
136 int      UnitType::Initiative()
137 {
138         return m_iInitiative;
139 }
140
141 //////////////////////////////////////////////////////////////////////////
142 //
143 void UnitType::setAgility (int iAgil)
144 {
145         m_iAgility = iAgil;
146 }
147
148 //////////////////////////////////////////////////////////////////////////
149 //
150 int  UnitType::Agility()
151 {
152         return m_iAgility;
153 }
154
155 //////////////////////////////////////////////////////////////////////////
156 //
157 void UnitType::setWeaponSpeed(int iWPSP)
158 {
159         m_iWeaponSpeed = iWPSP;
160 }
161
162 //////////////////////////////////////////////////////////////////////////
163 //
164 int  UnitType::WeaponSpeed()
165 {
166         return m_iWeaponSpeed;
167 }
168
169 //////////////////////////////////////////////////////////////////////////
170 //
171 void UnitType::setGuns(int iGuns)
172 {
173         m_iGuns = iGuns;
174 }
175
176 //////////////////////////////////////////////////////////////////////////
177 //
178 int UnitType::Guns()
179 {
180         return m_iGuns;
181 }
182
183 //////////////////////////////////////////////////////////////////////////
184 //
185 void UnitType::setPower(int iPower)
186 {
187         m_iPower = iPower;
188 }
189
190 //////////////////////////////////////////////////////////////////////////
191 //
192 int  UnitType::Power()
193 {
194         return m_iPower;
195 }
196
197 //////////////////////////////////////////////////////////////////////////
198 //
199 void UnitType::setArmor(int iArmor)
200 {
201         m_iArmor = iArmor;
202 }
203
204 //////////////////////////////////////////////////////////////////////////
205 //
206 int  UnitType::Armor()
207 {
208         return m_iArmor;
209 }
210
211 //////////////////////////////////////////////////////////////////////////
212 //
213 void UnitType::setEMP(int iEMP)
214 {
215         m_iEMP = iEMP;
216 }
217
218 //////////////////////////////////////////////////////////////////////////
219 //
220 int  UnitType::EMP()
221 {
222         return m_iEMP;
223 }
224
225 //////////////////////////////////////////////////////////////////////////
226 //
227 void UnitType::setTotalResources(int iTR)
228 {
229         m_iTotalResources = iTR;
230 }
231
232 //////////////////////////////////////////////////////////////////////////
233 //
234 int UnitType::TotRes()
235 {
236         return m_iTotalResources;
237 }
238
239 //////////////////////////////////////////////////////////////////////////
240 //
241 void UnitType::setFuel(int iFuel)
242 {
243         m_iFuel = iFuel;
244 }
245
246 //////////////////////////////////////////////////////////////////////////
247 //
248 int  UnitType::Fuel()
249 {
250         return m_iFuel;
251 }
252
253 //////////////////////////////////////////////////////////////////////////
254 //
255 void UnitType::setETA(int iETA)
256 {
257         m_iETA = iETA;
258 }
259
260 //////////////////////////////////////////////////////////////////////////
261 //
262 int  UnitType::ETA()
263 {
264         return m_iETA;
265 }
266
267 //////////////////////////////////////////////////////////////////////////
268 //
269 void UnitType::setType(string type)
270 {
271         m_sType = type;
272 }
273
274 //////////////////////////////////////////////////////////////////////////
275 //
276 string  UnitType::Type()
277 {
278         return m_sType;
279 }
280