Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/openvic-simulation/economy/ArtisanalProducer.cpp
Original file line number Diff line number Diff line change
@@ -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) } {}
22 changes: 22 additions & 0 deletions src/openvic-simulation/economy/ArtisanalProducer.hpp
Original file line number Diff line number Diff line change
@@ -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
);
};
}
39 changes: 39 additions & 0 deletions src/openvic-simulation/economy/FactoryProducer.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
51 changes: 51 additions & 0 deletions src/openvic-simulation/economy/FactoryProducer.hpp
Original file line number Diff line number Diff line change
@@ -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;
};
}
16 changes: 16 additions & 0 deletions src/openvic-simulation/economy/ResourceGatheringOperation.cpp
Original file line number Diff line number Diff line change
@@ -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, {}) {}
25 changes: 25 additions & 0 deletions src/openvic-simulation/economy/ResourceGatheringOperation.hpp
Original file line number Diff line number Diff line change
@@ -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);
};
}