Skip to content

Commit e98cd1f

Browse files
committed
Added producer types
1 parent be24f8d commit e98cd1f

File tree

6 files changed

+164
-0
lines changed

6 files changed

+164
-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 { new_stockpile }, current_production { new_current_production },
10+
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_injected_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 }, injected_days { new_injected_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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
uint8_t PROPERTY(profit_history_current);
15+
std::array<fixed_point_t, DAYS_OF_HISTORY> PROPERTY(daily_profit_history);
16+
ProductionType const& PROPERTY(production_type);
17+
fixed_point_t PROPERTY(revenue_yesterday);
18+
fixed_point_t PROPERTY(output_quantity_yesterday);
19+
fixed_point_t PROPERTY(unsold_quantity_yesterday);
20+
fixed_point_t PROPERTY(size_multiplier);
21+
ordered_map<Pop*, Pop::pop_size_t> PROPERTY(employees);
22+
Good::good_map_t PROPERTY(stockpile);
23+
fixed_point_t PROPERTY(budget);
24+
fixed_point_t PROPERTY(balance_yesterday);
25+
fixed_point_t PROPERTY(received_investments_yesterday);
26+
fixed_point_t PROPERTY(market_spendings_yesterday);
27+
fixed_point_t PROPERTY(paychecks_yesterday);
28+
uint32_t PROPERTY(unprofitable_days);
29+
uint32_t PROPERTY(injected_days);
30+
uint32_t PROPERTY(days_without_input);
31+
uint8_t PROPERTY_RW(hiring_priority);
32+
33+
public:
34+
FactoryProducer(
35+
ProductionType const& new_production_type, const fixed_point_t new_size_multiplier,
36+
const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday,
37+
const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees,
38+
Good::good_map_t&& new_stockpile, fixed_point_t new_budget, const fixed_point_t new_balance_yesterday,
39+
const fixed_point_t new_received_investments_yesterday, const fixed_point_t new_market_spendings_yesterday,
40+
const fixed_point_t new_paychecks_yesterday, const uint32_t new_unprofitable_days, const uint32_t new_injected_days,
41+
const uint32_t new_days_without_input, const uint8_t new_hiring_priority, const uint8_t new_profit_history_current,
42+
std::array<fixed_point_t, DAYS_OF_HISTORY>&& new_d
43+
);
44+
FactoryProducer(ProductionType const& new_production_type, const fixed_point_t new_size_multiplier);
45+
46+
fixed_point_t get_profitability_yesterday() const;
47+
fixed_point_t get_average_profitability_last_seven_days() const;
48+
};
49+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include "ResourceGatheringOpertion.hpp"
2+
3+
#include <utility>
4+
5+
6+
using namespace OpenVic;
7+
8+
ResourceGatheringOpertion::ResourceGatheringOpertion(
9+
ProductionType const& new_production_type, const fixed_point_t new_size_multiplier,
10+
const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday,
11+
const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees
12+
)
13+
: production_type { new_production_type }, revenue_yesterday { new_revenue_yesterday },
14+
output_quantity_yesterday { new_output_quantity_yesterday }, unsold_quantity_yesterday { new_unsold_quantity_yesterday },
15+
size_multiplier { new_size_multiplier }, employees { std::move(new_employees) } {}
16+
ResourceGatheringOpertion::ResourceGatheringOpertion(
17+
ProductionType const& new_production_type, const fixed_point_t new_size_multiplier
18+
)
19+
: ResourceGatheringOpertion(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 ResourceGatheringOpertion 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+
ResourceGatheringOpertion(
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+
ResourceGatheringOpertion(ProductionType const& new_production_type, const fixed_point_t new_size_multiplier);
24+
};
25+
}

0 commit comments

Comments
 (0)