CMapEvent.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * CMapEvent.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 "../ResourceSet.h"
  12. #include "../texts/MetaString.h"
  13. #include "MapDifficulty.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. class JsonSerializeFormat;
  16. /// The map event is an event which e.g. gives or takes resources of a specific
  17. /// amount to/from players and can appear regularly or once a time.
  18. class DLL_LINKAGE CMapEvent
  19. {
  20. public:
  21. CMapEvent();
  22. virtual ~CMapEvent() = default;
  23. bool occursToday(int currentDay) const;
  24. bool affectsDifficulty(EMapDifficulty difficulty) const;
  25. bool affectsPlayer(PlayerColor player, bool isHuman) const;
  26. std::string name;
  27. MetaString message;
  28. TResources resources;
  29. std::set<PlayerColor> players;
  30. MapDifficultySet affectedDifficulties;
  31. bool humanAffected;
  32. bool computerAffected;
  33. ui32 firstOccurrence;
  34. ui32 nextOccurrence; /// specifies after how many days the event will occur the next time; 0 if event occurs only one time
  35. std::vector<ObjectInstanceID> deletedObjectsInstances;
  36. template<typename Handler>
  37. void serialize(Handler & h)
  38. {
  39. h & name;
  40. h & message;
  41. h & resources;
  42. h & players;
  43. if(h.version >= Handler::Version::HOTA_MAP_FORMAT_EXTENSIONS)
  44. h & affectedDifficulties;
  45. h & humanAffected;
  46. h & computerAffected;
  47. h & firstOccurrence;
  48. h & nextOccurrence;
  49. h & deletedObjectsInstances;
  50. }
  51. virtual void serializeJson(JsonSerializeFormat & handler);
  52. };
  53. VCMI_LIB_NAMESPACE_END