aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp
diff options
context:
space:
mode:
author wvpm <24685035+wvpm@users.noreply.github.com>2024-10-28 11:07:15 +0100
committer wvpm <24685035+wvpm@users.noreply.github.com>2024-11-04 14:09:10 +0100
commit89e9c05f4d6276efa82fe486156357f841f864c3 (patch)
tree559be137cbbc7339c9d62658bf8a33366852bae5 /src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp
parent4eba08af501560e9139a562c53fbbc8b694fb4cf (diff)
Add market placeholder
Diffstat (limited to 'src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp')
-rw-r--r--src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp b/src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp
index ddf9d77..2413768 100644
--- a/src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp
+++ b/src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp
@@ -4,6 +4,7 @@
#include "openvic-simulation/economy/production/Employee.hpp"
#include "openvic-simulation/economy/production/ProductionType.hpp"
+#include "openvic-simulation/economy/trading/SellResult.hpp"
#include "openvic-simulation/map/ProvinceInstance.hpp"
#include "openvic-simulation/map/State.hpp"
#include "openvic-simulation/modifier/ModifierEffectCache.hpp"
@@ -14,6 +15,7 @@
using namespace OpenVic;
ResourceGatheringOperation::ResourceGatheringOperation(
+ MarketInstance& new_market_instance,
ModifierEffectCache const& new_modifier_effect_cache,
ProductionType const* new_production_type_nullable,
fixed_point_t new_size_multiplier,
@@ -22,7 +24,8 @@ ResourceGatheringOperation::ResourceGatheringOperation(
fixed_point_t new_unsold_quantity_yesterday,
std::vector<Employee>&& new_employees,
decltype(employee_count_per_type_cache)::keys_t const& pop_type_keys
-) : modifier_effect_cache { new_modifier_effect_cache },
+) : market_instance { new_market_instance },
+ modifier_effect_cache { new_modifier_effect_cache },
location_ptr { nullptr },
production_type_nullable { new_production_type_nullable },
revenue_yesterday { new_revenue_yesterday },
@@ -39,9 +42,11 @@ ResourceGatheringOperation::ResourceGatheringOperation(
{ }
ResourceGatheringOperation::ResourceGatheringOperation(
+ MarketInstance& new_market_instance,
ModifierEffectCache const& new_modifier_effect_cache,
decltype(employee_count_per_type_cache)::keys_t const& pop_type_keys
) : ResourceGatheringOperation {
+ new_market_instance,
new_modifier_effect_cache,
nullptr, fixed_point_t::_0(),
fixed_point_t::_0(), fixed_point_t::_0(),
@@ -146,15 +151,24 @@ void ResourceGatheringOperation::rgo_tick() {
owner_pops_cache,
total_owner_count_in_state_cache
);
-
- revenue_yesterday = output_quantity_yesterday * production_type.get_output_good().get_base_price(); //TODO sell on market
-
- pay_employees(
- revenue_yesterday,
- total_worker_count_in_province,
- owner_pops_cache,
- total_owner_count_in_state_cache
- );
+ market_instance.place_market_sell_order({
+ production_type.get_output_good(),
+ output_quantity_yesterday,
+ [
+ this,
+ total_worker_count_in_province,
+ owner_pops_cache = std::move(owner_pops_cache),
+ total_owner_count_in_state_cache
+ ](const SellResult sell_result) mutable -> void {
+ revenue_yesterday = sell_result.get_money_gained();
+ pay_employees(
+ revenue_yesterday,
+ total_worker_count_in_province,
+ owner_pops_cache,
+ total_owner_count_in_state_cache
+ );
+ }
+ });
}
void ResourceGatheringOperation::hire(const Pop::pop_size_t available_worker_count) {