CRmgTemplate.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * CRmgTemplate.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 "../GameConstants.h"
  12. class CRmgTemplateZone;
  13. /// The CRmgTemplateZoneConnection describes the connection between two zones.
  14. class DLL_LINKAGE CRmgTemplateZoneConnection
  15. {
  16. public:
  17. CRmgTemplateZoneConnection();
  18. CRmgTemplateZone * getZoneA() const;
  19. void setZoneA(CRmgTemplateZone * value);
  20. CRmgTemplateZone * getZoneB() const;
  21. void setZoneB(CRmgTemplateZone * value);
  22. int getGuardStrength() const; /// Default: 0
  23. void setGuardStrength(int value);
  24. private:
  25. CRmgTemplateZone * zoneA, * zoneB;
  26. int guardStrength;
  27. };
  28. /// The CRmgTemplate describes a random map template.
  29. class DLL_LINKAGE CRmgTemplate
  30. {
  31. public:
  32. class CSize
  33. {
  34. public:
  35. CSize();
  36. CSize(int width, int height, bool under);
  37. int getWidth() const; /// Default: CMapHeader::MAP_SIZE_MIDDLE
  38. void setWidth(int value);
  39. int getHeight() const; /// Default: CMapHeader::MAP_SIZE_MIDDLE
  40. void setHeight(int value);
  41. bool getUnder() const; /// Default: true
  42. void setUnder(bool value);
  43. bool operator<=(const CSize & value) const;
  44. bool operator>=(const CSize & value) const;
  45. private:
  46. int width, height;
  47. bool under;
  48. };
  49. class CPlayerCountRange
  50. {
  51. public:
  52. void addRange(int lower, int upper);
  53. void addNumber(int value);
  54. bool isInRange(int count) const;
  55. std::set<int> getNumbers() const;
  56. private:
  57. std::list<std::pair<int, int> > range;
  58. };
  59. CRmgTemplate();
  60. ~CRmgTemplate();
  61. const std::string & getName() const;
  62. void setName(const std::string & value);
  63. const CSize & getMinSize() const;
  64. void setMinSize(const CSize & value);
  65. const CSize & getMaxSize() const;
  66. void setMaxSize(const CSize & value);
  67. const CPlayerCountRange & getPlayers() const;
  68. void setPlayers(const CPlayerCountRange & value);
  69. const CPlayerCountRange & getCpuPlayers() const;
  70. void setCpuPlayers(const CPlayerCountRange & value);
  71. const std::map<TRmgTemplateZoneId, CRmgTemplateZone *> & getZones() const;
  72. void setZones(const std::map<TRmgTemplateZoneId, CRmgTemplateZone *> & value);
  73. const std::list<CRmgTemplateZoneConnection> & getConnections() const;
  74. void setConnections(const std::list<CRmgTemplateZoneConnection> & value);
  75. void validate() const; /// Tests template on validity and throws exception on failure
  76. private:
  77. std::string name;
  78. CSize minSize, maxSize;
  79. CPlayerCountRange players, cpuPlayers;
  80. std::map<TRmgTemplateZoneId, CRmgTemplateZone *> zones;
  81. std::list<CRmgTemplateZoneConnection> connections;
  82. };