CBuilding.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. std::set<EMarketMode> marketModes;
  32. BuildingID bid; //structure ID
  33. BuildingID upgrade; /// indicates that building "upgrade" can be improved by this, -1 = empty
  34. BuildingSubID::EBuildingSubID subId; /// subtype for special buildings, -1 = the building is not special
  35. bool upgradeReplacesBonuses = false;
  36. BonusList buildingBonuses;
  37. Rewardable::Info rewardableObjectInfo; ///configurable rewards for special buildings
  38. enum EBuildMode
  39. {
  40. BUILD_NORMAL, // 0 - normal, default
  41. BUILD_AUTO, // 1 - auto - building appears when all requirements are built
  42. BUILD_SPECIAL, // 2 - special - building can not be built normally
  43. BUILD_GRAIL // 3 - grail - building requires grail to be built
  44. } mode;
  45. enum ETowerHeight // for lookup towers and some grails
  46. {
  47. HEIGHT_NO_TOWER = 5, // building has not 'lookout tower' ability
  48. HEIGHT_LOW = 10, // low lookout tower, but castle without lookout tower gives radius 5
  49. HEIGHT_AVERAGE = 15,
  50. HEIGHT_HIGH = 20, // such tower is in the Tower town
  51. HEIGHT_SKYSHIP = std::numeric_limits<int>::max() // grail, open entire map
  52. } height;
  53. static const std::map<std::string, CBuilding::EBuildMode> MODES;
  54. static const std::map<std::string, CBuilding::ETowerHeight> TOWER_TYPES;
  55. CBuilding() : town(nullptr), mode(BUILD_NORMAL) {};
  56. BuildingTypeUniqueID getUniqueTypeID() const;
  57. std::string getJsonKey() const;
  58. std::string getNameTranslated() const;
  59. std::string getDescriptionTranslated() const;
  60. std::string getBaseTextID() const;
  61. std::string getNameTextID() const;
  62. std::string getDescriptionTextID() const;
  63. //return base of upgrade(s) or this
  64. BuildingID getBase() const;
  65. // returns how many times build has to be upgraded to become build
  66. si32 getDistance(const BuildingID & build) const;
  67. STRONG_INLINE
  68. bool IsTradeBuilding() const
  69. {
  70. return bid == BuildingID::MARKETPLACE || subId == BuildingSubID::ARTIFACT_MERCHANT || subId == BuildingSubID::FREELANCERS_GUILD;
  71. }
  72. void addNewBonus(const std::shared_ptr<Bonus> & b, BonusList & bonusList) const;
  73. friend class CTownHandler;
  74. };
  75. VCMI_LIB_NAMESPACE_END