Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List

Component.h

Go to the documentation of this file.
00001 /*
00002 Copyright 2003 - 2005 Elliott Kleinrock, Dan Neely, Kurt W. Over, Damon Domjan
00003 
00004 This file is part of FreeStars, a free clone of the Stars! game.
00005 
00006 FreeStars is free software; you can redistribute it and/or modify
00007 it under the terms of the GNU General Public License as published by
00008 the Free Software Foundation; either version 2 of the License, or
00009 (at your option) any later version.
00010 
00011 FreeStars is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with FreeStars; if not, write to the Free Software
00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 The full GPL Copyright notice should be in the file COPYING.txt
00021 
00022 Contact:
00023 Email Elliott at 9jm0tjj02@sneakemail.com
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 // Remote terraform:
00059 const long TERRA_DETERRA                = 0x0010;       // Can deterraform
00060 const long TERRA_POSTERRA       = 0x0020;       // Can terraform for planet owner
00061 const long TERRA_TERRABOTH      = (TERRA_DETERRA | TERRA_POSTERRA);     // can both de terra and terra
00062 const long TERRA_TOINIT         = 0x0001;       // can deterraform to the initial value
00063 const long TERRA_TOTECH         = 0x0002;       // can (de)terraform to the limits of the ship owners tech
00064 const long TERRA_BOMB           = 0x0100;       // terraform during bombing
00065 const long TERRA_REMOTE         = 0x0200;       // terraform during remote terraform phase
00066 // OAs are therefore 0x23, bombs are 0x11
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 //      long GetCost(long ct) const                     { return mCost.GetCost(ct); }
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;  // can this player build this component (right LRT and tech levels)
00169 
00170         static const Component * Upgrade(const Player * player);
00171 
00172 private:
00173         void init();
00174 
00175         // standard stuff for every component
00176         long ID;
00177         static long MaxID;
00178         string Name;
00179         ComponentType Type;     // Base type, can also have other capabilities
00180         Cost mCost;                     // Costs
00181         deque<long> Tech;       // 0 for tech 0 required, -1 for tech not needed. normal rules make no distinction. But a scout hull should be construction 0, -1 everything else
00182         long Mass;
00183         bool MTGift;
00184 
00185         // specific stuff, most will be defaults
00186         // armor and shield
00187         long Armor;             // armor DP
00188         long Shield;    // shield DP
00189 
00190         // weapons
00191         long WeaponType;        // type of weapon
00192         long Power;             // damage power
00193         long Range;             // weapon range
00194         long Init;              // weapon initiative
00195         double Accuracy;        // base accuracy
00196 
00197         // bombs
00198         long BombType;
00199         double Killper; // Bomb kill percentage
00200         long MinKill;   // Bomb min killed
00201         long InstKill;  // Bomb damage to instalations
00202 
00203         // electrical
00204         long Cloaking;          // cloaking units
00205         double CompPower;       // affect on inaccuracy of your missiles 1 for no affect, .8 is +20%
00206         double Jamming;         // affect on accuracy of incoming missiles 1 for no affect, .8 is 20% jamming
00207         long InitAdj;           // adjustment to init
00208         double Capacitors;      // beam damage multiplier - 1.1 and 1.2 for capacitors
00209         double Deflection;      // beam damage multiplier - .9 for deflectors
00210         double Tachyon;         // Power of tachyon detectors
00211         double Dampener;        // Energy Dampener (slows all ships in combat)
00212 
00213         // mechanical
00214         bool Colonize;  // true if it allows colonization
00215         long CargoCapacity;     // cargo capacity
00216         long FuelCapacity;      // Fuel capacity
00217         long FuelGen;   // Fuel generation ability
00218         double RepairRate;      // Max Repair rate helps all ships in the same fleet
00219         double SpeedBonus;      // speed bonus (.25 for Maneuver Jet)
00220 
00221         // engines
00222         deque<double> FuelUsage;        // FuelUsage for warp 1 through warp 10
00223         long Radiation; // hab type of radiation emitted, killing pop if the race can't take a lot of it (85th tick or higher)
00224         long SafeSpeed; // normally 9, some engines allow warp 10
00225         long MaxSpeed;  // For expantion for now 10 for all engines
00226         long BattleSpeed;       // battle speed of the engine, normaly dependant on FuelUsage
00227         long FreeSpeed; // 1 for stds, free speed for rams
00228 
00229         // Mine layers
00230         long MineType;  // 1 standards, 2 Heavies, 3 speed traps
00231         long MineAmount;        // number laid per year
00232 
00233         // remote mining
00234         long Mines;             // Number of remote mines
00235         long RemTerra;  // Remote terraform: 0x01 - deterra only, 0x02 improve only, 0x03 both deterra: 0x10 to initial, 0x20 terra tech (OAs are therefore 0x23, bombs are 0x11)
00236         long TerraPower;        // power of the remote terraformer
00237 
00238         // Orbitals
00239         long GateMass;  // -1 for infinite
00240         long GateRange; // -1 for infinite
00241         long DriverSpeed;       // mass driver speed
00242         bool JumpGate;          // can a ship with this part gate from anywhere
00243 
00244         // Scanners
00245         long ScanSpace; // deep space (red) scanning coverage
00246         long ScanPen;   // orbital (yellow) scanning coverage - every scanner can see a world it is in orbit of
00247         bool StealShip;
00248         bool StealPlanet;
00249 
00250         // Terraforming
00251         long TerraType; // -1 for any
00252         long TerraLimit;        // max amount of terraforming at this tech
00253         double DefPower;        // Defensive power at this tech
00254 
00255         // Station attributes
00256         bool Refuel;    // can this station refuel
00257         long Dock;              // max ship size built here -1 for infinite
00258         long ARMaxPop;  // Max pop for AR races, in cargo units (100 pop a unit)
00259 
00260         // Specials
00261         bool PlanetReset;       // building this resets the planet
00262 
00263         HullType mHullType;     // Allowed on what hull (or what hull this is)
00264 
00265         // restrictions:
00266         deque<const RacialTrait *> PRTNeeded;   // list of PRTs allowed to use this item, if empty then no restriction
00267         deque<const RacialTrait *> PRTDenied;   // list of PRTs denied use this item
00268         deque<const RacialTrait *> LRTNeeded;   // list of LRTs that allow use of this item, if empty then no restriction
00269         deque<const RacialTrait *> LRTDenied;   // list of LRTs that deny use of this item
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)

Generated on Mon Aug 8 21:33:42 2005 for Freestars by  doxygen 1.4.2-20050421