diff options
author | Hop311 <Hop3114@gmail.com> | 2023-04-26 01:26:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-26 01:26:33 +0200 |
commit | 10053cf259c55ee45803268a844edf1011d8a16b (patch) | |
tree | fcf86e6fac31430ba537a0d056e97f901ad76dd7 /extension/src/openvic2/map/Building.hpp | |
parent | 639f86febf39184cccde9f898fc328375048233f (diff) | |
parent | 563834e7e6f9ce565bbfd553a0d9ff80a98c677d (diff) |
Merge pull request #98 from OpenVic2Project/some-cleanup
Req comments + cleanup + c++ registry refactoring
Diffstat (limited to 'extension/src/openvic2/map/Building.hpp')
-rw-r--r-- | extension/src/openvic2/map/Building.hpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/extension/src/openvic2/map/Building.hpp b/extension/src/openvic2/map/Building.hpp index 7a1a777..1305014 100644 --- a/extension/src/openvic2/map/Building.hpp +++ b/extension/src/openvic2/map/Building.hpp @@ -6,11 +6,16 @@ #include "openvic2/Date.hpp" namespace OpenVic2 { - struct BuildingManager; + struct Province; struct BuildingType; - struct Building { - friend struct BuildingManager; + /* REQUIREMENTS: + * MAP-11, MAP-72, MAP-73 + * MAP-12, MAP-75, MAP-76 + * MAP-13, MAP-78, MAP-79 + */ + struct Building : HasIdentifier { + friend struct Province; using level_t = int8_t; @@ -26,6 +31,8 @@ namespace OpenVic2 { bool _can_expand() const; public: + Building(Building&&) = default; + BuildingType const& get_type() const; level_t get_level() const; ExpansionState get_expansion_state() const; @@ -38,26 +45,31 @@ namespace OpenVic2 { void tick(Date const& today); }; + struct BuildingManager; + struct BuildingType : HasIdentifier { friend struct BuildingManager; private: - Building::level_t max_level; - Timespan build_time; + const Building::level_t max_level; + const Timespan build_time; BuildingType(std::string const& new_identifier, Building::level_t new_max_level, Timespan new_build_time); public: + BuildingType(BuildingType&&) = default; + Building::level_t get_max_level() const; Timespan get_build_time() const; }; struct BuildingManager { private: - std::vector<BuildingType> building_types; - bool building_types_locked = false; + IdentifierRegistry<BuildingType> building_types; public: + BuildingManager(); + return_t add_building_type(std::string const& identifier, Building::level_t max_level, Timespan build_time); void lock_building_types(); BuildingType const* get_building_type_by_identifier(std::string const& identifier) const; - void generate_province_buildings(std::vector<Building>& buildings) const; + return_t generate_province_buildings(Province& province) const; }; } |