Skip to content

Commit 4a5ed35

Browse files
committed
Added producer types
1 parent b578311 commit 4a5ed35

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
namespace OpenVic {
12+
using money_t = OpenVic::fixed_point_t;
13+
using good_quantity_t = OpenVic::fixed_point_t;
14+
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+
public:
33+
money_t PROPERTY(revenue_yesterday);
34+
good_quantity_t PROPERTY(output_quantity_yesterday);
35+
good_quantity_t PROPERTY(unsold_quantity_yesterday);
36+
fixed_point_t PROPERTY(size_multiplier);
37+
ordered_map<Pop const*, Pop::pop_size_t> PROPERTY(employees);
38+
};
39+
40+
class FactoryProducer final : public NonArtisanalProducer, public Manufacturer {
41+
private:
42+
static constexpr size_t days_of_history = 7;
43+
int PROPERTY(profit_history_current);
44+
std::array<money_t, days_of_history> PROPERTY(daily_profit_history);
45+
46+
public:
47+
money_t PROPERTY(budget);
48+
money_t PROPERTY(balance_yesterday);
49+
money_t PROPERTY(received_investments_yesterday);
50+
money_t PROPERTY(market_spendings_yesterday);
51+
money_t PROPERTY(paychecks_yesterday);
52+
uint32_t PROPERTY(unprofitable_days);
53+
uint32_t PROPERTY(injected_days);
54+
uint32_t PROPERTY(days_without_input);
55+
uint8_t PROPERTY_RW_ACCESS(hiring_priority, public);
56+
57+
fixed_point_t get_profitability_yesterday() const {
58+
return daily_profit_history[profit_history_current];
59+
}
60+
61+
fixed_point_t get_average_profitability_last_seven_days() const {
62+
money_t sum = 0;
63+
64+
for (int i = 0; i <= profit_history_current; i++) {
65+
sum += daily_profit_history[i];
66+
}
67+
68+
return sum / (1 + profit_history_current);
69+
}
70+
};
71+
72+
class ResourceGatheringOpertion final : public NonArtisanalProducer {
73+
public:
74+
ResourceGatheringOpertion(ProductionType const& production_type, fixed_point_t size_multiplier);
75+
};
76+
}

0 commit comments

Comments
 (0)