aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/economy/GoodInstance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/economy/GoodInstance.cpp')
-rw-r--r--src/openvic-simulation/economy/GoodInstance.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/openvic-simulation/economy/GoodInstance.cpp b/src/openvic-simulation/economy/GoodInstance.cpp
index 3e3d88e..e48624c 100644
--- a/src/openvic-simulation/economy/GoodInstance.cpp
+++ b/src/openvic-simulation/economy/GoodInstance.cpp
@@ -13,6 +13,17 @@ GoodInstance::GoodInstance(GoodDefinition const& new_good_definition)
market_sell_order_callbacks {}
{}
+void GoodInstance::add_buy_up_to_order(
+ const fixed_point_t max_quantity,
+ const fixed_point_t money_to_spend,
+ const std::function<void(const BuyResult)> callback
+) {
+ demand_running_total += max_quantity;
+ buy_up_to_order_max_quantities.push_back(max_quantity);
+ buy_up_to_order_money_to_spend.push_back(money_to_spend);
+ buy_up_to_order_callbacks.push_back(callback);
+}
+
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);
@@ -20,8 +31,13 @@ void GoodInstance::add_market_sell_order(const fixed_point_t quantity, const std
}
void GoodInstance::clear_orders() {
+ total_demand_yesterday = demand_running_total;
+ demand_running_total = fixed_point_t::_0();
total_supply_yesterday = supply_running_total;
supply_running_total = fixed_point_t::_0();
+
+ buy_up_to_order_max_quantities.clear();
+ buy_up_to_order_callbacks.clear();
market_sell_order_quantities.clear();
market_sell_order_callbacks.clear();
}