BattleFieldHandler.h 2.2 KB

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