CMapEvent.h 1.3 KB

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