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

Planet.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(Planet_h)
00031 #define Planet_h
00032 
00033 #include <string>
00034 #include <deque>
00035 using namespace std;
00036 
00037 class Ship;
00038 class Message;
00039 class Creation;
00040 class ProductionOrder;
00041 #include "Player.h"
00042 #include "Rules.h"
00043 
00044 #include "CargoHolder.h"
00045 #include "Invasion.h"
00046 //#include "ProdOrder.h"
00047 class ProdOrder;
00048 
00053 class Planet : public CargoHolder {
00054 public:
00055         Planet();
00056 //      Planet(int x, int y);
00057         virtual ~Planet();
00058         virtual bool ParseNode(const TiXmlNode * node);
00059         virtual TiXmlNode * WriteNode(TiXmlNode * node, const Player * viewer) const;
00060         void Init();
00061         void SetDestinations();
00062 
00063         void AddScrapRes(int amount)    { mScrapRes += amount; }
00064         long GetBaseNumber() const              { return mBaseDesign; }
00065         void SetBaseNumber(long n);
00066         const Ship * GetBaseDesign() const      { return GetOwner()->GetBaseDesign(mBaseDesign); }
00067         long GetBaseDamage() const              { return mBaseDamage; }
00068         void SetBaseDamage(long bd)             { mBaseDamage = bd; }
00069         virtual const string GetName(const Player *) const      { return mName; }
00070         const string GetName() const    { return mName; }
00071         static const string SGetName(Planet * p)        { return p->GetName(); }
00072         static const string SGetName(const Planet * p)  { return p->GetName(); }
00073         long GetResources() const;
00074         virtual long GetCargoCapacity() const           { return -1; }
00075         void Invade(Player * invader, long amount);
00076         void ResolveInvasion();
00077         void TakePlanet(Player * invader, long amount);
00078         void DeadCheck();
00079         void Kill();
00080 
00081         void AdjustDefenses(long amount);
00082         void AdjustFactories(long amount);
00083         void AdjustMines(long amount);
00084         virtual long GetCloak(const Player *, bool) const       { return 0; }
00085         virtual double GetMaxTachyon() const;
00086         virtual long GetScanPen() const;
00087         virtual long GetScanSpace() const;
00088         const Planet * GetRoute() const         { return mRouteTo; }
00089         Planet * GetPacketDest()                        { return mPacketDest; }
00090         const Planet * GetPacketDest() const      { return mPacketDest; }
00091         int GetPacketSpeed() const                              { return mPacketSpeed; }
00092         friend bool operator==(const Planet & p1, const Planet & p2)    { return p1.mName == p2.mName; }
00093         friend bool operator!=(const Planet & p1, const Planet & p2)    { return p1.mName != p2.mName; }
00094         double GetDefenseValue() const;
00095         double GetSmartDefenseValue() const;
00096         double GetInstallationDefenseValue() const      { return GetDefenseValue() / 2; }
00097         double GetDisplayDef() const;
00098         long GetDisplayPop() const;
00099         long GetMaxPop() const;
00100         void Mine();
00101         void Mine(long mines, const Player * miner);
00102         void DoProduction();
00103         long PopGrowth() const;
00104         void BuildFactories(long number)        { mFactories += number; mBuiltFactories += number; }
00105         void BuildMines(long number)            { mMines += number; mBuiltMines += number; }
00106         void BuildDefenses(long number)         { mDefenses += number; mBuiltDefenses += number; }
00107         void BuildAlchemy(long number)          { mBuiltAlchemy += number; }
00108         void BuildScanner()                                     { mScanner = true; }
00109         long GetFactories() const                       { return mFactories; }
00110         long GetMines() const                           { return mMines; }
00111         long GetDefenses() const                        { return mDefenses; }
00112         bool GetScanner() const                         { return mScanner; }
00113         long GetMinConc(long type) const                { return type < 0 || type >= Rules::MaxMinType ? 0 : mMinConc[type]; }
00114         long GetMineProgress(long type) const   { return type < 0 || type >= Rules::MaxMinType ? 0 : mMinMined[type]; }
00115         Message* AddMessageOwner(string type) {return NCGetOwner()->AddMessage(type);}; // Add a message to owner of planet
00116         long MaxFactories() const;
00117         long MaxMines() const;
00118         long MaxDefenses() const;
00119         long CanTerraform(const Component * comp) const;
00120         long CanTerraform(HabType ht, long max) const;
00121 
00122         virtual void SetCanLoadBy(const Player * player)        { mCanLoadBy[player->GetID()-1] = true; }
00123         virtual bool CanLoadBy(const Player * player) const     { return mCanLoadBy[player->GetID()-1]; }
00124         long GetHabValue(HabType ht) const      { return mHabTerra[ht]; }
00125         bool Terraform(const Player * player, bool positive);           // Terraforms a world 1 tick, and returns true if any change was made
00126 
00127         Cost GetPacketCost(long type) const;
00128         virtual void ResetSeen();
00129 
00130         void CreateRandom(Creation * c);
00131         void CreateHW(const Player * player);
00132         void AdjustHW(Player * player);
00133         void CreateSecondWorld(const Planet * HW);
00134         void AdjustSecondWorld(Player * player);
00135         void ParseProduction(const TiXmlNode * node);
00136         void SetProduction(const deque<ProdOrder *> & ords);
00137         void SetPayTax(bool paytax);
00138         void SetInBattle()      { mHadBattle = true; }
00139         void RepairBase();
00140         void Instaform();
00141         void RemoteTerraform(Fleet * fleet, bool bomb);
00142 
00143         void SetPacketSpeed(int speed);
00144         void SetPacketDest(Planet * pdest);
00145         void SetRoute(const Planet * rdest);
00146 
00147         friend bool operator ==(const Planet &a, const char * b)        { return a.mName == b; }
00148         friend bool operator !=(const Planet &a, const char * b)        { return !(a == b); }
00149 
00150 private:
00151         void DeleteProdQ();
00152         void CopyProdQ(const deque<ProdOrder *> &prod);
00153         string mName;
00154         long mScrapRes;
00155         long mBaseDesign;
00156         long mFactories;
00157         long mMines;
00158         deque<long> mMinConc;
00159         deque<long>     mMinMined;      // amount of mines on this concentration
00160         bool mScanner;
00161         long mDefenses;
00162         const Planet * mRouteTo;
00163         Planet * mPacketDest;
00164         string mRouteName;      // temp till we read in all planets;
00165         string mPacketName;     // temp till we read in all planets;
00166         long mPacketSpeed;
00167         long mBaseDamage;
00168         deque<ProdOrder *> mProductionQ;
00169         deque<Invasion> mInvasions;
00170         deque<long> mHabTerra;
00171         deque<long> mHabStart;
00172         long mArtifactType;
00173         long mArtifactAmount;
00174         bool mPayTax;
00175         bool mHomeWorld;
00176         long mBuiltFactories;
00177         long mBuiltMines;
00178         long mBuiltDefenses;
00179         long mBuiltAlchemy;
00180         long mDisplayPop;
00181         bool mHadBattle;
00182 
00183         // 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)
00184         // set to true or false on the end of movement for thieving capabilities. Set to true when mining planets for remote miners
00185         deque<bool> mCanLoadBy;
00186 
00187         friend class ProdOrder;
00188 };
00189 
00190 const TechType ARTI_NONE                = -1;
00191 const TechType ARTI_ALL                 = -2;   // give amount to all fields
00192 const TechType ARTI_RANDTYPE    = -3;   // give all to a random field
00193 const TechType ARTI_RANDSPLIT   = -4;   // divide amount into Rules::MaxTechType * 2 parts and assign them randomly
00194 
00195 #endif // !defined(Planet_h)

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