diff options
4 files changed, 35 insertions, 30 deletions
diff --git a/src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp b/src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp index 14688ea..ef20db8 100644 --- a/src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp +++ b/src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp @@ -1,5 +1,7 @@ #include "ResourceGatheringOperation.hpp" -#include "types/fixed_point/FixedPoint.hpp" +#include "openvic-simulation/pop/Pop.hpp" +#include "openvic-simulation/map/ProvinceInstance.hpp" +#include "openvic-simulation/types/fixed_point/FixedPoint.hpp" using namespace OpenVic; @@ -22,4 +24,32 @@ ResourceGatheringOperation::ResourceGatheringOperation() : ResourceGatheringOper nullptr, fixed_point_t::_0(), fixed_point_t::_0(), fixed_point_t::_0() , fixed_point_t::_0(), {} -} {}
\ No newline at end of file +} {} + +void ResourceGatheringOperation::update_size(ProvinceInstance const& location) { + if(production_type == nullptr) { + size_multiplier = fixed_point_t::_0(); + } + else { + std::vector<Job> const& jobs = production_type->get_jobs(); + fixed_point_t total_worker_count_in_province = 0; //not counting equivalents + for(Pop const& pop : location.get_pops()) { + bool is_worker_pop_type = false; + for(Job const& job : jobs) { + if(job.get_pop_type() == pop.get_type()) { + is_worker_pop_type = true; + break; + } + } + + if(is_worker_pop_type) { + total_worker_count_in_province += pop.get_size(); + } + } + + const fixed_point_t base_workforce_size = production_type->get_base_workforce_size(); + //TODO: if is_farm add farm size bonus + //TODO: if is_mine add mine size bonus + size_multiplier = ((total_worker_count_in_province / base_workforce_size).ceil() * fixed_point_t::_1_50()).floor(); + } +}
\ No newline at end of file diff --git a/src/openvic-simulation/economy/production/ResourceGatheringOperation.hpp b/src/openvic-simulation/economy/production/ResourceGatheringOperation.hpp index 70a84c0..dff9f5f 100644 --- a/src/openvic-simulation/economy/production/ResourceGatheringOperation.hpp +++ b/src/openvic-simulation/economy/production/ResourceGatheringOperation.hpp @@ -3,6 +3,7 @@ #include "openvic-simulation/economy/production/ProductionType.hpp" #include "openvic-simulation/types/fixed_point/FixedPoint.hpp" #include "openvic-simulation/utility/Getters.hpp" +#include "pop/Pop.hpp" namespace OpenVic { struct ResourceGatheringOperation { @@ -27,5 +28,6 @@ namespace OpenVic { constexpr bool is_valid() const { return production_type != nullptr; } + void update_size(ProvinceInstance const& location); }; } diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp index 7abb5cb..4282e7b 100644 --- a/src/openvic-simulation/map/ProvinceInstance.cpp +++ b/src/openvic-simulation/map/ProvinceInstance.cpp @@ -9,7 +9,6 @@ #include "openvic-simulation/misc/Define.hpp" #include "openvic-simulation/politics/Ideology.hpp" #include "openvic-simulation/pop/Pop.hpp" -#include "openvic-simulation/types/fixed_point/FixedPoint.hpp" using namespace OpenVic; @@ -201,29 +200,6 @@ void ProvinceInstance::_update_pops(DefineManager const& define_manager) { } } -fixed_point_t ProvinceInstance::calculate_rgo_size(ProductionType const& production_type) const { - std::vector<Job> const& jobs = production_type.get_jobs(); - fixed_point_t total_worker_count_in_province = 0; //not counting equivalents - for(Pop const& pop : pops) { - bool is_worker_pop_type = false; - for(Job const& job : jobs) { - if(job.get_pop_type() == pop.get_type()) { - is_worker_pop_type = true; - break; - } - } - - if(is_worker_pop_type) { - total_worker_count_in_province += pop.get_size(); - } - } - - const fixed_point_t base_workforce_size = production_type.get_base_workforce_size(); - //TODO: if is_farm add farm size bonus - //TODO: if is_mine add mine size bonus - return ((total_worker_count_in_province / base_workforce_size).ceil() * fixed_point_t::_1_50()).floor(); -} - void ProvinceInstance::convert_rgo_worker_pops_to_equivalent(ProductionType const& production_type) { std::vector<Job> const& jobs = production_type.get_jobs(); fixed_point_t total_worker_count_in_province = 0; //not counting equivalents @@ -362,8 +338,8 @@ bool ProvinceInstance::apply_history_to_province(ProvinceHistoryEntry const& ent void ProvinceInstance::setup_rgo(ProductionType const& rgo_production_type) { convert_rgo_worker_pops_to_equivalent(rgo_production_type); - rgo.set_size_multiplier(calculate_rgo_size(rgo_production_type)); rgo.set_production_type(&rgo_production_type); + rgo.update_size(*this); } void ProvinceInstance::setup_pop_test_values(IssueManager const& issue_manager) { diff --git a/src/openvic-simulation/map/ProvinceInstance.hpp b/src/openvic-simulation/map/ProvinceInstance.hpp index 281f19f..7e2754f 100644 --- a/src/openvic-simulation/map/ProvinceInstance.hpp +++ b/src/openvic-simulation/map/ProvinceInstance.hpp @@ -9,8 +9,6 @@ #include "openvic-simulation/pop/Pop.hpp" #include "openvic-simulation/types/HasIdentifier.hpp" #include "openvic-simulation/types/OrderedContainers.hpp" -#include "openvic-simulation/types/fixed_point/FixedPointMap.hpp" -#include "openvic-simulation/types/fixed_point/FixedPoint.hpp" namespace OpenVic { @@ -99,7 +97,6 @@ namespace OpenVic { void _add_pop(Pop&& pop); void _update_pops(DefineManager const& define_manager); - fixed_point_t calculate_rgo_size(ProductionType const& production_type) const; void convert_rgo_worker_pops_to_equivalent(ProductionType const& production_type); public: |