CGPandoraBox.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #include "CObjectHandler.h"
  3. #include "CArmedInstance.h"
  4. #include "../ResourceSet.h"
  5. /*
  6. * CGPandoraBox.h, part of VCMI engine
  7. *
  8. * Authors: listed in file AUTHORS in main folder
  9. *
  10. * License: GNU General Public License v2.0 or later
  11. * Full text of license available in license.txt file, in main folder
  12. *
  13. */
  14. struct InfoWindow;
  15. class DLL_LINKAGE CGPandoraBox : public CArmedInstance
  16. {
  17. public:
  18. std::string message;
  19. bool hasGuardians; //helper - after battle even though we have no stacks, allows us to know that there was battle
  20. //gained things:
  21. ui32 gainedExp;
  22. si32 manaDiff; //amount of gained / lost mana
  23. si32 moraleDiff; //morale modifier
  24. si32 luckDiff; //luck modifier
  25. TResources resources;//gained / lost resources
  26. std::vector<si32> primskills;//gained / lost prim skills
  27. std::vector<SecondarySkill> abilities; //gained abilities
  28. std::vector<si32> abilityLevels; //levels of gained abilities
  29. std::vector<ArtifactID> artifacts; //gained artifacts
  30. std::vector<SpellID> spells; //gained spells
  31. CCreatureSet creatures; //gained creatures
  32. void initObj() override;
  33. void onHeroVisit(const CGHeroInstance * h) const override;
  34. void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
  35. void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
  36. void heroLevelUpDone(const CGHeroInstance *hero) const override;
  37. template <typename Handler> void serialize(Handler &h, const int version)
  38. {
  39. h & static_cast<CArmedInstance&>(*this);
  40. h & message & hasGuardians & gainedExp & manaDiff & moraleDiff & luckDiff & resources & primskills
  41. & abilities & abilityLevels & artifacts & spells & creatures;
  42. }
  43. protected:
  44. void giveContentsUpToExp(const CGHeroInstance *h) const;
  45. void giveContentsAfterExp(const CGHeroInstance *h) const;
  46. private:
  47. void getText( InfoWindow &iw, bool &afterBattle, int val, int negative, int positive, const CGHeroInstance * h ) const;
  48. void getText( InfoWindow &iw, bool &afterBattle, int text, const CGHeroInstance * h ) const;
  49. };
  50. class DLL_LINKAGE CGEvent : public CGPandoraBox //event objects
  51. {
  52. public:
  53. bool removeAfterVisit; //true if event is removed after occurring
  54. ui8 availableFor; //players whom this event is available for
  55. bool computerActivate; //true if computer player can activate this event
  56. bool humanActivate; //true if human player can activate this event
  57. template <typename Handler> void serialize(Handler &h, const int version)
  58. {
  59. h & static_cast<CGPandoraBox &>(*this);
  60. h & removeAfterVisit & availableFor & computerActivate & humanActivate;
  61. }
  62. void onHeroVisit(const CGHeroInstance * h) const override;
  63. private:
  64. void activated(const CGHeroInstance * h) const;
  65. };