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(Component_h)
00031 #define Component_h
00032
00033 #include <deque>
00034 using namespace std;
00035
00036 #include "FSTypes.h"
00037 #include "Rules.h"
00038 #include "Cost.h"
00039
00040 class RacialTrait;
00041 class TiXmlNode;
00042
00043 const long WT_BEAM = 1;
00044 const long WT_GATLING = 2;
00045 const long WT_SAPPER = 3;
00046 const long WT_TORP = 4;
00047 const long WT_MISSILE = 5;
00048
00049 const long BT_NORMAL = 1;
00050 const long BT_SMART = 2;
00051 const long BT_TERRA = 3;
00052
00053 const long MT_STD = 1;
00054 const long MT_SPEED = 2;
00055 const long MT_HEAVY = 3;
00056 const long MT_MAXIMUM = MT_HEAVY;
00057
00058
00059 const long TERRA_DETERRA = 0x0010;
00060 const long TERRA_POSTERRA = 0x0020;
00061 const long TERRA_TERRABOTH = (TERRA_DETERRA | TERRA_POSTERRA);
00062 const long TERRA_TOINIT = 0x0001;
00063 const long TERRA_TOTECH = 0x0002;
00064 const long TERRA_BOMB = 0x0100;
00065 const long TERRA_REMOTE = 0x0200;
00066
00067
00068 const long THIEF_NONE = 0x00;
00069 const long THIEF_SHIP = 0x01;
00070 const long THIEF_PLANET = 0x02;
00071 const long THIEF_BOTH = THIEF_SHIP | THIEF_PLANET;
00072
00073
00074 class CargoHolder;
00075
00082 class Component {
00083 public:
00084 Component();
00085 virtual ~Component();
00086 static void Cleanup();
00087
00088
00089 const Cost & GetCost() const { return mCost; }
00090 Cost GetCost(const Player * owner) const;
00091
00092 long GetID() const { return ID; }
00093 ComponentType GetType() const { return Type; }
00094 bool IsType(ComponentType ct) const { return ct == Type;}
00095 const string GetName() const { return Name; }
00096 HullType GetHullType() const { return mHullType; }
00097 long GetTech(TechType tt) const { return Tech[tt]; }
00098 long GetMass() const { return Mass; }
00099
00100 long GetArmor() const { return Armor; }
00101 long GetShield() const { return Shield; }
00102 long GetWeaponType() const { return WeaponType; }
00103 long GetPower() const { return Power; }
00104 long GetRange() const { return Range; }
00105 long GetInit() const { return Init; }
00106 double GetAccuracy() const { return Accuracy; }
00107 long GetBombType() const { return BombType; }
00108 double GetKillper() const { return Killper; }
00109 double GetNormalKillper() const { return BombType==BT_NORMAL ? Killper : 0;}
00110 double GetSmartKillper() const { return BombType==BT_SMART ? Killper : 0;}
00111 long GetMinKill() const { return MinKill; }
00112 long GetInstKill() const { return InstKill; }
00113 long GetCloaking() const { return Cloaking; }
00114 double GetCompPower() const { return CompPower; }
00115 double GetJamming() const { return Jamming; }
00116 long GetInitAdj() const { return InitAdj; }
00117 double GetCapacitors() const { return Capacitors; }
00118 double GetDeflection() const { return Deflection; }
00119 double GetTachyon() const { return Tachyon; }
00120 bool CanColonize() const { return Colonize; }
00121 long GetCargoCapacity() const { return CargoCapacity; }
00122 long GetFuelCapacity() const { return FuelCapacity; }
00123 long GetFuelGen() const { return FuelGen; }
00124 double GetRepairRate() const { return RepairRate; }
00125 double GetSpeedBonus() const { return SpeedBonus; }
00126 long GetMineType() const { return MineType; }
00127 long GetMineAmount() const { return MineAmount; }
00128 long GetMines() const { return Mines; }
00129 long GetRemTerra() const { return RemTerra; }
00130 long GetGateMass() const { return GateMass; }
00131 long GetGateRange() const { return GateRange; }
00132 long GetDriverSpeed() const { return DriverSpeed; }
00133 long GetScanSpace() const { return ScanSpace; }
00134 long GetScanPen() const { return ScanPen; }
00135 bool CanStealShip() const { return StealShip; }
00136 bool CanStealPlanet() const { return StealPlanet; }
00137 long GetTerraType() const { return TerraType; }
00138 long GetTerraLimit() const { return TerraLimit; }
00139 double GetDefPower() const { return DefPower; }
00140 long GetSweeping(long RangeBonus) const;
00141 long GetTerraPower() const { return TerraPower; }
00142 long GetARMaxPop() const { return ARMaxPop; }
00143 long GetDock() const { return Dock; }
00144 bool CanRefuel() const { return Refuel; }
00145 double GetDampener() const { return Dampener; }
00146 double GetFuelUsage(unsigned long speed) const { if (FuelUsage.size() < speed || speed < 1 || speed > (unsigned long)Rules::GetConstant("MaxSpeed")) return 0; else return FuelUsage[speed-1]; }
00147 long GetRadiation() const { return Radiation; }
00148 long GetSafeSpeed() const { return SafeSpeed; }
00149 long GetMaxSpeed() const { return MaxSpeed; }
00150 long GetBattleSpeed() const { return BattleSpeed; }
00151 long GetFreeSpeed() const { return FreeSpeed; }
00152 bool CanJumpGate() const { return JumpGate; }
00153 bool CanNormalBomb() const {return BombType == BT_NORMAL;}
00154 bool CanSmartBomb() const {return BombType == BT_SMART;}
00155 bool CanTerraBomb() const {return BombType == BT_TERRA;}
00156
00157 static bool LoadComponents(const TiXmlNode * comps, deque<Component *> &CompList);
00158 static HullType ParseHullType(const char * ptr);
00159 static ComponentType ParseCompType(const char * ptr);
00160 static long GetScore(const Component * check, long ValueType);
00161 static const Cost * DefenseCost() { return mDefenseCost; }
00162 static const Cost * ScannerCost() { return mScannerCost; }
00163 static const Component * T0Defense();
00164 static const Component * T0PlanetScanner();
00165 static long ParseSubType(const char * ptr, bool insert);
00166 long GetValueType() const { return SubTypeIndex.size() == 0 ? -1 : SubTypeIndex[0]; }
00167
00168 bool IsBuildable(const Player * player) const;
00169
00170 static const Component * Upgrade(const Player * player);
00171
00172 private:
00173 void init();
00174
00175
00176 long ID;
00177 static long MaxID;
00178 string Name;
00179 ComponentType Type;
00180 Cost mCost;
00181 deque<long> Tech;
00182 long Mass;
00183 bool MTGift;
00184
00185
00186
00187 long Armor;
00188 long Shield;
00189
00190
00191 long WeaponType;
00192 long Power;
00193 long Range;
00194 long Init;
00195 double Accuracy;
00196
00197
00198 long BombType;
00199 double Killper;
00200 long MinKill;
00201 long InstKill;
00202
00203
00204 long Cloaking;
00205 double CompPower;
00206 double Jamming;
00207 long InitAdj;
00208 double Capacitors;
00209 double Deflection;
00210 double Tachyon;
00211 double Dampener;
00212
00213
00214 bool Colonize;
00215 long CargoCapacity;
00216 long FuelCapacity;
00217 long FuelGen;
00218 double RepairRate;
00219 double SpeedBonus;
00220
00221
00222 deque<double> FuelUsage;
00223 long Radiation;
00224 long SafeSpeed;
00225 long MaxSpeed;
00226 long BattleSpeed;
00227 long FreeSpeed;
00228
00229
00230 long MineType;
00231 long MineAmount;
00232
00233
00234 long Mines;
00235 long RemTerra;
00236 long TerraPower;
00237
00238
00239 long GateMass;
00240 long GateRange;
00241 long DriverSpeed;
00242 bool JumpGate;
00243
00244
00245 long ScanSpace;
00246 long ScanPen;
00247 bool StealShip;
00248 bool StealPlanet;
00249
00250
00251 long TerraType;
00252 long TerraLimit;
00253 double DefPower;
00254
00255
00256 bool Refuel;
00257 long Dock;
00258 long ARMaxPop;
00259
00260
00261 bool PlanetReset;
00262
00263 HullType mHullType;
00264
00265
00266 deque<const RacialTrait *> PRTNeeded;
00267 deque<const RacialTrait *> PRTDenied;
00268 deque<const RacialTrait *> LRTNeeded;
00269 deque<const RacialTrait *> LRTDenied;
00270 static deque<string> Subtypes;
00271 deque<long> SubTypeIndex;
00272 deque<long> SubTypeValue;
00273
00274 static Cost * mDefenseCost;
00275 static Cost * mScannerCost;
00276 };
00277
00278 #endif // !defined(Component_h)