CBattleCallback.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. /// if true, request functions will return after they are realized by server
  19. bool waitTillRealize;
  20. /// 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!
  21. bool unlockGsWhenWaiting;
  22. //battle
  23. /// for casting spells by hero - DO NOT use it for moving active stack
  24. virtual int battleMakeAction(BattleAction* action)=0;
  25. /// performs tactic phase actions
  26. virtual bool battleMakeTacticAction(BattleAction * action) =0;
  27. };
  28. class DLL_EXPORT CBattleCallback : public IBattleCallback, public CBattleInfoCallback
  29. {
  30. protected:
  31. void sendRequest(const CPack *request);
  32. IConnectionHandler *connHandler;
  33. //virtual bool hasAccess(int playerId) const;
  34. public:
  35. CBattleCallback(CGameState *GS, int Player, IConnectionHandler *C);
  36. /// for casting spells by hero - DO NOT use it for moving active stack
  37. int battleMakeAction(BattleAction* action) OVERRIDE;
  38. /// performs tactic phase actions
  39. bool battleMakeTacticAction(BattleAction * action) OVERRIDE;
  40. friend class CCallback;
  41. friend class CClient;
  42. };