Interface.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Interface.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 "../spells/ExternalCaster.h"
  12. #include "Configuration.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. class IObjectInterface;
  15. class IGameEventCallback;
  16. class CArmedInstance;
  17. namespace Rewardable
  18. {
  19. class DLL_LINKAGE Interface
  20. {
  21. private:
  22. /// caster to cast adveture spells, no serialize
  23. mutable spells::ExternalCaster caster;
  24. protected:
  25. /// function that must be called if hero got level-up during grantReward call
  26. void grantRewardAfterLevelup(IGameEventCallback & gameEvents, const Rewardable::VisitInfo & reward, const CArmedInstance * army, const CGHeroInstance * hero) const;
  27. /// grants reward to hero
  28. void grantRewardBeforeLevelup(IGameEventCallback & gameEvents, const Rewardable::VisitInfo & reward, const CGHeroInstance * hero) const;
  29. virtual void grantRewardWithMessage(IGameEventCallback & gameEvents, const CGHeroInstance * contextHero, int rewardIndex, bool markAsVisit) const;
  30. void selectRewardWithMessage(IGameEventCallback & gameEvents, const CGHeroInstance * contextHero, const std::vector<ui32> & rewardIndices, const MetaString & dialog) const;
  31. void grantAllRewardsWithMessage(IGameEventCallback & gameEvents, const CGHeroInstance * contextHero, const std::vector<ui32>& rewardIndices, bool markAsVisit) const;
  32. std::vector<Component> loadComponents(const CGHeroInstance * contextHero, const std::vector<ui32> & rewardIndices) const;
  33. void doHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance *h) const;
  34. virtual const IObjectInterface * getObject() const = 0;
  35. virtual bool wasVisitedBefore(const CGHeroInstance * hero) const = 0;
  36. virtual bool wasVisited(PlayerColor player) const = 0;
  37. virtual void markAsVisited(IGameEventCallback & gameEvents, const CGHeroInstance * hero) const = 0;
  38. virtual void markAsScouted(IGameEventCallback & gameEvents, const CGHeroInstance * hero) const = 0;
  39. virtual void grantReward(IGameEventCallback & gameEvents, ui32 rewardID, const CGHeroInstance * hero) const = 0;
  40. void onBlockingDialogAnswered(IGameEventCallback & gameEvents, const CGHeroInstance * hero, int32_t answer) const;
  41. public:
  42. /// filters list of visit info and returns rewards that can be granted to current hero
  43. std::vector<ui32> getAvailableRewards(const CGHeroInstance * hero, Rewardable::EEventType event) const;
  44. Rewardable::Configuration configuration;
  45. void serializeJson(JsonSerializeFormat & handler);
  46. template <typename Handler> void serialize(Handler &h)
  47. {
  48. h & configuration;
  49. }
  50. };
  51. }
  52. VCMI_LIB_NAMESPACE_END