CGPandoraBox.h 2.6 KB

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