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

Game.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(Game_h)
00031 #define Game_h
00032 
00033 class TiXmlNode;
00034 class RacialTrait;
00035 class Creation;
00036 class MineField;
00037 
00038 #include "WayOrderList.h"
00039 
00040 #include "Component.h"
00041 #include "Player.h"
00042 
00046 class Game {
00047 public:
00048         Game();
00049         virtual ~Game();
00050         double GetTechFactor() const    { return TechFactor; }
00051         long GetTurnPhase() const       { return TurnPhase; }
00052         long GetTurn() const            { return Turn; }
00053         bool LoadDefFile(const char * deffile);
00054         void PlacePlayers();
00055         void SetFileLocation(const char * hostfile);
00056         bool LoadHostFile(const char * hostfile);
00057         bool LoadPlayerFile(const char * playerfile);
00058         bool LoadXYFile();
00059         bool LoadRules(const char * file, const char * verify, double version, bool checkver);
00060         bool LoadRacialTraits(const TiXmlNode * node);
00061         bool LoadComponents(const TiXmlNode * node);
00062         bool LoadCreation(const TiXmlNode * options);
00063         bool LoadStartShips(const TiXmlNode * node);
00064 //      bool LoadOptions();
00065 //      bool LoadPlayer(const char * file);
00066         bool LoadTurns();
00067         bool ProcessOrders(long pnumber);
00068         bool ProcessWaypoints(long pnumber);
00069         bool AssignWaypoints();
00070 
00071         Player * GetCurrentPlayer()             { return NCGetPlayer(mCurrentPlayer); }
00072         Player * NCGetPlayer(unsigned int n);
00073         const Player * GetPlayer(unsigned int n) const  { return const_cast<Game *>(this)->NCGetPlayer(n); }    // Same thing just const
00074         unsigned int NumberPlayers()    { return mNumberOfPlayers; }
00075         const RacialTrait * ParsePRT(const char * str) const;
00076         const RacialTrait * ParseLRT(const char * str) const;
00077         bool ProcessTurn();
00078         void WriteXYFile();
00079         bool WriteHostFile();
00080         bool WritePlayerFiles();
00081         long GetRandomEvents() const    { return mRandomEvents; }
00082 
00083         Message * AddMessage(string type);
00084         void StoreMessageLocation(const Location * loc);
00085 
00086         const Component * ParseComponent(const char * name) const;
00087         const Component * GetBestComp(const Player * player, const char * ValueType, bool CheckRad) const;
00088         const Component * GetBestComp(const Player * player, long vt, bool CheckRad) const;
00089         const deque<Message *>& GetMessages() {return mMessages;}
00090         
00091 //      enum FileLocation {
00092 //              AnyLocation = 1,
00093 //              GameDirOnly = 2,
00094 //              GameNameOnly = 3,
00095 //      };
00096 //      string GetFile(const char * file, FileLocation fLoc = AnyLocation);
00097         string GetFileLoc() const               { return mFileLoc; }
00098         string GetFileName() const              { return mFileName; }
00099         const deque<Component *> & GetComponents() const { return mComponents; }
00100 
00101         long GetTerraLimit(const Player * player, HabType ht);
00102 
00103         Creation * GetCreation()        { return mCreation; }
00104 
00105         long GetGameID() const          { return mGameID; }
00106         static bool Game::CheckMetaInfo(const TiXmlNode * node, const char * file, double fileversion);
00107 
00108         double ClosestMinefield(deque<MineField *> *pm, const Location * loc, long dist);
00109         double ClosestMinefield(deque<MineField *> *pm, const Location * loc, double px, double py, deque<MineField *> *inmine = NULL);
00110         deque<CargoHolder *> * GetClosestTop(int x, int y, long max = 0);
00111         void AddAlsoHere(CargoHolder * loc);
00112         void MoveAlsoHere(CargoHolder * loc);
00113         void RemoveAlsoHere(CargoHolder * loc);
00114 
00115         void InitialSeen();
00116         void UpdateSeen();
00117         void ResetSeen();
00118         void UpdateLoadBy();
00119         long MinWormholes() const       { return mWHMin; }
00120         long MaxWormholes() const       { return mWHMax; }
00121         long GetWHMinDistance() const   { return mWHMinDistance; }
00122 
00123 protected:
00124         long mCurrentPlayer;    // current player for client display
00125         long mGameID;
00126         double TechFactor;              // 1.0 for normal games, 2.0 for slow tech games
00127         long TurnPhase;
00128         long Turn;
00129         string Name;
00130         string mFileLoc;
00131         string mFileName;
00132 //      string GameDir;
00133         unsigned long mRandomEvents;
00134         long RandomEventsStart;         // random events wait to start (all at once - execpt artifacts, they're either on or off)
00135         long mWHMin;
00136         long mWHMax;
00137         long mWHMinDistance;
00138         unsigned long PublicScore;
00139         long PublicScoreStart;          // rank score is either on or off, others wait for a start time
00140         unsigned int mNumberOfPlayers;
00141 
00142         deque<Component *> mComponents;
00143         deque<Player *> mPlayers;
00144         deque<RacialTrait *> mPRTs;
00145         deque<RacialTrait *> mLRTs;
00146 
00147         deque<WayOrderList> mOrders;
00148         deque<Message *> mMessages;
00149         deque<deque<CargoHolder *> *> mTopObjects;
00150 
00151         Creation * mCreation;
00152 
00153         // VictoryConditions
00154         long VCWorlds;
00155         long VCTechLevel;
00156         long VCTechCount;
00157         long VCScore;
00158         double VCTimes2nd;
00159         long VCResources;
00160         long VCCapShips;
00161         long VCHighScoreAt;
00162         long VCCount;
00163         long VCStart;
00164 
00165 };
00166 
00167 extern Game * TheGame;
00168 
00169 // turn phases
00170 const long TP_PARSEWAYPOINTS    =  10;
00171 const long TP_SCRAPFLEET                =  20;
00172 const long TP_WAY0_UNLOAD               =  30;
00173 const long TP_WAY0_COLONIZE             =  40;
00174 const long TP_WAY0_INVADE               =  50;
00175 const long TP_WAY0_LOAD                 =  60;
00176 const long TP_TECH_CHECK1               =  70;
00177 const long TP_MT_MOVE                   =  80;
00178 const long TP_PACKETS1                  =  90;
00179 const long TP_DEADCHECK1                =  95;
00180 const long TP_MOVEMENT                  = 100;
00181 const long TP_MOVEMENT_CYCLE    = 110;
00182 const long TP_FREIGHTER_GROW    = 120;
00183 const long TP_SALVAGEDECAY              = 140;
00184 const long TP_WORMHOLES                 = 150;
00185 const long TP_MINES_DETONATE    = 160;
00186 const long TP_MINING                    = 171;
00187 const long TP_PRODUCTION                = 182;
00188 const long TP_SPYBONUS                  = 190;
00189 const long TP_TECH_CHECK2               = 200;
00190 const long TP_POPULATION                = 210;
00191 const long TP_INSTA_PACKETS             = 220;
00192 const long TP_DEADCHECK2                = 225;
00193 const long TP_RANDOM_EVENTS             = 230;
00194 const long TP_BATTLES                   = 240;
00195 const long TP_REMOTE_MINE               = 250;
00196 const long TP_MEET_MT                   = 260;
00197 const long TP_BOMBING                   = 270;
00198 const long TP_REPAIR                    = 280;
00199 const long TP_WAY1_UNLOAD               = 290;
00200 const long TP_WAY1_COLONIZE             = 300;
00201 const long TP_WAY1_INVADE               = 310;
00202 const long TP_WAY1_LOAD                 = 320;
00203 const long TP_TECH_CHECK3               = 330;
00204 const long TP_DEADCHECK3                = 335;
00205 const long TP_MINELAYING                = 340;
00206 const long TP_TRANSFER                  = 350;
00207 const long TP_MERGE                             = 360;
00208 const long TP_INSTA_TERRAFORM   = 370;
00209 const long TP_MINEDECAY                 = 380;
00210 const long TP_MINESWEEP                 = 390;
00211 const long TP_REMOTE_TERRAFORM  = 400;
00212 const long TP_PATROL                    = 410;
00213 
00214 #endif // !defined(Game_h)

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