BattleFieldHandler.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 "bonuses/Bonus.h"
  14. #include "GameConstants.h"
  15. #include "IHandlerBase.h"
  16. #include "battle/BattleHexArray.h"
  17. #include "filesystem/ResourcePath.h"
  18. VCMI_LIB_NAMESPACE_BEGIN
  19. class DLL_LINKAGE BattleFieldInfo : public EntityT<BattleField>
  20. {
  21. public:
  22. BattleField battlefield;
  23. std::vector<std::shared_ptr<Bonus>> bonuses;
  24. bool isSpecial;
  25. std::vector<MapLayerId> limitToLayers;
  26. ImagePath graphics;
  27. std::string name;
  28. std::string modScope;
  29. std::string identifier;
  30. std::string icon;
  31. si32 iconIndex;
  32. BattleHexArray impassableHexes;
  33. AudioPath openingSoundFilename;
  34. AudioPath musicFilename;
  35. BattleFieldInfo()
  36. : BattleFieldInfo(BattleField::NONE, "")
  37. {
  38. }
  39. BattleFieldInfo(BattleField battlefield, std::string identifier):
  40. isSpecial(false),
  41. battlefield(battlefield),
  42. identifier(identifier),
  43. iconIndex(battlefield.getNum()),
  44. name(identifier)
  45. {
  46. }
  47. int32_t getIndex() const override;
  48. int32_t getIconIndex() const override;
  49. std::string getJsonKey() const override;
  50. std::string getModScope() const override;
  51. std::string getNameTextID() const override;
  52. std::string getNameTranslated() const override;
  53. void registerIcons(const IconRegistar & cb) const override;
  54. BattleField getId() const override;
  55. };
  56. class DLL_LINKAGE BattleFieldService : public EntityServiceT<BattleField, BattleFieldInfo>
  57. {
  58. public:
  59. };
  60. class BattleFieldHandler : public CHandlerBase<BattleField, BattleFieldInfo, BattleFieldInfo, BattleFieldService>
  61. {
  62. public:
  63. std::shared_ptr<BattleFieldInfo> loadFromJson(
  64. const std::string & scope,
  65. const JsonNode & json,
  66. const std::string & identifier,
  67. size_t index) override;
  68. const std::vector<std::string> & getTypeNames() const override;
  69. std::vector<JsonNode> loadLegacyData() override;
  70. static BattleField selectRandomBattlefield(const std::vector<BattleField> & battleFields, MapLayerId currentLayer, vstd::RNG & randomGenerator);
  71. };
  72. VCMI_LIB_NAMESPACE_END