-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
215 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "MarketInstance.hpp" | ||
|
||
using namespace OpenVic; | ||
|
||
MarketInstance::MarketInstance(GoodInstanceManager& new_good_instance_manager) | ||
: good_instance_manager { new_good_instance_manager} {} | ||
|
||
void MarketInstance::place_market_sell_order(MarketSellOrder&& market_sell_order) { | ||
GoodDefinition const& good = market_sell_order.get_good(); | ||
GoodInstance& good_instance = good_instance_manager.get_good_instance_from_definition(good); | ||
good_instance.add_market_sell_order(std::move(market_sell_order)); | ||
} | ||
|
||
void MarketInstance::execute_orders() { | ||
std::vector<GoodInstance>& good_instances = good_instance_manager.get_good_instances(); | ||
for (GoodInstance& good_instance : good_instances) { | ||
good_instance.execute_orders(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include "openvic-simulation/economy/GoodInstance.hpp" | ||
#include "openvic-simulation/economy/trading/MarketSellOrder.hpp" | ||
|
||
namespace OpenVic { | ||
struct MarketInstance { | ||
private: | ||
GoodInstanceManager& PROPERTY(good_instance_manager); | ||
public: | ||
MarketInstance(GoodInstanceManager& new_good_instance_manager); | ||
void place_market_sell_order(MarketSellOrder&& market_sell_order); | ||
void execute_orders(); | ||
}; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/openvic-simulation/economy/trading/MarketSellOrder.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "MarketSellOrder.hpp" | ||
|
||
using namespace OpenVic; | ||
|
||
GoodMarketSellOrder::GoodMarketSellOrder( | ||
const fixed_point_t new_quantity, | ||
std::function<void(const SellResult)>&& new_after_trade | ||
): | ||
quantity { new_quantity }, | ||
after_trade { std::move(new_after_trade) } | ||
{} | ||
|
||
MarketSellOrder::MarketSellOrder( | ||
GoodDefinition const& new_good, | ||
const fixed_point_t new_quantity, | ||
std::function<void(const SellResult)>&& new_after_trade | ||
): GoodMarketSellOrder(new_quantity, std::move(new_after_trade)), | ||
good { new_good } | ||
{} |
Oops, something went wrong.