diff options
author | hop311 <hop3114@gmail.com> | 2023-10-29 22:24:42 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2023-10-30 19:51:35 +0100 |
commit | 61e5c971cd371950a3bd659799208d8143dddd4f (patch) | |
tree | 3d6e4cf31866df81f80143b9d6801d2dec3190e6 /src/openvic-simulation/economy | |
parent | 1603fbafb1c03830f38fefd87d8bd0d7d3f135a2 (diff) |
ModifierEffects stored as instances
Diffstat (limited to 'src/openvic-simulation/economy')
-rw-r--r-- | src/openvic-simulation/economy/Building.cpp | 15 | ||||
-rw-r--r-- | src/openvic-simulation/economy/Building.hpp | 2 | ||||
-rw-r--r-- | src/openvic-simulation/economy/EconomyManager.hpp | 2 |
3 files changed, 15 insertions, 4 deletions
diff --git a/src/openvic-simulation/economy/Building.cpp b/src/openvic-simulation/economy/Building.cpp index a79741b..39b49ee 100644 --- a/src/openvic-simulation/economy/Building.cpp +++ b/src/openvic-simulation/economy/Building.cpp @@ -207,8 +207,8 @@ bool BuildingManager::add_building(std::string_view identifier, BuildingType con } bool BuildingManager::load_buildings_file( - GoodManager const& good_manager, ProductionTypeManager const& production_type_manager, - ModifierManager const& modifier_manager, ast::NodeCPtr root + GoodManager const& good_manager, ProductionTypeManager const& production_type_manager, ModifierManager& modifier_manager, + ast::NodeCPtr root ) { bool ret = expect_dictionary_reserve_length(buildings, [this](std::string_view, ast::NodeCPtr value) -> bool { return expect_key("type", expect_identifier( @@ -281,6 +281,17 @@ bool BuildingManager::load_buildings_file( )(root); lock_buildings(); + for (Building const& building : buildings.get_items()) { + std::string max_modifier_prefix = "max_"; + std::string min_modifier_prefix = "min_build_"; + modifier_manager.add_modifier_effect( + max_modifier_prefix.append(building.get_identifier()), true, ModifierEffect::format_t::INT + ); + modifier_manager.add_modifier_effect( + min_modifier_prefix.append(building.get_identifier()), false, ModifierEffect::format_t::INT + ); + } + return ret; } diff --git a/src/openvic-simulation/economy/Building.hpp b/src/openvic-simulation/economy/Building.hpp index 89b6db8..0b94298 100644 --- a/src/openvic-simulation/economy/Building.hpp +++ b/src/openvic-simulation/economy/Building.hpp @@ -162,7 +162,7 @@ namespace OpenVic { bool load_buildings_file( GoodManager const& good_manager, ProductionTypeManager const& production_type_manager, - ModifierManager const& modifier_manager, ast::NodeCPtr root + ModifierManager& modifier_manager, ast::NodeCPtr root ); bool generate_province_buildings(Province& province) const; diff --git a/src/openvic-simulation/economy/EconomyManager.hpp b/src/openvic-simulation/economy/EconomyManager.hpp index b7d45c9..7445614 100644 --- a/src/openvic-simulation/economy/EconomyManager.hpp +++ b/src/openvic-simulation/economy/EconomyManager.hpp @@ -20,7 +20,7 @@ namespace OpenVic { return production_type_manager.load_production_types_file(good_manager, pop_manager, root); } - inline bool load_buildings_file(ModifierManager const& modifier_manager, ast::NodeCPtr root) { + inline bool load_buildings_file(ModifierManager& modifier_manager, ast::NodeCPtr root) { return building_manager.load_buildings_file(good_manager, production_type_manager, modifier_manager, root); } }; |