1 /***************************************************************************
2 fleet.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 ***************************************************************************/
24 map<string, vector<int> > Fleet::s_Races;
25 map<string, UnitType > Fleet::s_Units;
35 //////////////////////////////////////////////////////////////////////////
37 void Fleet::setName(string sName)
42 //////////////////////////////////////////////////////////////////////////
49 //////////////////////////////////////////////////////////////////////////
51 /** This function first sets the race, then it iterates through the the
52 * s_Races and checks if it finds the race it returns true, if it reaches
53 * the end without finding it it returns false.
55 bool Fleet::setRace(std::string sRace)
58 for (map<string, vector<int> >::iterator i = s_Races.begin(); i != s_Races.end(); i++)
60 if (m_sRace == (*i).first)
66 //////////////////////////////////////////////////////////////////////////
73 //////////////////////////////////////////////////////////////////////////
75 /** This function iterates through m_Fleet and adds all numbers together to
78 int Fleet::NumberOfShips()
82 for (map<string, vector<int> >::iterator i = m_Fleet.begin(); i != m_Fleet.end(); i++)
84 total += m_Fleet[(*i).first][0];
90 //////////////////////////////////////////////////////////////////////////
92 void Fleet::setETA(int eta)
97 //////////////////////////////////////////////////////////////////////////
104 //////////////////////////////////////////////////////////////////////////
106 void Fleet::setRaces(std::map<std::string, std::vector<int> >& races)
111 //////////////////////////////////////////////////////////////////////////
113 void Fleet::setUnits(map<std::string, UnitType>& units)
117 for (map<string, UnitType >::iterator i = s_Units.begin(); i != s_Units.end(); i++)
119 cerr << s_Units[(*i).first].Name() << "\t"
120 << s_Units[(*i).first].Race() <<"\t"
121 << s_Units[(*i).first].Class() << "\t"
122 << s_Units[(*i).first].Target(0) << "\t"
123 << s_Units[(*i).first].Target(1) << "\t"
124 << s_Units[(*i).first].Target(2) << "\t"
125 << s_Units[(*i).first].Initiative() << "\t"
126 << s_Units[(*i).first].Agility() << "\t"
127 << s_Units[(*i).first].WeaponSpeed() << "\t"
128 << s_Units[(*i).first].Guns() << "\t"
129 << s_Units[(*i).first].Power() << "\t"
130 << s_Units[(*i).first].Armor() << "\t"
131 << s_Units[(*i).first].EMP() << "\t"
132 << s_Units[(*i).first].TotRes() << "\t"
133 << s_Units[(*i).first].Fuel() << "\t"
134 << s_Units[(*i).first].ETA() << "\t"
135 << s_Units[(*i).first].Type() << endl;