1 /***************************************************************************
2 unittype.cpp - description
4 begin : Tue Jan 22 2002
5 copyright : (C) 2002 by Michael Andreen
7 ***************************************************************************/
9 /***************************************************************************
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. *
16 ***************************************************************************/
22 //////////////////////////////////////////////////////////////////////////
28 //////////////////////////////////////////////////////////////////////////
30 UnitType::~UnitType(){
34 //////////////////////////////////////////////////////////////////////////
36 void UnitType::setName(string sName)
41 //////////////////////////////////////////////////////////////////////////
43 string UnitType::Name() const
48 //////////////////////////////////////////////////////////////////////////
50 void UnitType::setRace(int iRace)
55 //////////////////////////////////////////////////////////////////////////
57 int UnitType::race() const
62 //////////////////////////////////////////////////////////////////////////
64 void UnitType::setUnitClass(string sClass)
69 //////////////////////////////////////////////////////////////////////////
71 string UnitType::unitClass() const
76 //////////////////////////////////////////////////////////////////////////
78 void UnitType::setTarget(vector<string> Target)
83 //////////////////////////////////////////////////////////////////////////
85 void UnitType::addTarget(string target)
87 m_vTarget.push_back(target);
90 //////////////////////////////////////////////////////////////////////////
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.
96 void UnitType::insTarget(string target, int index = 0)
99 vector<string>::iterator i = m_vTarget.begin();
101 for (int j = 0; j < index; j++, i++)
103 if (i == m_vTarget.end())
105 m_vTarget.push_back(target);
110 m_vTarget.insert(i, target);
113 //////////////////////////////////////////////////////////////////////////
115 vector<string> UnitType::target() const
120 //////////////////////////////////////////////////////////////////////////
122 string UnitType::target(int index) const
124 return m_vTarget[index];
127 //////////////////////////////////////////////////////////////////////////
129 void UnitType::setInitiative(int iInit)
131 m_iInitiative = iInit;
134 //////////////////////////////////////////////////////////////////////////
136 int UnitType::initiative() const
138 return m_iInitiative;
141 //////////////////////////////////////////////////////////////////////////
143 void UnitType::setAgility (int iAgil)
148 //////////////////////////////////////////////////////////////////////////
150 int UnitType::agility() const
155 //////////////////////////////////////////////////////////////////////////
157 void UnitType::setWeaponSpeed(int iWPSP)
159 m_iWeaponSpeed = iWPSP;
162 //////////////////////////////////////////////////////////////////////////
164 int UnitType::weaponSpeed() const
166 return m_iWeaponSpeed;
169 //////////////////////////////////////////////////////////////////////////
171 void UnitType::setGuns(int iGuns)
176 //////////////////////////////////////////////////////////////////////////
178 int UnitType::guns() const
183 //////////////////////////////////////////////////////////////////////////
185 void UnitType::setPower(int iPower)
190 //////////////////////////////////////////////////////////////////////////
192 int UnitType::power() const
197 //////////////////////////////////////////////////////////////////////////
199 void UnitType::setArmor(int iArmor)
204 //////////////////////////////////////////////////////////////////////////
206 int UnitType::armor() const
211 //////////////////////////////////////////////////////////////////////////
213 void UnitType::setEMP(int iEMP)
218 //////////////////////////////////////////////////////////////////////////
220 int UnitType::EMP() const
225 //////////////////////////////////////////////////////////////////////////
227 void UnitType::setResources(std::string type, int i)
229 m_Resources[type] = i;
232 //////////////////////////////////////////////////////////////////////////
234 void UnitType::setResources(map<std::string, int> res)
239 //////////////////////////////////////////////////////////////////////////
241 std::map<std::string, int> UnitType::resources()
246 //////////////////////////////////////////////////////////////////////////
248 int UnitType::totRes() const
251 for (map<string, int>::const_iterator i = m_Resources.begin(); i != m_Resources.end(); ++i)
256 //////////////////////////////////////////////////////////////////////////
258 void UnitType::setFuel(int iFuel)
263 //////////////////////////////////////////////////////////////////////////
265 int UnitType::fuel() const
270 //////////////////////////////////////////////////////////////////////////
272 void UnitType::setETA(int iETA)
277 //////////////////////////////////////////////////////////////////////////
279 int UnitType::ETA() const
284 //////////////////////////////////////////////////////////////////////////
286 void UnitType::setType(string type)
291 //////////////////////////////////////////////////////////////////////////
293 string UnitType::type() const