Obstacle.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Obstacle.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 "LocationEffect.h"
  12. #include "../../battle/BattleHex.h"
  13. #include "../../battle/CObstacleInstance.h"
  14. namespace spells
  15. {
  16. namespace effects
  17. {
  18. class ObstacleSideOptions
  19. {
  20. public:
  21. using RelativeShape = std::vector<std::vector<BattleHex::EDir>>;
  22. RelativeShape shape; //shape of single obstacle relative to obstacle position
  23. RelativeShape range; //position of obstacles relative to effect destination
  24. std::string appearAnimation;
  25. std::string animation;
  26. int offsetY;
  27. ObstacleSideOptions();
  28. void serializeJson(JsonSerializeFormat & handler);
  29. private:
  30. void serializeRelativeShape(JsonSerializeFormat & handler, const std::string & fieldName, RelativeShape & value);
  31. };
  32. class Obstacle : public LocationEffect
  33. {
  34. public:
  35. Obstacle();
  36. virtual ~Obstacle();
  37. void adjustAffectedHexes(std::set<BattleHex> & hexes, const Mechanics * m, const Target & spellTarget) const override;
  38. bool applicable(Problem & problem, const Mechanics * m) const override;
  39. bool applicable(Problem & problem, const Mechanics * m, const EffectTarget & target) const override;
  40. EffectTarget transformTarget(const Mechanics * m, const Target & aimPoint, const Target & spellTarget) const override;
  41. void apply(BattleStateProxy * battleState, RNG & rng, const Mechanics * m, const EffectTarget & target) const override;
  42. protected:
  43. void serializeJsonEffect(JsonSerializeFormat & handler) override;
  44. private:
  45. bool hidden;
  46. bool passable;
  47. bool trigger;
  48. bool trap;
  49. bool removeOnTrigger;
  50. int32_t patchCount;//random patches to place, only for massive spells
  51. int32_t turnsRemaining;
  52. std::array<ObstacleSideOptions, 2> sideOptions;
  53. static bool isHexAvailable(const CBattleInfoCallback * cb, const BattleHex & hex, const bool mustBeClear);
  54. static bool noRoomToPlace(Problem & problem, const Mechanics * m);
  55. void placeObstacles(BattleStateProxy * battleState, const Mechanics * m, const EffectTarget & target) const;
  56. };
  57. }
  58. }