]> ruin.nu Git - hbs.git/commitdiff
Some fixes..
authorMichael Andreen <harv@ruin.nu>
Tue, 5 Mar 2002 23:20:59 +0000 (23:20 +0000)
committerMichael Andreen <harv@ruin.nu>
Tue, 5 Mar 2002 23:20:59 +0000 (23:20 +0000)
bs/fleet.h
bs/ui/battlesumbase.ui
bs/unittype.cpp
bs/unittype.h

index 7a2f489e57c3c5858520aa97bfe7ad3c8ba61dd8..7c2f817f4f60b6afb43d7c9d87633f072b3c9fc3 100644 (file)
 #include <map>
 #include <string>
 
-/**
+#include "unittype.h"
+
+//!This is the engine for the whole battlesystem.
+/**This is the engine for the whole battlesystem.
+  *    One of the few parts that I plan make fully portable.
   *@author Michael Andreen
-  *This is the engine for the whole battlesystem.
-  *One of the few parts that I plan make fully portable.
   */
 
 class Fleet 
@@ -34,9 +36,11 @@ public:
        ~Fleet();
 
 private:
-       string  m_name;
-       string  m_race;
-       map<string, units> 
+       std::string     m_Name;
+       std::string     m_Race;
+       std::map<std::string, std::vector<int> >        m_Fleet;
+
+       static std::map<std::string, UnitType>  m_Units;
 };
 
 #endif
index a0935de4e7f3330dd27166da8d3ae9dd21b3c133..216757ce6602d1497b712e7c3f9bb52b4ab6c4b2 100644 (file)
                                 <property name="text">
                                     <string>Total</string>
                                 </property>
+                                <property name="pixmap">
+                                    <pixmap></pixmap>
+                                </property>
                             </column>
                             <column>
                                 <property name="text">
                                     <string>L/S</string>
                                 </property>
+                                <property name="pixmap">
+                                    <pixmap></pixmap>
+                                </property>
                             </column>
                             <column>
                                 <property name="text">
                                     <string>Total</string>
                                 </property>
+                                <property name="pixmap">
+                                    <pixmap></pixmap>
+                                </property>
                             </column>
                             <column>
                                 <property name="text">
                                     <string>L/S</string>
                                 </property>
-                            </column>
-                            <row>
-                                <property name="text">
-                                    <string>Interceptors</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Pheonix</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Warfrigate</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Devistator</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Starcruiser</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Dreadnaught</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Spider</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Ghost</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Tarantula</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Spectre</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Astropod</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Meson</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Hyperon</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Neutron</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Photon</string>
+                                <property name="pixmap">
+                                    <pixmap></pixmap>
                                 </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>ION</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Resource</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Metal</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Crystal</string>
-                                </property>
-                            </row>
-                            <row>
-                                <property name="text">
-                                    <string>Eonium</string>
-                                </property>
-                            </row>
+                            </column>
                             <property name="name">
                                 <cstring>fleetTable</cstring>
                             </property>
                                 <enum>Default</enum>
                             </property>
                             <property name="numRows">
-                                <number>20</number>
+                                <number>0</number>
                             </property>
                             <property name="numCols">
                                 <number>4</number>
index 3b57cc1544cf8ad517ab891fda6caa5875ed6fdd..38af1dacb45d6842462a7b99cca9eaef568ceace 100644 (file)
  ***************************************************************************/
 
 #include "unittype.h"
+#include <iostream>
+using namespace std;
 
-UnitType::UnitType(){
+UnitType::UnitType()
+{
 }
 UnitType::~UnitType(){
 }
+
+
+void UnitType::setName(string sName)
+{
+       m_sName = sName;
+}
+
+string UnitType::Name()
+{
+       return m_sName;
+}
+
+void UnitType::setRace(int iRace)
+{
+       m_iRace = iRace;
+}
+
+int UnitType::Race()
+{
+       return m_iRace;
+}
+
+void UnitType::setClass(int iClass)
+{
+       m_iClass = iClass;
+}
+
+int UnitType::iClass()
+{
+       return m_iClass;
+}
+
+void UnitType::setTarget(vector<int> Target)
+{
+       m_vTarget = Target;
+}
+
+void UnitType::addTarget(int iTarget)
+{
+       m_vTarget.push_back(iTarget);
+}
+
+/** 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)
+{
+
+       vector<int>::iterator i = m_vTarget.begin();    
+
+       for (int j = 0; j < index; j++, i++)
+       {
+               if (i == m_vTarget.end())
+               {
+                       m_vTarget.push_back(iTarget);
+                       return;
+               }
+       }
+
+       m_vTarget.insert(i, iTarget);
+}
+
+vector<int> UnitType::Target()
+{
+       return m_vTarget;
+}
+
+int    UnitType::Target(int index)
+{
+       return m_vTarget[index];
+}
+
+void UnitType::setInitiative(int iInit)
+{
+       m_iInitiative = iInit;
+}
+
+int     UnitType::Initiative()
+{
+       return m_iInitiative;
+}
+
+void UnitType::setAgility (int iAgil)
+{
+       m_iAgility = iAgil;
+}
+
+int  UnitType::Agility()
+{
+       return m_iAgility;
+}
+
+void UnitType::setWeaponSpeed(int iWPSP)
+{
+       m_iWeaponSpeed = iWPSP;
+}
+
+int  UnitType::WeaponSpeed()
+{
+       return m_iWeaponSpeed;
+}
+
+void UnitType::setGuns(int iGuns)
+{
+       m_iGuns = iGuns;
+}
+
+int UnitType::Guns()
+{
+       return m_iGuns;
+}
+
+void UnitType::setPower(int iPower)
+{
+       m_iPower = iPower;
+}
+
+int  UnitType::Power()
+{
+       return m_iPower;
+}
+
+void UnitType::setArmor(int iArmor)
+{
+       m_iArmor = iArmor;
+}
+
+int  UnitType::Armor()
+{
+       return m_iArmor;
+}
+
+void UnitType::setEMP(int iEMP)
+{
+       m_iEMP = iEMP;
+}
+
+int  UnitType::EMP()
+{
+       return m_iEMP;
+}
+
+void UnitType::setTotalResources(int iTR)
+{
+       m_iTotalResources = iTR;
+}
+
+int UnitType::TotRes()
+{
+       return m_iTotalResources;
+}
+
+void UnitType::setFuel(int iFuel)
+{
+       m_iFuel = iFuel;
+}
+
+int  UnitType::Fuel()
+{
+       return m_iFuel;
+}
+
+void UnitType::setETA(int iETA)
+{
+       m_iETA = iETA;
+}
+
+int  UnitType::ETA()
+{
+       return m_iETA;
+}
+
+void UnitType::setType(int iType)
+{
+       m_iType = iType;
+}
+
+int  UnitType::Type()
+{
+       return m_iType;
+}
+
index 5c66e011eec98d8d189a6410785d4aa04621b3d6..428588b3bd59f976d9e53239f0c0a2e75e180f02 100644 (file)
 #ifndef UNITTYPE_H
 #define UNITTYPE_H
 
+#include <map>
+#include <vector>
+#include <string>
 
-/**
-  *@author Michael Andreen
+//!This class contains a unittype, with all it's attributes + the number you got.
+//
+/**This class contains a unittype, with all it's attributes + the number you got.
+ * Maybe this actually should be a struct, since this class doen't have much to do, since i want it to be as generic as possible.  
+ * It got some data need need to be taken care of which makes me put it as a class. 
+  *@author Michael Andreen <whale@linux.nu>
+  *@see Fleet
   */
 
-class UnitType {
+class UnitType 
+{
 public: 
        UnitType();
        ~UnitType();
+       
+       /*! This function sets the name for this unittype (ie. interceptor) */
+       void setName(std::string sName);
+       /** Returns the name of this unittype */
+       std::string Name();
+
+       /** This functions sets which race this unittype is, the race is represented with a integer. */
+       void setRace(int iRace);
+       /** Returns the race this unittype belongs to*/
+       int Race();
+
+       /** Sets the class for the unittype, it's represented as a integer */
+       void setClass(int iClass);
+       int iClass();
+
+       /** Sets the classes that this unittype targets. a vector is used. */
+       void setTarget(std::vector<int> Target);
+       /** This function adds a target class to the end of the target list. */
+       void addTarget(int iTarget);
+       /** This function inserts a target class into the target list. The default is in the beginning.
+        * \param iTarget an integer that represents the target's class. 
+        * \param index where to place the target. 0 being the default and first place. */
+       void insTarget(int iTarget, int index = 0);
+       /** Returns all targets from the target list */
+       std::vector<int> Target();
+       /** Returns a specific target 
+        * \param index An index value that represents the target. 0 being the first*/
+       int     Target(int index);
+
+       /** Sets the initiatve, the lower it is the earlier the unit shots */
+       void setInitiative(int iInit);
+       int      Initiative();
+
+       /** Sets the agility, the higher it is the harder it is to hit the unit */
+       void setAgility (int iAgil);
+       int  Agility();
+
+       /** Sets the weaponspeed.. just a simple integer that shows how good it is at hitting things */
+       void setWeaponSpeed(int iWPSP);
+       int  WeaponSpeed();
+
+       /** Sets the number of guns. */
+       void setGuns(int iGuns);
+       int Guns();
+
+       /** Sets the how much power the guns have.. or in other words: the damage they do. */
+       void setPower(int iPower);
+       int  Power();
+
+       /** Sets the armor, this is how much damage the unittype can take before it's destroyed */
+       void setArmor(int iArmor);
+       int  Armor();
+
+       /** Sets the emp resistance, the lower value the easier it is to block it */
+       void setEMP(int iEMP);
+       int  EMP();
+
+       /** Sets the resource cost for this unittype. Used for example for score calculation and so on. */
+       void setTotalResources(int iTR);
+       /** Returns the number of total resources this unittype cost. */
+       int TotRes();
+
+       /** Sets the fuelcost for this unittype */
+       void setFuel(int iFuel);
+       /** Returns the fuelcost */
+       int  Fuel();
+
+       /** Sets the ETA, the speed in a sort of inverted form.. the lower ETA, the faster is the unit */
+       void setETA(int iETA);
+       int  ETA(); 
+
+       /** Sets the type of the unit. What the types do must be specified in the real battle engine (Fleet) though.
+        * \param iType An integer to symbolise the type. */
+       void setType(int iType);
+       /** What type of ship this is. */
+       int  Type();    
+protected:
+       std::string             m_sName;
+       int                     m_iRace;            //!< Not really the race, but an indiaction on what race can use it.. 
+       int                     m_iClass;
+       std::vector<int>        m_vTarget;
+       int                     m_iInitiative;
+       int                     m_iAgility;
+       int                     m_iWeaponSpeed;
+       int                     m_iGuns;
+       int                     m_iPower;
+       int                     m_iArmor;
+       int                     m_iEMP;
+       int                     m_iTotalResources;
+       int                     m_iType;            //!< normal,emp,cloak,steal,pod
+       int                     m_iETA;
+       int                     m_iFuel;
 };
 
 #endif