00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00030 #if !defined(Ship_h)
00031 #define Ship_h
00032
00033 #include <string>
00034 #include <list>
00035
00036 class Player;
00037 class CargoHolder;
00038
00039 #include "Slot.h"
00040 #include "Cost.h"
00041
00042 class Component;
00043 class Hull;
00044
00049 class Ship {
00050 public:
00051 Ship();
00052 virtual ~Ship();
00053 static void Cleanup();
00054
00055 bool ParseNode(const TiXmlNode * node, Player * player, bool other);
00056 void WriteNode(TiXmlNode * node, bool Host, bool Owner, bool SeeDesign) const;
00057
00058 bool IsValidDesign() const;
00059 bool IsValidDesign(const Player * player) const;
00060
00061 long TechLevel(TechType tech) const;
00062 const Cost & GetCost(const Player * owner, const Ship * from =NULL, const Planet * planet =NULL) const;
00063
00064 string GetName() const { return mName; }
00065 bool IsGift() const { return mGift; }
00066
00067 bool CanStealShip() const;
00068 bool CanStealPlanet() const;
00069 long GetScanPen(const Player * player, long pop = 0) const;
00070 long GetScanSpace(const Player * player, long pop = 0) const;
00071 long GetCloaking() const;
00072 long GetFuelCapacity() const;
00073 long GetFuelGen() const;
00074 long GetMass() const;
00075 double GetTachyon() const;
00076 long GetCargoCapacity() const;
00077 long GetShield(const Player * p) const;
00078 long GetArmor(const Player * p) const;
00079 long GetSweeping() const;
00080 long GetInitAdj() const;
00081 double GetSpeedBonus() const;
00082 long GetMines() const;
00083 long GetARMaxPop() const;
00084 long GetDock() const;
00085 double GetCompPower() const;
00086 double GetJamming() const;
00087 double GetCapacitors() const;
00088 double GetDeflection() const;
00089 double GetDampener() const;
00090 double GetRepairRate() const;
00091 bool DoesRadiate(HabType ht) const;
00092 bool CanColonize() const;
00093 bool CanRefuel() const;
00094 long GetDriverSpeed() const;
00095 long CountDrivers() const;
00096
00097 long GetTerraPower(long type) const;
00098 long GetMineAmount(long type) const;
00099 double GetFuelUsage(long speed) const;
00100 long GetSafeSpeed() const;
00101 long GetMaxSpeed() const;
00102 long GetBattleSpeed() const;
00103 long GetFreeSpeed() const;
00104 long GetRating() const;
00105 bool CanShoot() const;
00106 bool CanBomb() const {return CanNormalBomb() || CanTerraBomb() || CanSmartBomb();}
00107 bool CanNormalBomb() const;
00108 bool CanTerraBomb() const;
00109 bool CanSmartBomb() const;
00110 double GetNormalKillper() const;
00111
00112 long GetMinKill() const;
00113 long GetInstKill() const;
00114 long GetNetSpeed() const;
00115 long GetNetInit() const;
00116 bool CanJumpGate() const;
00117 const Component * GetGate() const;
00118 long GetEngines() const;
00119
00120 bool IsBattleTarget(HullType hc) const;
00121 long GetAttractiveCost(const Player * owner) const;
00122 double GetAccuracy(const Component & torp, const Ship * target) const;
00123
00124 void ResetSeen();
00125 bool SeenHull(long p) const { return mSeenHull[p]; }
00126 bool SeenDesign(long p) const { return mSeenDesign[p]; }
00127 void SetSeenHull(long p, bool seen) { mSeenHull[p] = seen; }
00128 void SetSeenDesign(long p, bool seen) { mSeenDesign[p] = seen; }
00129
00130 void IncrementBuilt(long number) { mBuilt += number; }
00131
00132 const Hull * GetHull() const { return mHull; }
00133
00134 const Slot & GetSlot(int i) const { return mSlots[i]; }
00135
00136 void CopyDesign(const Ship * sd, bool IsGift);
00137 void Upgrade(const Player * player);
00138 void SetCannotBuild(const Component * comp) { mCannotBuild = comp; }
00139 const Component * GetCannotBuild() const { return mCannotBuild; }
00140
00141 friend bool operator==(const Ship & s1, const Ship & s2);
00142
00143 private:
00144 void ResetDefaults();
00145 std::string mName;
00146 long mGraphicNumber;
00147 bool mGift;
00148 deque<Slot> mSlots;
00149 const Hull * mHull;
00150 long mBuilt;
00151 long ReCost;
00152 void ScrapRecover(Cost & c, int number, const Planet * planet) const;
00153
00154 deque<bool> mSeenDesign;
00155 deque<bool> mSeenHull;
00156
00157 friend class Bombing;
00158
00159 const Component * mCannotBuild;
00160
00161 static Cost mUpCost;
00162
00163 Cost CVCost;
00164
00165 long CVFuelCapacity;
00166 long CVFuelGen;
00167 long CVMass;
00168 double CVTachyon;
00169 bool CCalcTachyon;
00170 long CVCargoCapacity;
00171 long CVArmor;
00172 long CVShield;
00173 long CVInitAdj;
00174 double CVSpeedBonus;
00175 bool CCalcSpeedBonus;
00176 long CVMines;
00177 long CVARMaxPop;
00178 long CVDock;
00179
00180 double CVCompPower;
00181 bool CCalcCompPower;
00182 double CVJamming;
00183 bool CCalcJamming;
00184 double CVCapacitors;
00185 bool CCalcCapacitors;
00186 double CVDeflection;
00187 bool CCalcDeflection;
00188
00189 double CVDampener;
00190 bool CCalcDampener;
00191 double CVRepairRate;
00192 bool CCalcRepairRate;
00193 long CVSafeSpeed;
00194 long CVMaxSpeed;
00195 long CVBattleSpeed;
00196 long CVFreeSpeed;
00197
00198 long CVColonize;
00199 long CVRefuel;
00200 long CVDriverSpeed;
00201 long CVCountDrivers;
00202
00203 long CVStealShip;
00204 long CVStealPlanet;
00205
00206 long CVCloaking;
00207 long CVSweeping;
00208 long CVScanSpace;
00209 long CVScanPen;
00210 long CVRating;
00211 long CVShoot;
00212 long CVNormalBomb;
00213 long CVSmartBomb;
00214 long CVTerraBomb;
00215 long CVJumpGate;
00216 long CVEngines;
00217
00218 double CVNormalKillper;
00219 bool CCalcNormalKillper;
00220 long CVMinKill;
00221 long CVInstKill;
00222
00223 deque<long> CVTechLevel;
00224 deque<long> CVMineAmount;
00225 deque<double> CVFuelUsage;
00226 deque<bool> CalcedFuelUsage;
00227 deque<long> CVRadiation;
00228 };
00229
00230 #endif // !defined(Ship_h)