Skip to content

Commit b004547

Browse files
committed
Added producer types
1 parent 068c13e commit b004547

File tree

6 files changed

+163
-0
lines changed

6 files changed

+163
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "ArtisanalProducer.hpp"
2+
3+
using namespace OpenVic;
4+
5+
ArtisanalProducer::ArtisanalProducer(
6+
ProductionType const& new_production_type, Good::good_map_t&& new_stockpile, const fixed_point_t new_current_production,
7+
Good::good_map_t&& new_current_needs
8+
)
9+
: production_type { new_production_type }, stockpile { std::move(new_stockpile) },
10+
current_production { new_current_production }, current_needs { std::move(new_current_needs) } {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
3+
#include "openvic-simulation/economy/Good.hpp"
4+
#include "openvic-simulation/economy/ProductionType.hpp"
5+
#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
6+
#include "openvic-simulation/utility/Getters.hpp"
7+
8+
namespace OpenVic {
9+
class ArtisanalProducer final {
10+
private:
11+
ProductionType const& PROPERTY(production_type);
12+
Good::good_map_t PROPERTY(stockpile);
13+
fixed_point_t PROPERTY(current_production);
14+
Good::good_map_t PROPERTY(current_needs);
15+
16+
public:
17+
ArtisanalProducer(
18+
ProductionType const& new_production_type, Good::good_map_t&& new_stockpile,
19+
const fixed_point_t new_current_production, Good::good_map_t&& new_current_needs
20+
);
21+
};
22+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "FactoryProducer.hpp"
2+
3+
using namespace OpenVic;
4+
5+
FactoryProducer::FactoryProducer(
6+
ProductionType const& new_production_type, const fixed_point_t new_size_multiplier,
7+
const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday,
8+
const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees,
9+
Good::good_map_t&& new_stockpile, fixed_point_t new_budget, const fixed_point_t new_balance_yesterday,
10+
const fixed_point_t new_received_investments_yesterday, const fixed_point_t new_market_spendings_yesterday,
11+
const fixed_point_t new_paychecks_yesterday, const uint32_t new_unprofitable_days, const uint32_t new_subsidised_days,
12+
const uint32_t new_days_without_input, const uint8_t new_hiring_priority, const uint8_t new_profit_history_current,
13+
std::array<fixed_point_t, DAYS_OF_HISTORY>&& new_daily_profit_history
14+
)
15+
: production_type { new_production_type }, size_multiplier { new_size_multiplier },
16+
revenue_yesterday { new_revenue_yesterday }, output_quantity_yesterday { new_output_quantity_yesterday },
17+
unsold_quantity_yesterday { new_unsold_quantity_yesterday }, employees { std::move(new_employees) },
18+
stockpile { std::move(new_stockpile) }, budget { new_budget }, balance_yesterday { new_balance_yesterday },
19+
received_investments_yesterday { new_received_investments_yesterday },
20+
market_spendings_yesterday { new_market_spendings_yesterday }, paychecks_yesterday { new_paychecks_yesterday },
21+
unprofitable_days { new_unprofitable_days }, subsidised_days { new_subsidised_days },
22+
days_without_input { new_days_without_input }, hiring_priority { new_hiring_priority },
23+
profit_history_current { new_profit_history_current }, daily_profit_history { std::move(new_daily_profit_history) } {}
24+
FactoryProducer::FactoryProducer(ProductionType const& new_production_type, const fixed_point_t new_size_multiplier)
25+
: FactoryProducer { new_production_type, new_size_multiplier, 0, 0, 0, {}, {}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {} } {}
26+
27+
fixed_point_t FactoryProducer::get_profitability_yesterday() const {
28+
return daily_profit_history[profit_history_current];
29+
}
30+
31+
fixed_point_t FactoryProducer::get_average_profitability_last_seven_days() const {
32+
fixed_point_t sum = 0;
33+
34+
for (int i = 0; i <= profit_history_current; i++) {
35+
sum += daily_profit_history[i];
36+
}
37+
38+
return sum / (1 + profit_history_current);
39+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#pragma once
2+
3+
#include <cstdint>
4+
5+
#include "openvic-simulation/economy/Good.hpp"
6+
#include "openvic-simulation/economy/ProductionType.hpp"
7+
#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
8+
#include "openvic-simulation/utility/Getters.hpp"
9+
10+
namespace OpenVic {
11+
class FactoryProducer final {
12+
private:
13+
static constexpr uint8_t DAYS_OF_HISTORY = 7;
14+
using daily_profit_history_t = std::array<fixed_point_t, DAYS_OF_HISTORY>;
15+
16+
uint8_t PROPERTY(profit_history_current);
17+
daily_profit_history_t PROPERTY(daily_profit_history);
18+
ProductionType const& PROPERTY(production_type);
19+
fixed_point_t PROPERTY(revenue_yesterday);
20+
fixed_point_t PROPERTY(output_quantity_yesterday);
21+
fixed_point_t PROPERTY(unsold_quantity_yesterday);
22+
fixed_point_t PROPERTY(size_multiplier);
23+
ordered_map<Pop*, Pop::pop_size_t> PROPERTY(employees);
24+
Good::good_map_t PROPERTY(stockpile);
25+
fixed_point_t PROPERTY(budget);
26+
fixed_point_t PROPERTY(balance_yesterday);
27+
fixed_point_t PROPERTY(received_investments_yesterday);
28+
fixed_point_t PROPERTY(market_spendings_yesterday);
29+
fixed_point_t PROPERTY(paychecks_yesterday);
30+
uint32_t PROPERTY(unprofitable_days);
31+
uint32_t PROPERTY(subsidised_days);
32+
uint32_t PROPERTY(days_without_input);
33+
uint8_t PROPERTY_RW(hiring_priority);
34+
35+
public:
36+
FactoryProducer(
37+
ProductionType const& new_production_type, const fixed_point_t new_size_multiplier,
38+
const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday,
39+
const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees,
40+
Good::good_map_t&& new_stockpile, fixed_point_t new_budget, const fixed_point_t new_balance_yesterday,
41+
const fixed_point_t new_received_investments_yesterday, const fixed_point_t new_market_spendings_yesterday,
42+
const fixed_point_t new_paychecks_yesterday, const uint32_t new_unprofitable_days,
43+
const uint32_t new_subsidised_days, const uint32_t new_days_without_input, const uint8_t new_hiring_priority,
44+
const uint8_t new_profit_history_current, daily_profit_history_t&& new_daily_profit_history
45+
);
46+
FactoryProducer(ProductionType const& new_production_type, const fixed_point_t new_size_multiplier);
47+
48+
fixed_point_t get_profitability_yesterday() const;
49+
fixed_point_t get_average_profitability_last_seven_days() const;
50+
};
51+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "ResourceGatheringOperation.hpp"
2+
3+
using namespace OpenVic;
4+
5+
ResourceGatheringOperation::ResourceGatheringOperation(
6+
ProductionType const& new_production_type, const fixed_point_t new_size_multiplier,
7+
const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday,
8+
const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees
9+
)
10+
: production_type { new_production_type }, revenue_yesterday { new_revenue_yesterday },
11+
output_quantity_yesterday { new_output_quantity_yesterday }, unsold_quantity_yesterday { new_unsold_quantity_yesterday },
12+
size_multiplier { new_size_multiplier }, employees { std::move(new_employees) } {}
13+
ResourceGatheringOperation::ResourceGatheringOperation(
14+
ProductionType const& new_production_type, const fixed_point_t new_size_multiplier
15+
)
16+
: ResourceGatheringOperation(new_production_type, new_size_multiplier, 0, 0, 0, {}) {}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
3+
#include "openvic-simulation/economy/ProductionType.hpp"
4+
#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
5+
#include "openvic-simulation/utility/Getters.hpp"
6+
7+
namespace OpenVic {
8+
class ResourceGatheringOperation final {
9+
private:
10+
ProductionType const& PROPERTY(production_type);
11+
fixed_point_t PROPERTY(revenue_yesterday);
12+
fixed_point_t PROPERTY(output_quantity_yesterday);
13+
fixed_point_t PROPERTY(unsold_quantity_yesterday);
14+
fixed_point_t PROPERTY(size_multiplier);
15+
ordered_map<Pop*, Pop::pop_size_t> PROPERTY(employees);
16+
17+
public:
18+
ResourceGatheringOperation(
19+
ProductionType const& new_production_type, const fixed_point_t new_size_multiplier,
20+
const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday,
21+
const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees
22+
);
23+
ResourceGatheringOperation(ProductionType const& new_production_type, const fixed_point_t new_size_multiplier);
24+
};
25+
}

0 commit comments

Comments
 (0)