2011-09-29 21:29:54 +00:00
# pragma once
# include "../global.h"
# include "IGameCallback.h"
# include "CondSh.h"
class CConnection ;
2011-10-01 15:07:07 +00:00
struct CPack ;
2011-09-29 21:29:54 +00:00
class DLL_EXPORT IConnectionHandler
{
public :
IConnectionHandler ( ) ;
~ IConnectionHandler ( ) ;
CConnection * serv ;
CondSh < int > waitingRequest ;
} ;
class DLL_EXPORT IBattleCallback
{
public :
2011-12-03 23:40:56 +00:00
/// if true, request functions will return after they are realized by server
bool waitTillRealize ;
/// if true after sending each request, gs mutex will be unlocked so the changes can be applied; NOTICE caller must have gs mx locked prior to any call to actiob callback!
bool unlockGsWhenWaiting ;
2011-09-29 21:29:54 +00:00
//battle
2011-12-03 23:40:56 +00:00
/// for casting spells by hero - DO NOT use it for moving active stack
virtual int battleMakeAction ( BattleAction * action ) = 0 ;
/// performs tactic phase actions
virtual bool battleMakeTacticAction ( BattleAction * action ) = 0 ;
2011-09-29 21:29:54 +00:00
} ;
class DLL_EXPORT CBattleCallback : public IBattleCallback , public CBattleInfoCallback
{
protected :
void sendRequest ( const CPack * request ) ;
IConnectionHandler * connHandler ;
//virtual bool hasAccess(int playerId) const;
public :
CBattleCallback ( CGameState * GS , int Player , IConnectionHandler * C ) ;
2011-12-03 23:40:56 +00:00
/// for casting spells by hero - DO NOT use it for moving active stack
int battleMakeAction ( BattleAction * action ) OVERRIDE ;
/// performs tactic phase actions
bool battleMakeTacticAction ( BattleAction * action ) OVERRIDE ;
2011-09-29 21:29:54 +00:00
friend class CCallback ;
friend class CClient ;
} ;