aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/openvic-simulation/economy/ArtisanalProducer.cpp10
-rw-r--r--src/openvic-simulation/economy/ArtisanalProducer.hpp22
-rw-r--r--src/openvic-simulation/economy/FactoryProducer.cpp39
-rw-r--r--src/openvic-simulation/economy/FactoryProducer.hpp51
-rw-r--r--src/openvic-simulation/economy/ResourceGatheringOperation.cpp16
-rw-r--r--src/openvic-simulation/economy/ResourceGatheringOperation.hpp25
6 files changed, 163 insertions, 0 deletions
diff --git a/src/openvic-simulation/economy/ArtisanalProducer.cpp b/src/openvic-simulation/economy/ArtisanalProducer.cpp
new file mode 100644
index 0000000..52cfa4f
--- /dev/null
+++ b/src/openvic-simulation/economy/ArtisanalProducer.cpp
@@ -0,0 +1,10 @@
+#include "ArtisanalProducer.hpp"
+
+using namespace OpenVic;
+
+ArtisanalProducer::ArtisanalProducer(
+ ProductionType const& new_production_type, Good::good_map_t&& new_stockpile, const fixed_point_t new_current_production,
+ Good::good_map_t&& new_current_needs
+)
+ : production_type { new_production_type }, stockpile { std::move(new_stockpile) },
+ current_production { new_current_production }, current_needs { std::move(new_current_needs) } {}
diff --git a/src/openvic-simulation/economy/ArtisanalProducer.hpp b/src/openvic-simulation/economy/ArtisanalProducer.hpp
new file mode 100644
index 0000000..36de2f2
--- /dev/null
+++ b/src/openvic-simulation/economy/ArtisanalProducer.hpp
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "openvic-simulation/economy/Good.hpp"
+#include "openvic-simulation/economy/ProductionType.hpp"
+#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
+#include "openvic-simulation/utility/Getters.hpp"
+
+namespace OpenVic {
+ class ArtisanalProducer final {
+ private:
+ ProductionType const& PROPERTY(production_type);
+ Good::good_map_t PROPERTY(stockpile);
+ fixed_point_t PROPERTY(current_production);
+ Good::good_map_t PROPERTY(current_needs);
+
+ public:
+ ArtisanalProducer(
+ ProductionType const& new_production_type, Good::good_map_t&& new_stockpile,
+ const fixed_point_t new_current_production, Good::good_map_t&& new_current_needs
+ );
+ };
+}
diff --git a/src/openvic-simulation/economy/FactoryProducer.cpp b/src/openvic-simulation/economy/FactoryProducer.cpp
new file mode 100644
index 0000000..81ebd4a
--- /dev/null
+++ b/src/openvic-simulation/economy/FactoryProducer.cpp
@@ -0,0 +1,39 @@
+#include "FactoryProducer.hpp"
+
+using namespace OpenVic;
+
+FactoryProducer::FactoryProducer(
+ ProductionType const& new_production_type, const fixed_point_t new_size_multiplier,
+ const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday,
+ const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees,
+ Good::good_map_t&& new_stockpile, fixed_point_t new_budget, const fixed_point_t new_balance_yesterday,
+ const fixed_point_t new_received_investments_yesterday, const fixed_point_t new_market_spendings_yesterday,
+ const fixed_point_t new_paychecks_yesterday, const uint32_t new_unprofitable_days, const uint32_t new_subsidised_days,
+ const uint32_t new_days_without_input, const uint8_t new_hiring_priority, const uint8_t new_profit_history_current,
+ daily_profit_history_t&& new_daily_profit_history
+)
+ : production_type { new_production_type }, size_multiplier { new_size_multiplier },
+ revenue_yesterday { new_revenue_yesterday }, output_quantity_yesterday { new_output_quantity_yesterday },
+ unsold_quantity_yesterday { new_unsold_quantity_yesterday }, employees { std::move(new_employees) },
+ stockpile { std::move(new_stockpile) }, budget { new_budget }, balance_yesterday { new_balance_yesterday },
+ received_investments_yesterday { new_received_investments_yesterday },
+ market_spendings_yesterday { new_market_spendings_yesterday }, paychecks_yesterday { new_paychecks_yesterday },
+ unprofitable_days { new_unprofitable_days }, subsidised_days { new_subsidised_days },
+ days_without_input { new_days_without_input }, hiring_priority { new_hiring_priority },
+ profit_history_current { new_profit_history_current }, daily_profit_history { std::move(new_daily_profit_history) } {}
+FactoryProducer::FactoryProducer(ProductionType const& new_production_type, const fixed_point_t new_size_multiplier)
+ : FactoryProducer { new_production_type, new_size_multiplier, 0, 0, 0, {}, {}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {} } {}
+
+fixed_point_t FactoryProducer::get_profitability_yesterday() const {
+ return daily_profit_history[profit_history_current];
+}
+
+fixed_point_t FactoryProducer::get_average_profitability_last_seven_days() const {
+ fixed_point_t sum = 0;
+
+ for (int i = 0; i <= profit_history_current; i++) {
+ sum += daily_profit_history[i];
+ }
+
+ return sum / (1 + profit_history_current);
+}
diff --git a/src/openvic-simulation/economy/FactoryProducer.hpp b/src/openvic-simulation/economy/FactoryProducer.hpp
new file mode 100644
index 0000000..623ec48
--- /dev/null
+++ b/src/openvic-simulation/economy/FactoryProducer.hpp
@@ -0,0 +1,51 @@
+#pragma once
+
+#include <cstdint>
+
+#include "openvic-simulation/economy/Good.hpp"
+#include "openvic-simulation/economy/ProductionType.hpp"
+#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
+#include "openvic-simulation/utility/Getters.hpp"
+
+namespace OpenVic {
+ class FactoryProducer final {
+ private:
+ static constexpr uint8_t DAYS_OF_HISTORY = 7;
+ using daily_profit_history_t = std::array<fixed_point_t, DAYS_OF_HISTORY>;
+
+ uint8_t PROPERTY(profit_history_current);
+ daily_profit_history_t PROPERTY(daily_profit_history);
+ ProductionType const& PROPERTY(production_type);
+ fixed_point_t PROPERTY(revenue_yesterday);
+ fixed_point_t PROPERTY(output_quantity_yesterday);
+ fixed_point_t PROPERTY(unsold_quantity_yesterday);
+ fixed_point_t PROPERTY(size_multiplier);
+ ordered_map<Pop*, Pop::pop_size_t> PROPERTY(employees);
+ Good::good_map_t PROPERTY(stockpile);
+ fixed_point_t PROPERTY(budget);
+ fixed_point_t PROPERTY(balance_yesterday);
+ fixed_point_t PROPERTY(received_investments_yesterday);
+ fixed_point_t PROPERTY(market_spendings_yesterday);
+ fixed_point_t PROPERTY(paychecks_yesterday);
+ uint32_t PROPERTY(unprofitable_days);
+ uint32_t PROPERTY(subsidised_days);
+ uint32_t PROPERTY(days_without_input);
+ uint8_t PROPERTY_RW(hiring_priority);
+
+ public:
+ FactoryProducer(
+ ProductionType const& new_production_type, const fixed_point_t new_size_multiplier,
+ const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday,
+ const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees,
+ Good::good_map_t&& new_stockpile, fixed_point_t new_budget, const fixed_point_t new_balance_yesterday,
+ const fixed_point_t new_received_investments_yesterday, const fixed_point_t new_market_spendings_yesterday,
+ const fixed_point_t new_paychecks_yesterday, const uint32_t new_unprofitable_days,
+ const uint32_t new_subsidised_days, const uint32_t new_days_without_input, const uint8_t new_hiring_priority,
+ const uint8_t new_profit_history_current, daily_profit_history_t&& new_daily_profit_history
+ );
+ FactoryProducer(ProductionType const& new_production_type, const fixed_point_t new_size_multiplier);
+
+ fixed_point_t get_profitability_yesterday() const;
+ fixed_point_t get_average_profitability_last_seven_days() const;
+ };
+}
diff --git a/src/openvic-simulation/economy/ResourceGatheringOperation.cpp b/src/openvic-simulation/economy/ResourceGatheringOperation.cpp
new file mode 100644
index 0000000..19bce2d
--- /dev/null
+++ b/src/openvic-simulation/economy/ResourceGatheringOperation.cpp
@@ -0,0 +1,16 @@
+#include "ResourceGatheringOperation.hpp"
+
+using namespace OpenVic;
+
+ResourceGatheringOperation::ResourceGatheringOperation(
+ ProductionType const& new_production_type, const fixed_point_t new_size_multiplier,
+ const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday,
+ const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees
+)
+ : production_type { new_production_type }, revenue_yesterday { new_revenue_yesterday },
+ output_quantity_yesterday { new_output_quantity_yesterday }, unsold_quantity_yesterday { new_unsold_quantity_yesterday },
+ size_multiplier { new_size_multiplier }, employees { std::move(new_employees) } {}
+ResourceGatheringOperation::ResourceGatheringOperation(
+ ProductionType const& new_production_type, const fixed_point_t new_size_multiplier
+)
+ : ResourceGatheringOperation(new_production_type, new_size_multiplier, 0, 0, 0, {}) {}
diff --git a/src/openvic-simulation/economy/ResourceGatheringOperation.hpp b/src/openvic-simulation/economy/ResourceGatheringOperation.hpp
new file mode 100644
index 0000000..4855a30
--- /dev/null
+++ b/src/openvic-simulation/economy/ResourceGatheringOperation.hpp
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "openvic-simulation/economy/ProductionType.hpp"
+#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
+#include "openvic-simulation/utility/Getters.hpp"
+
+namespace OpenVic {
+ class ResourceGatheringOperation final {
+ private:
+ ProductionType const& PROPERTY(production_type);
+ fixed_point_t PROPERTY(revenue_yesterday);
+ fixed_point_t PROPERTY(output_quantity_yesterday);
+ fixed_point_t PROPERTY(unsold_quantity_yesterday);
+ fixed_point_t PROPERTY(size_multiplier);
+ ordered_map<Pop*, Pop::pop_size_t> PROPERTY(employees);
+
+ public:
+ ResourceGatheringOperation(
+ ProductionType const& new_production_type, const fixed_point_t new_size_multiplier,
+ const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday,
+ const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees
+ );
+ ResourceGatheringOperation(ProductionType const& new_production_type, const fixed_point_t new_size_multiplier);
+ };
+}