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

Fleet.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(Fleet_h)
00031 #define Fleet_h
00032 
00033 #include <string>
00034 #include <deque>
00035 using namespace std;
00036 
00037 #include "Rules.h"
00038 #include "Stack.h"
00039 
00040 class TiXmlNode;
00041 class Player;
00042 class Planet;
00043 class Ship;
00044 class MineField;
00045 class WaypointOrder;
00046 
00047 class WayOrder;
00048 //#include "WayOrder.h"
00049 #include "Galaxy.h"
00050 #include "CargoHolder.h"
00051 
00055 class Fleet : public CargoHolder {
00056 public:
00057         Fleet();
00058         Fleet(int id, const CargoHolder &loc);
00059         virtual ~Fleet();
00060 
00061         void Init();
00062         virtual bool ParseNode(const TiXmlNode * node, Player * player, bool other);
00063         virtual TiXmlNode * WriteNode(TiXmlNode * node, const Player * viewer) const;
00064 
00065         virtual const string GetName(const Player * viewer) const;
00066         long GetFuel() const    { return mFuel; }
00067         long GetFuelNeeded() const;     // fuel needed to make it to the next waypoint (waypoint 2)
00068         void AdjustFuel(long amount);
00069         void Refuel()                   { if (mFuel < GetFuelCapacity()) Refuel(InOrbit()); }
00070         void Refuel(const Planet * p);
00071         void SetName(const char * n)    { mName = n; }
00072 
00073         enum FuncType {
00074                 FTScrap                 = 1,
00075                 FTUnload0               = 2,
00076                 FTColonize0             = 3,
00077                 FTLoad0                 = 4,
00078                 FTMove                  = 5,
00079                 FTRemoteMine    = 6,
00080                 FTFreighterReproduction = 7,
00081                 FTCheckWaypoint = 8,
00082                 FTRefuel                = 9,
00083                 FTUnload1               = 10,
00084                 FTColonize1             = 11,
00085                 FTLoad1                 = 12,
00086                 FTMerge                 = 13,
00087                 FTClearWaypoint = 14,
00088                 FTRemoteTerraform = 15,
00089                 FTRepair                = 16,
00090         };
00091         bool Process(FuncType func, bool arg);
00092         void Scrap(bool colonize);
00093         void KillFleet();
00094         void ProcessTransport(bool load, bool dunnage);
00095         void Colonize();
00096         void RemoteMine(bool ARmining);
00097         bool Move();
00098         void FreighterReproduction();
00099         bool Move1LY(Location & dest, long speed);
00100         void CheckWaypoint();
00101         void ClearWaypoint();
00102         void CheckMerge();
00103         void RemoteTerraform(bool bomb);
00104         void Repair();
00105 
00106         Planet * InOrbit() const        { return TheGalaxy->GetPlanet(this); }
00107         virtual long GetCloak(const Player *, bool) const;
00108         void MergeTo(Fleet * to);
00109         void MergeTo(Fleet * to, const Ship * design, long number, long damaged);
00110         bool IsEmpty() const    { return mStacks.size() == 0; }
00111         const deque<WayOrder *> GetOrders() const               { return mOrders; }
00112         const WayOrder* GetFirstOrder() { return mOrders[0]; }
00113         void SetStartOrders(Planet * planet);
00114         void SetNextRoute(Planet * planet);
00115         long GetBestSpeed(const Location * L1, const Location * L2, OrderType ot);
00116 
00117         void ChangeWaypoints(WayOrderList & wol);
00118         void SetRepeat(bool repeat);
00119         bool GetRepeat() const  { return mRepeatOrders; }
00120         void SetBattlePlan(long bp);
00121 
00122         void AddChaser(unsigned long p, unsigned long f);
00123         void TakeMinefieldDamage(MineField * field);
00124 
00125         void SetSeenDesign(long p, bool seen, bool design);
00126         virtual void ResetSeen();
00127         virtual void SetSeenBy(long p, bool seen);
00128         virtual void SetCanLoadBy(const Player * player);
00129         virtual bool CanLoadBy(const Player * player) const;
00130 
00131         // stuff from components
00132         long TechLevel(TechType tech) const;
00133         const Cost & GetCost() const;
00134         long GetCloaking() const;
00135         virtual bool CanStealShip() const;
00136         virtual bool CanStealPlanet() const;
00137         long GetCargoCapacity() const;
00138         long GetScanPen() const;
00139         long GetScanSpace() const;
00140         long GetFuelCapacity() const;
00141         long GetFuelGen() const;
00142         long GetMass() const;
00143         long GetMaxMass() const;
00144         double GetMaxTachyon() const;
00145         long GetSweeping() const;
00146         long GetMines() const;
00147         double GetMaxDampener() const;
00148         double GetMaxRepairRate() const;
00149         bool DoesRadiate(HabType ht) const;
00150         double RadDamage() const;
00151         bool CanColonize() const;
00152         long GetTerraPower(long type) const;
00153         long GetMineAmount(long type) const;
00154         double GetFuelUsage(long speed) const;
00155         long GetMinSafeSpeed() const;
00156         long GetMinMaxSpeed() const;
00157         long GetMinFreeSpeed() const;
00158         long GetMinBattleSpeed() const;
00159         bool CanShoot() const;          // Is any ship of this fleet armed
00160         bool CanNormalBomb() const; // Can any ship do normal bombing
00161         bool CanSmartBomb() const; // Can any ship smart bomb
00162         bool CanTerraBomb() const; // Can any ship terra bomb
00163         bool CanJumpGate() const;
00164         bool CanBomb() const{return CanNormalBomb() || CanSmartBomb() || CanTerraBomb();}// Can any ship bomb
00165         void AddShips(long Type, long number);
00166         bool AlreadyFought() const      { return mAlreadyFought; }
00167         void SetAlreadyFought()         { mAlreadyFought = true; }
00168         const BattlePlan * GetBattlePlan() const;
00169         void SetInBattle(bool in)       { mInBattle = in; }
00170         bool GetInBattle() const        { return mInBattle; }
00171         long GetShipCount() const;
00172         bool KillShips(long i, long count, bool salvage);
00173         
00174         double GetNormalKillper() const;
00175         //long GetSmartKillper() const;
00176         long GetMinKill() const;
00177         long GetInstKill() const;
00178 
00179 private:
00180         void Merge(Stack &stack, long number, long damaged, long Origin);
00181 
00182         long mFuel;
00183         string mName;
00184         deque<Stack> mStacks;  // stacks of different ships
00185         long mRepairRate;       // how much this fleet will repair this turn - 0: nothing (gated); 1: fleet moved through space; 2: fleet didn't move
00186         long mBattlePlan;
00187         bool mAlreadyFought;
00188         bool mInBattle;
00189         bool mHasMoved;
00190         long mDistMoved;        // distance already moved this turn
00191         Location mStartPos;     // where this fleet started the turn
00192         double mPX;     // current location while in flight
00193         double mPY;     // current location while in flight
00194         bool mDoneWaypoint;     // true if we've arrived at our destination and are ready to do waypoint 1 tasks
00195 
00196         deque<WayOrder *> mOrders;
00197         bool mRepeatOrders;
00198 
00199         friend class WayOrder;
00200         friend class Battle;
00201         friend class Bombing;
00202 
00203         const Fleet * mChasing;
00204         class Chaser {
00205         public:
00206                 unsigned long player;
00207                 unsigned long fleet;
00208         };
00209 
00210         void AddChaser(const deque<Chaser> &w2);
00211         deque<Chaser> mChasers;
00212 
00213         deque<MineField *> mPossibleMines;
00214 
00215         // true if a player # can load from this (can a ship in the same location steal from it, or is a ship remote mining it)
00216         // set to true or false on the end of movement for thieving capabilities.
00217         deque<bool> mCanLoadBy;
00218 
00219         // Calculated Values
00220         Cost CVCost;
00221         long ReCost;
00222         void ResetDefaults();   // reset all Calculated Values to defaults
00223         long CVScanPen;
00224         long CVScanSpace;
00225         long CVCloaking;
00226         long CVFuelCapacity;
00227         long CVFuelGen;
00228         long CVMass;
00229         long CVMaxMass;
00230         bool CCalcMaxMass;
00231         double CVMaxTachyon;
00232         bool CCalcMaxTachyon;
00233         long CVCargoCapacity;
00234         long CVMines;
00235         long CVSweeping;
00236 
00237         double CVMaxDampener;
00238         bool CCalcMaxDampener;
00239         double CVMaxRepairRate;
00240         bool CCalcMaxRepairRate;
00241         long CVMinSafeSpeed;
00242         long CVMinMaxSpeed;
00243         long CVMinFreeSpeed;
00244         long CVMinBattleSpeed;
00245 
00246         long CVColonize;
00247         long CVStealShip;
00248         long CVStealPlanet;
00249         long CVShoot;
00250         long CVNormalBomb;
00251         long CVSmartBomb;
00252         long CVTerraBomb;
00253         
00254         double CVNormalKillper;
00255         bool CCalcNormalKillper;
00256         //long CVSmartKillper;
00257         long CVMinKill;
00258         long CVInstKill;
00259         long CVJumpGate;
00260 
00261         deque<long> CVTechLevel;
00262         deque<long> CVMineAmount;
00263         deque<long> CVRadiation;
00264 };
00265 
00266 #endif // !defined(Fleet_h)

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