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(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
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;
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
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;
00160 bool CanNormalBomb() const;
00161 bool CanSmartBomb() const;
00162 bool CanTerraBomb() const;
00163 bool CanJumpGate() const;
00164 bool CanBomb() const{return CanNormalBomb() || CanSmartBomb() || CanTerraBomb();}
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
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;
00185 long mRepairRate;
00186 long mBattlePlan;
00187 bool mAlreadyFought;
00188 bool mInBattle;
00189 bool mHasMoved;
00190 long mDistMoved;
00191 Location mStartPos;
00192 double mPX;
00193 double mPY;
00194 bool mDoneWaypoint;
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
00216
00217 deque<bool> mCanLoadBy;
00218
00219
00220 Cost CVCost;
00221 long ReCost;
00222 void ResetDefaults();
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
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)