2007-07-28 15:23:15 +00:00
# ifndef CGAMESTATE_H
# define CGAMESTATE_H
2007-10-16 17:46:01 +00:00
# include "mapHandler.h"
2007-11-24 14:17:57 +00:00
# include <set>
2007-11-18 22:58:28 +00:00
class CScriptCallback ;
2007-08-27 14:15:03 +00:00
class CCallback ;
2007-11-18 22:58:28 +00:00
class CLuaCallback ;
2007-11-24 14:17:57 +00:00
class CCPPObjectScript ;
2007-07-28 15:23:15 +00:00
struct PlayerState
{
2007-08-04 19:01:22 +00:00
public :
2007-11-18 22:58:28 +00:00
int color , serial ;
2007-10-16 17:46:01 +00:00
//std::vector<std::vector<std::vector<char> > > fogOfWarMap; //true - visible, false - hidden
PseudoV < PseudoV < PseudoV < unsigned char > > > fogOfWarMap ; //true - visible, false - hidden
2007-07-28 15:23:15 +00:00
std : : vector < int > resources ;
2007-10-27 19:38:48 +00:00
std : : vector < CGHeroInstance * > heroes ;
std : : vector < CGTownInstance * > towns ;
2007-09-18 13:30:26 +00:00
PlayerState ( ) : color ( - 1 ) { } ;
2007-07-28 23:01:25 +00:00
} ;
2007-07-28 15:23:15 +00:00
class CGameState
{
2007-11-18 22:58:28 +00:00
private :
2007-08-04 19:01:22 +00:00
int currentPlayer ;
2007-09-18 13:30:26 +00:00
int day ; //total number of days in game
2007-07-28 23:01:25 +00:00
std : : map < int , PlayerState > players ; //color <-> playerstate
2007-11-24 14:17:57 +00:00
std : : set < CCPPObjectScript * > cppscripts ;
std : : map < int , std : : map < std : : string , CObjectScript * > > objscr ; //custom user scripts (as for now only Lua)
2007-11-18 22:58:28 +00:00
bool checkFunc ( int obid , std : : string name )
{
if ( objscr . find ( obid ) ! = objscr . end ( ) )
{
if ( objscr [ obid ] . find ( name ) ! = objscr [ obid ] . end ( ) )
{
return true ;
}
}
return false ;
}
CGHeroInstance * getHero ( int ID , int mode )
{
if ( mode ! = 0 )
throw new std : : exception ( " gs->getHero: This mode is not supported! " ) ;
for ( std : : map < int , PlayerState > : : iterator i = players . begin ( ) ; i ! = players . end ( ) ; i + + )
{
for ( int j = 0 ; j < ( * i ) . second . heroes . size ( ) ; j + + )
{
if ( i - > second . heroes [ j ] - > subID = = ID )
return i - > second . heroes [ j ] ;
}
}
return NULL ;
}
2007-08-27 14:15:03 +00:00
public :
friend CCallback ;
2007-11-18 22:58:28 +00:00
friend CLuaCallback ;
2007-08-27 14:15:03 +00:00
friend int _tmain ( int argc , _TCHAR * argv [ ] ) ;
2007-09-14 13:11:10 +00:00
friend void initGameState ( CGameInfo * cgi ) ;
2007-11-18 22:58:28 +00:00
friend CScriptCallback ;
2007-11-24 14:17:57 +00:00
friend void handleCPPObjS ( std : : map < int , CCPPObjectScript * > * mapa , CCPPObjectScript * script ) ;
2007-09-30 16:16:00 +00:00
//CCallback * cb; //for communication between PlayerInterface/AI and GameState
2007-10-27 20:14:25 +00:00
2008-01-08 13:31:44 +00:00
friend SDL_Surface * CMapHandler : : terrainRect ( int x , int y , int dx , int dy , int level , unsigned char anim , PseudoV < PseudoV < PseudoV < unsigned char > > > & visibilityMap , bool otherHeroAnim , unsigned char heroAnim ) ; //todo: wywalic koniecznie, tylko do flag obecnie!!!!
2007-07-28 23:01:25 +00:00
} ;
2007-07-28 15:23:15 +00:00
2007-09-14 13:11:10 +00:00
# endif //CGAMESTATE_H