BattleChanges.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * BattleChanges.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 "JsonNode.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class BattleChanges
  14. {
  15. public:
  16. enum class EOperation : si8
  17. {
  18. ADD,
  19. RESET_STATE,
  20. UPDATE,
  21. REMOVE,
  22. };
  23. JsonNode data;
  24. EOperation operation = EOperation::RESET_STATE;
  25. BattleChanges() = default;
  26. explicit BattleChanges(EOperation operation_)
  27. : operation(operation_)
  28. {
  29. }
  30. };
  31. class UnitChanges : public BattleChanges
  32. {
  33. public:
  34. uint32_t id = 0;
  35. int64_t healthDelta = 0;
  36. UnitChanges() = default;
  37. UnitChanges(uint32_t id_, EOperation operation_)
  38. : BattleChanges(operation_)
  39. , id(id_)
  40. {
  41. }
  42. template <typename Handler> void serialize(Handler & h, const int version)
  43. {
  44. h & id;
  45. h & healthDelta;
  46. h & data;
  47. h & operation;
  48. }
  49. };
  50. class ObstacleChanges : public BattleChanges
  51. {
  52. public:
  53. uint32_t id = 0;
  54. ObstacleChanges() = default;
  55. ObstacleChanges(uint32_t id_, EOperation operation_)
  56. : BattleChanges(operation_),
  57. id(id_)
  58. {
  59. }
  60. template <typename Handler> void serialize(Handler & h, const int version)
  61. {
  62. h & id;
  63. h & data;
  64. h & operation;
  65. }
  66. };
  67. VCMI_LIB_NAMESPACE_END