CBuilding.h 2.6 KB

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