CBuilding.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * CBuilding.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 "../../constants/EntityIdentifiers.h"
  12. #include "../../LogicalExpression.h"
  13. #include "../../ResourceSet.h"
  14. #include "../../bonuses/BonusList.h"
  15. #include "../../rewardable/Info.h"
  16. VCMI_LIB_NAMESPACE_BEGIN
  17. class CTown;
  18. /// a typical building encountered in every castle ;]
  19. /// this is structure available to both client and server
  20. /// contains all mechanics-related data about town structures
  21. class DLL_LINKAGE CBuilding
  22. {
  23. std::string modScope;
  24. std::string identifier;
  25. public:
  26. using TRequired = LogicalExpression<BuildingID>;
  27. CTown * town; // town this building belongs to
  28. TResources resources;
  29. TResources produce;
  30. TRequired requirements;
  31. ArtifactID warMachine;
  32. std::set<EMarketMode> marketModes;
  33. BuildingID bid; //structure ID
  34. BuildingID upgrade; /// indicates that building "upgrade" can be improved by this, -1 = empty
  35. BuildingSubID::EBuildingSubID subId; /// subtype for special buildings, -1 = the building is not special
  36. bool upgradeReplacesBonuses = false;
  37. BonusList buildingBonuses;
  38. Rewardable::Info rewardableObjectInfo; ///configurable rewards for special buildings
  39. enum EBuildMode
  40. {
  41. BUILD_NORMAL, // 0 - normal, default
  42. BUILD_AUTO, // 1 - auto - building appears when all requirements are built
  43. BUILD_SPECIAL, // 2 - special - building can not be built normally
  44. BUILD_GRAIL // 3 - grail - building requires grail to be built
  45. } mode;
  46. enum ETowerHeight // for lookup towers and some grails
  47. {
  48. HEIGHT_NO_TOWER = 5, // building has not 'lookout tower' ability
  49. HEIGHT_LOW = 10, // low lookout tower, but castle without lookout tower gives radius 5
  50. HEIGHT_AVERAGE = 15,
  51. HEIGHT_HIGH = 20, // such tower is in the Tower town
  52. HEIGHT_SKYSHIP = std::numeric_limits<int>::max() // grail, open entire map
  53. } height;
  54. static const std::map<std::string, CBuilding::EBuildMode> MODES;
  55. static const std::map<std::string, CBuilding::ETowerHeight> TOWER_TYPES;
  56. CBuilding() : town(nullptr), mode(BUILD_NORMAL) {};
  57. BuildingTypeUniqueID getUniqueTypeID() const;
  58. std::string getJsonKey() const;
  59. std::string getNameTranslated() const;
  60. std::string getDescriptionTranslated() const;
  61. std::string getBaseTextID() const;
  62. std::string getNameTextID() const;
  63. std::string getDescriptionTextID() const;
  64. //return base of upgrade(s) or this
  65. BuildingID getBase() const;
  66. // returns how many times build has to be upgraded to become build
  67. si32 getDistance(const BuildingID & build) const;
  68. STRONG_INLINE
  69. bool IsTradeBuilding() const
  70. {
  71. return !marketModes.empty();
  72. }
  73. void addNewBonus(const std::shared_ptr<Bonus> & b, BonusList & bonusList) const;
  74. friend class CTownHandler;
  75. };
  76. VCMI_LIB_NAMESPACE_END