Skip to content

Commit 43e6cd2

Browse files
committed
Added producer types
1 parent b578311 commit 43e6cd2

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#pragma once
2+
3+
#include <cstddef>
4+
#include <cstdint>
5+
6+
#include "openvic-simulation/economy/Good.hpp"
7+
#include "openvic-simulation/economy/ProductionType.hpp"
8+
#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
9+
#include "openvic-simulation/utility/Getters.hpp"
10+
11+
using money_t = OpenVic::fixed_point_t;
12+
using good_quantity_t = OpenVic::fixed_point_t;
13+
14+
namespace OpenVic {
15+
class Producer {
16+
public:
17+
ProductionType const& PROPERTY(production_type);
18+
};
19+
20+
class Manufacturer : public virtual Producer {
21+
public:
22+
Good::good_map_t PROPERTY(stockpile);
23+
};
24+
25+
class ArtisanalProducer final : public Manufacturer {
26+
public:
27+
good_quantity_t PROPERTY(current_production);
28+
Good::good_map_t PROPERTY(current_needs);
29+
};
30+
31+
class NonArtisanalProducer : public virtual Producer {
32+
private:
33+
Pop::pop_size_t get_max_workforce_size() const {
34+
return static_cast<Pop::pop_size_t>(
35+
static_cast<fixed_point_t>(production_type.get_base_workforce_size()) * size_multiplier
36+
);
37+
}
38+
39+
public:
40+
money_t PROPERTY(revenue_yesterday);
41+
good_quantity_t PROPERTY(output_quantity_yesterday);
42+
good_quantity_t PROPERTY(unsold_quantity_yesterday);
43+
fixed_point_t PROPERTY(size_multiplier);
44+
ordered_map<Pop const*, Pop::pop_size_t> PROPERTY(employees);
45+
};
46+
47+
class FactoryProducer final : public NonArtisanalProducer, public Manufacturer {
48+
private:
49+
static constexpr size_t days_of_history = 7;
50+
int PROPERTY(profit_history_current);
51+
std::array<money_t, days_of_history> PROPERTY(daily_profit_history);
52+
53+
fixed_point_t get_max_budget() const {
54+
return defines.economy.MAX_FACTORY_MONEY_SAVE * size_multiplier;
55+
}
56+
57+
public:
58+
money_t PROPERTY(budget);
59+
money_t PROPERTY(balance_yesterday);
60+
money_t PROPERTY(received_investments_yesterday);
61+
money_t PROPERTY(market_spendings_yesterday);
62+
money_t PROPERTY(paychecks_yesterday);
63+
uint32_t PROPERTY(unprofitable_days);
64+
uint32_t PROPERTY(injected_days);
65+
uint32_t PROPERTY(days_without_input);
66+
uint8_t PROPERTY_RW_ACCESS(hiring_priority, public);
67+
68+
fixed_point_t get_profitability_yesterday() const {
69+
return daily_profit_history[profit_history_current];
70+
}
71+
72+
fixed_point_t get_average_profitability_last_seven_days() const {
73+
money_t sum = 0;
74+
75+
for (int i = 0; i <= profit_history_current; i++) {
76+
sum += daily_profit_history[i];
77+
}
78+
79+
return sum / (1 + profit_history_current);
80+
}
81+
};
82+
83+
class ResourceGatheringOpertion final : public NonArtisanalProducer {
84+
public:
85+
ResourceGatheringOpertion(ProductionType const& production_type, fixed_point_t size_multiplier);
86+
};
87+
}

0 commit comments

Comments
 (0)