diff options
Diffstat (limited to 'src/openvic-simulation/economy')
-rw-r--r-- | src/openvic-simulation/economy/Building.cpp | 23 | ||||
-rw-r--r-- | src/openvic-simulation/economy/Building.hpp | 10 | ||||
-rw-r--r-- | src/openvic-simulation/economy/EconomyManager.hpp | 2 | ||||
-rw-r--r-- | src/openvic-simulation/economy/Good.cpp | 2 |
4 files changed, 24 insertions, 13 deletions
diff --git a/src/openvic-simulation/economy/Building.cpp b/src/openvic-simulation/economy/Building.cpp index a79741b..38a8863 100644 --- a/src/openvic-simulation/economy/Building.cpp +++ b/src/openvic-simulation/economy/Building.cpp @@ -129,11 +129,11 @@ ExpansionState BuildingInstance::get_expansion_state() const { return expansion_state; } -Date const& BuildingInstance::get_start_date() const { +Date BuildingInstance::get_start_date() const { return start; } -Date const& BuildingInstance::get_end_date() const { +Date BuildingInstance::get_end_date() const { return end; } @@ -153,7 +153,7 @@ bool BuildingInstance::expand() { /* REQUIREMENTS: * MAP-71, MAP-74, MAP-77 */ -void BuildingInstance::update_state(Date const& today) { +void BuildingInstance::update_state(Date today) { switch (expansion_state) { case ExpansionState::Preparing: start = today; @@ -166,7 +166,7 @@ void BuildingInstance::update_state(Date const& today) { } } -void BuildingInstance::tick(Date const& today) { +void BuildingInstance::tick(Date today) { if (expansion_state == ExpansionState::Preparing) { expansion_state = ExpansionState::Expanding; } @@ -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..e907e49 100644 --- a/src/openvic-simulation/economy/Building.hpp +++ b/src/openvic-simulation/economy/Building.hpp @@ -133,13 +133,13 @@ namespace OpenVic { level_t get_current_level() const; ExpansionState get_expansion_state() const; - Date const& get_start_date() const; - Date const& get_end_date() const; + Date get_start_date() const; + Date get_end_date() const; float get_expansion_progress() const; bool expand(); - void update_state(Date const& today); - void tick(Date const& today); + void update_state(Date today); + void tick(Date today); }; struct Province; @@ -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); } }; diff --git a/src/openvic-simulation/economy/Good.cpp b/src/openvic-simulation/economy/Good.cpp index 11230d2..2b1d694 100644 --- a/src/openvic-simulation/economy/Good.cpp +++ b/src/openvic-simulation/economy/Good.cpp @@ -10,7 +10,7 @@ GoodCategory::GoodCategory(std::string_view new_identifier) : HasIdentifier { ne Good::Good( std::string_view new_identifier, colour_t new_colour, GoodCategory const& new_category, price_t new_base_price, bool new_available_from_start, bool new_tradeable, bool new_money, bool new_overseas_penalty -) : HasIdentifierAndColour { new_identifier, new_colour, true, false }, category { new_category }, +) : HasIdentifierAndColour { new_identifier, new_colour, false, false }, category { new_category }, base_price { new_base_price }, available_from_start { new_available_from_start }, tradeable { new_tradeable }, money { new_money }, overseas_penalty { new_overseas_penalty } { assert(base_price > NULL_PRICE); |