]> ruin.nu Git - hbs.git/blobdiff - bs/unittype.cpp
now compiles with gcc 3.1, might not work with gcc 3.0 though (not sure)
[hbs.git] / bs / unittype.cpp
index 38af1dacb45d6842462a7b99cca9eaef568ceace..836ddb95056f0d79978e78a48d4d5f9735762006 100644 (file)
 #include <iostream>
 using namespace std;
 
+//////////////////////////////////////////////////////////////////////////
+//
+
 UnitType::UnitType()
 {
 }
+//////////////////////////////////////////////////////////////////////////
+//
 UnitType::~UnitType(){
 }
 
 
+//////////////////////////////////////////////////////////////////////////
+//
 void UnitType::setName(string sName)
 {
        m_sName = sName;
 }
 
-string UnitType::Name()
+//////////////////////////////////////////////////////////////////////////
+//
+string UnitType::Name() const
 {
        return m_sName;
 }
 
+//////////////////////////////////////////////////////////////////////////
+//
 void UnitType::setRace(int iRace)
 {
        m_iRace = iRace;
 }
 
-int UnitType::Race()
+//////////////////////////////////////////////////////////////////////////
+//
+int UnitType::race() const
 {
        return m_iRace;
 }
 
-void UnitType::setClass(int iClass)
+//////////////////////////////////////////////////////////////////////////
+//
+void UnitType::setUnitClass(string sClass)
 {
-       m_iClass = iClass;
+       m_sClass = sClass;
 }
 
-int UnitType::iClass()
+//////////////////////////////////////////////////////////////////////////
+//
+string UnitType::unitClass() const
 {
-       return m_iClass;
+       return m_sClass;
 }
 
-void UnitType::setTarget(vector<int> Target)
+//////////////////////////////////////////////////////////////////////////
+//
+void UnitType::setTarget(vector<string> Target)
 {
        m_vTarget = Target;
 }
 
-void UnitType::addTarget(int iTarget)
+//////////////////////////////////////////////////////////////////////////
+//
+void UnitType::addTarget(string target)
 {
-       m_vTarget.push_back(iTarget);
+       m_vTarget.push_back(target);
 }
 
-/** This function iterates through the list until it finds the right positition. If it finds the position it inserts the target there, if it reaches the end before it finds the correct possition it adds the target to the end. 
+//////////////////////////////////////////////////////////////////////////
+//
+/** This function iterates through the list until it finds the right positition.
+ * If it finds the position it inserts the target there, if it reaches the end 
+ * before it finds the correct possition it adds the target to the end. 
  */
-void UnitType::insTarget(int iTarget, int index = 0)
+void UnitType::insTarget(string target, int index)
 {
 
-       vector<int>::iterator i = m_vTarget.begin();    
+       vector<string>::iterator i = m_vTarget.begin(); 
 
        for (int j = 0; j < index; j++, i++)
        {
                if (i == m_vTarget.end())
                {
-                       m_vTarget.push_back(iTarget);
+                       m_vTarget.push_back(target);
                        return;
                }
        }
 
-       m_vTarget.insert(i, iTarget);
+       m_vTarget.insert(i, target);
 }
 
-vector<int> UnitType::Target()
+//////////////////////////////////////////////////////////////////////////
+//
+vector<string> UnitType::target() const
 {
        return m_vTarget;
 }
 
-int    UnitType::Target(int index)
+//////////////////////////////////////////////////////////////////////////
+//
+string UnitType::target(int index) const
 {
        return m_vTarget[index];
 }
 
+//////////////////////////////////////////////////////////////////////////
+//
 void UnitType::setInitiative(int iInit)
 {
        m_iInitiative = iInit;
 }
 
-int     UnitType::Initiative()
+//////////////////////////////////////////////////////////////////////////
+//
+int     UnitType::initiative() const
 {
        return m_iInitiative;
 }
 
+//////////////////////////////////////////////////////////////////////////
+//
 void UnitType::setAgility (int iAgil)
 {
        m_iAgility = iAgil;
 }
 
-int  UnitType::Agility()
+//////////////////////////////////////////////////////////////////////////
+//
+int  UnitType::agility() const
 {
        return m_iAgility;
 }
 
+//////////////////////////////////////////////////////////////////////////
+//
 void UnitType::setWeaponSpeed(int iWPSP)
 {
        m_iWeaponSpeed = iWPSP;
 }
 
-int  UnitType::WeaponSpeed()
+//////////////////////////////////////////////////////////////////////////
+//
+int  UnitType::weaponSpeed() const
 {
        return m_iWeaponSpeed;
 }
 
+//////////////////////////////////////////////////////////////////////////
+//
 void UnitType::setGuns(int iGuns)
 {
        m_iGuns = iGuns;
 }
 
-int UnitType::Guns()
+//////////////////////////////////////////////////////////////////////////
+//
+int UnitType::guns() const
 {
        return m_iGuns;
 }
 
+//////////////////////////////////////////////////////////////////////////
+//
 void UnitType::setPower(int iPower)
 {
        m_iPower = iPower;
 }
 
-int  UnitType::Power()
+//////////////////////////////////////////////////////////////////////////
+//
+int  UnitType::power() const
 {
        return m_iPower;
 }
 
+//////////////////////////////////////////////////////////////////////////
+//
 void UnitType::setArmor(int iArmor)
 {
        m_iArmor = iArmor;
 }
 
-int  UnitType::Armor()
+//////////////////////////////////////////////////////////////////////////
+//
+int  UnitType::armor() const
 {
        return m_iArmor;
 }
 
+//////////////////////////////////////////////////////////////////////////
+//
 void UnitType::setEMP(int iEMP)
 {
        m_iEMP = iEMP;
 }
 
-int  UnitType::EMP()
+//////////////////////////////////////////////////////////////////////////
+//
+int  UnitType::EMP() const
 {
        return m_iEMP;
 }
 
-void UnitType::setTotalResources(int iTR)
+//////////////////////////////////////////////////////////////////////////
+//
+void UnitType::setResources(std::string type, int i)
+{
+       m_Resources[type] = i;
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+void UnitType::setResources(map<std::string, int> res)
+{
+       m_Resources = res;
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+std::map<std::string, int> UnitType::resources()
 {
-       m_iTotalResources = iTR;
+       return m_Resources;
 }
 
-int UnitType::TotRes()
+//////////////////////////////////////////////////////////////////////////
+//
+int UnitType::totRes() const
 {
-       return m_iTotalResources;
+       int totres = 0;
+       for (map<string, int>::const_iterator i = m_Resources.begin(); i != m_Resources.end(); ++i)
+               totres += i->second;
+       return totres;
 }
 
+//////////////////////////////////////////////////////////////////////////
+//
 void UnitType::setFuel(int iFuel)
 {
        m_iFuel = iFuel;
 }
 
-int  UnitType::Fuel()
+//////////////////////////////////////////////////////////////////////////
+//
+int  UnitType::fuel() const
 {
        return m_iFuel;
 }
 
+//////////////////////////////////////////////////////////////////////////
+//
 void UnitType::setETA(int iETA)
 {
        m_iETA = iETA;
 }
 
-int  UnitType::ETA()
+//////////////////////////////////////////////////////////////////////////
+//
+int  UnitType::ETA() const
 {
        return m_iETA;
 }
 
-void UnitType::setType(int iType)
+//////////////////////////////////////////////////////////////////////////
+//
+void UnitType::setType(string type)
 {
-       m_iType = iType;
+       m_sType = type;
 }
 
-int  UnitType::Type()
+//////////////////////////////////////////////////////////////////////////
+//
+string  UnitType::type() const
 {
-       return m_iType;
+       return m_sType;
 }