BattleFieldHandler.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * BattleFieldHandler.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 <vcmi/EntityService.h>
  12. #include "HeroBonus.h"
  13. #include "GameConstants.h"
  14. #include "IHandlerBase.h"
  15. #include "Terrain.h"
  16. #include "battle/BattleHex.h"
  17. class BattleFieldInfo : public EntityT<BattleField>
  18. {
  19. public:
  20. BattleField battlefield;
  21. std::vector<std::shared_ptr<Bonus>> bonuses;
  22. bool isSpecial;
  23. std::string graphics;
  24. std::string name;
  25. std::string identifier;
  26. std::string icon;
  27. si32 iconIndex;
  28. std::vector<BattleHex> impassableHexes;
  29. BattleFieldInfo()
  30. : BattleFieldInfo(BattleField::NONE, "")
  31. {
  32. }
  33. BattleFieldInfo(BattleField battlefield, std::string identifier)
  34. :bonuses(), isSpecial(false), battlefield(battlefield), identifier(identifier), graphics(), icon(), iconIndex(battlefield.getNum()), impassableHexes(), name(identifier)
  35. {
  36. }
  37. int32_t getIndex() const override;
  38. int32_t getIconIndex() const override;
  39. const std::string & getName() const override;
  40. const std::string & getJsonKey() const override;
  41. void registerIcons(const IconRegistar & cb) const override;
  42. BattleField getId() const override;
  43. template <typename Handler> void serialize(Handler & h, const int version)
  44. {
  45. h & name;
  46. h & identifier;
  47. h & isSpecial;
  48. h & graphics;
  49. h & icon;
  50. h & iconIndex;
  51. h & battlefield;
  52. h & impassableHexes;
  53. }
  54. };
  55. class DLL_LINKAGE BattleFieldService : public EntityServiceT<BattleField, BattleFieldInfo>
  56. {
  57. public:
  58. };
  59. class BattleFieldHandler : public CHandlerBase<BattleField, BattleFieldInfo, BattleFieldInfo, BattleFieldService>
  60. {
  61. public:
  62. virtual BattleFieldInfo * loadFromJson(
  63. const std::string & scope,
  64. const JsonNode & json,
  65. const std::string & identifier,
  66. size_t index) override;
  67. virtual const std::vector<std::string> & getTypeNames() const override;
  68. virtual std::vector<JsonNode> loadLegacyData(size_t dataSize) override;
  69. virtual std::vector<bool> getDefaultAllowed() const override;
  70. template <typename Handler> void serialize(Handler & h, const int version)
  71. {
  72. h & objects;
  73. }
  74. };