diff options
Diffstat (limited to 'src/openvic-simulation/economy/GoodInstance.cpp')
-rw-r--r-- | src/openvic-simulation/economy/GoodInstance.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/openvic-simulation/economy/GoodInstance.cpp b/src/openvic-simulation/economy/GoodInstance.cpp index ac081c9..3e3d88e 100644 --- a/src/openvic-simulation/economy/GoodInstance.cpp +++ b/src/openvic-simulation/economy/GoodInstance.cpp @@ -3,8 +3,28 @@ using namespace OpenVic; GoodInstance::GoodInstance(GoodDefinition const& new_good_definition) - : HasIdentifierAndColour { new_good_definition }, good_definition { new_good_definition }, - price { new_good_definition.get_base_price() }, is_available { new_good_definition.get_is_available_from_start() } {} + : HasIdentifierAndColour { new_good_definition }, + good_definition { new_good_definition }, + price { new_good_definition.get_base_price() }, + is_available { new_good_definition.get_is_available_from_start() }, + supply_running_total { fixed_point_t::_0() }, + total_supply_yesterday { fixed_point_t::_0() }, + market_sell_order_quantities {}, + market_sell_order_callbacks {} + {} + +void GoodInstance::add_market_sell_order(const fixed_point_t quantity, const std::function<void(SellResult)> callback) { + supply_running_total += quantity; + market_sell_order_quantities.push_back(quantity); + market_sell_order_callbacks.push_back(callback); +} + +void GoodInstance::clear_orders() { + total_supply_yesterday = supply_running_total; + supply_running_total = fixed_point_t::_0(); + market_sell_order_quantities.clear(); + market_sell_order_callbacks.clear(); +} bool GoodInstanceManager::setup(GoodDefinitionManager const& good_definition_manager) { if (good_instances_are_locked()) { |