CCallbackBase.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * CCallbackBase.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "GameConstants.h"
  12. class CGameState;
  13. struct BattleInfo;
  14. class CBattleInfoEssentials;
  15. //Basic class for various callbacks (interfaces called by players to get info about game and so forth)
  16. class DLL_LINKAGE CCallbackBase
  17. {
  18. const BattleInfo *battle; //battle to which the player is engaged, nullptr if none or not applicable
  19. const BattleInfo * getBattle() const;
  20. protected:
  21. CGameState *gs;
  22. boost::optional<PlayerColor> player; // not set gives access to all information, otherwise callback provides only information "visible" for player
  23. CCallbackBase(CGameState *GS, boost::optional<PlayerColor> Player);
  24. CCallbackBase();
  25. void setBattle(const BattleInfo *B);
  26. bool duringBattle() const;
  27. public:
  28. boost::optional<PlayerColor> getPlayerID() const;
  29. friend class CBattleInfoEssentials;
  30. };