Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

game.h

00001 // $Id: game_8h-source.html,v 1.2 2002/06/20 17:09:51 mkrohn5 Exp $
00002 
00003 // Game Header File
00004 // Written by: Alberto Barsella, <>
00005 //             Marco Krohn, <marco.krohn@gmx.de>
00006 
00007 // Copyright (C) 2001 - 2002, Marco Krohn, <marco.krohn@gmx.de>
00008 //
00009 // This program is free software; you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation; either version 1, or (at your option)
00012 // any later version.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 
00019 #ifndef __GAME_INCLUDED
00020 #define __GAME_INCLUDED
00021 
00022 #include "common/defs.h"
00023 #include "common/link.h"
00024 #include "common/plist.h"
00025 #include "gamelogic/action.h"
00026 
00027 class TDataPackageList;
00028 class TRuleSystem;
00029 class TPlayer;
00030 class TRace;
00031 
00032 
00033 
00034 
00035 
00036 //----------------------------------------  class TGame  ----------------------------------------
00037 
00048 class TGame
00049 {
00053   friend int yyparse();
00054 
00055   public:
00061     void addPlayer( TPlayer* player );
00067     void addRace( TRace* race );
00071     const string& getGameDirectory() const;
00075     const string& getGameName() const;
00079     const list<TPlayer*>& getPlayers() const;
00083     const list<TRace*>& getRaces() const;
00087     int4 getTurn() const;
00092     virtual void resetAll();
00097     bool saveServerMasterFile() const;
00102     void setGameName( const string& name );
00107     void setTurn( int4 turn );
00108 
00109   protected:
00113     typedef void (TGame::*tPDBFunc)(TDataPackageList* block);
00114     /* used by ProcessDataBlock DFA to parse the file */
00115     struct tTransition {
00116       tTransition( const string& s, int i1, int i2, tPDBFunc func )  {
00117         BlockType=s;
00118         CurrLevel=i1;
00119         NewLevel=i2;
00120         Function = func;
00121       }
00122       string BlockType;
00123       int CurrLevel;
00124       int NewLevel;
00125       tPDBFunc Function;
00126     };
00131     list<tTransition> fTransitions;
00135     TLink<TRace> fIluvatar;
00136 
00143     TGame( const string& gameDir, const string& gameName="" );
00147     virtual ~TGame();
00148 
00153     string FNamePlayerData(const string& PlayerName) const;
00158     string FNamePlayerOrder(const string& PlayerName) const;
00162     string FNameServerMaster() const;
00166     string FNameUniverseDefinition() const;
00167     /*
00168     * @param playerName The name of the player.
00169     * @return the complete path (gamedirectory + filename) to
00170     *   the player data file.
00171     */
00172     string FSpecPlayerData( const string& playerName ) const;
00173     /*
00174     * @param playerName The name of the player.
00175     * @return the complete path (gamedirectory + filename) to
00176     *   the player order file.
00177     */
00178     string FSpecPlayerOrder( const string& playerName ) const;
00183     string FSpecServerMaster() const;
00188     string FSpecUniverseDefinition() const;
00194     string getBlockType( TDataPackageList* list ) const;
00199     virtual void PDBAction( TDataPackageList* )  {};
00204     virtual void PDBFleet( TDataPackageList* )  {};
00209     virtual void PDBGalaxy( TDataPackageList* )  {};
00214     virtual void PDBGame( TDataPackageList* )  {} ;
00218     void PDBItem( TDataPackageList* block );
00223     virtual void PDBLoadOrders( TDataPackageList* )  {};
00227     void PDBPlayer( TDataPackageList* block );
00231     void PDBRace( TDataPackageList* block );
00235     void PDBRuleSystem( TDataPackageList* block );
00240     virtual void PDBSystem( TDataPackageList* )  {};
00248     void processDataBlock( TDataPackageList* block );
00252     void resetLoadLevel();
00253 
00254   private:
00260     int2 fLoadLevel;
00265     string fGameDirectory;
00269     string fGameName;
00273     int4 fCurrentTurn;
00278     TPList<TRace> fRaces;
00284     TPList<TPlayer> fPlayers;
00285 };
00286 
00287 
00288 
00289 
00290 
00291 #endif        // __GAME_INCLUDED

Generated on Thu Jun 20 18:13:15 2002 for Stellar Legacy by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001