Interface.h 2.3 KB

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