CBattleCallback.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include "../global.h"
  3. #include "IGameCallback.h"
  4. #include "CondSh.h"
  5. class CConnection;
  6. struct CPack;
  7. class DLL_EXPORT IConnectionHandler
  8. {
  9. public:
  10. IConnectionHandler();
  11. ~IConnectionHandler();
  12. CConnection *serv;
  13. CondSh<int> waitingRequest;
  14. };
  15. class DLL_EXPORT IBattleCallback
  16. {
  17. public:
  18. bool waitTillRealize; //if true, request functions will return after they are realized by server
  19. bool unlockGsWhenWaiting;//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!
  20. //battle
  21. virtual int battleMakeAction(BattleAction* action)=0;//for casting spells by hero - DO NOT use it for moving active stack
  22. virtual bool battleMakeTacticAction(BattleAction * action) =0; // performs tactic phase actions
  23. };
  24. class DLL_EXPORT CBattleCallback : public IBattleCallback, public CBattleInfoCallback
  25. {
  26. protected:
  27. void sendRequest(const CPack *request);
  28. IConnectionHandler *connHandler;
  29. //virtual bool hasAccess(int playerId) const;
  30. public:
  31. CBattleCallback(CGameState *GS, int Player, IConnectionHandler *C);
  32. int battleMakeAction(BattleAction* action) OVERRIDE;//for casting spells by hero - DO NOT use it for moving active stack
  33. bool battleMakeTacticAction(BattleAction * action) OVERRIDE; // performs tactic phase actions
  34. friend class CCallback;
  35. friend class CClient;
  36. };