|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <cstddef> |
| 4 | +#include <cstdint> |
| 5 | +#include <map> |
| 6 | + |
| 7 | +#include "openvic-simulation/economy/Good.hpp" |
| 8 | +#include "openvic-simulation/economy/ProductionType.hpp" |
| 9 | +#include "openvic-simulation/types/fixed_point/FixedPoint.hpp" |
| 10 | +#include "openvic-simulation/utility/Getters.hpp" |
| 11 | + |
| 12 | +using money_t = OpenVic::fixed_point_t; |
| 13 | +using good_quantity_t = OpenVic::fixed_point_t; |
| 14 | + |
| 15 | +namespace OpenVic { |
| 16 | + class Producer { |
| 17 | + public: |
| 18 | + ProductionType PROPERTY(production_type) |
| 19 | + }; |
| 20 | + |
| 21 | + class Manufacturer : Producer { |
| 22 | + public: |
| 23 | + Good::good_map_t PROPERTY(stockpile); |
| 24 | + }; |
| 25 | + |
| 26 | + class ArtisanalProducer final : Manufacturer { |
| 27 | + public: |
| 28 | + good_quantity_t PROPERTY(current_production); |
| 29 | + Good::good_map_t PROPERTY(current_needs); |
| 30 | + }; |
| 31 | + |
| 32 | + class NonArtisanalProducer : Producer { |
| 33 | + private: |
| 34 | + Pop::pop_size_t get_max_workforce_size() { |
| 35 | + return static_cast<Pop::pop_size_t>( |
| 36 | + static_cast<fixed_point_t>(production_type.get_base_workforce_size()) * size_multiplier |
| 37 | + ); |
| 38 | + } |
| 39 | + |
| 40 | + public: |
| 41 | + money_t PROPERTY(revenue_yesterday); |
| 42 | + good_quantity_t PROPERTY(output_quantity_yesterday); |
| 43 | + good_quantity_t PROPERTY(unsold_quantity_yesterday); |
| 44 | + fixed_point_t PROPERTY(size_multiplier); |
| 45 | + std::map<Pop const*, Pop::pop_size_t> PROPERTY(employees) |
| 46 | + }; |
| 47 | + |
| 48 | + class FactoryProducer final : NonArtisanalProducer, Manufacturer { |
| 49 | + private: |
| 50 | + int PROPERTY(profit_history_current); |
| 51 | + money_t[7] PROPERTY(daily_profit_history); |
| 52 | + |
| 53 | + fixed_point_t get_max_budget() { |
| 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 | + std::byte PROPERTY_RW_ACCESS(hiring_priority, public); |
| 67 | + |
| 68 | + fixed_point_t get_profitability_yesterday() { |
| 69 | + return daily_profit_history[profit_history_current]; |
| 70 | + } |
| 71 | + |
| 72 | + fixed_point_t get_average_profitability_last_seven_days() { |
| 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 : NonArtisanalProducer { |
| 84 | + ResourceGatheringOpertion(const ProductionType production_type, const fixed_point_t size_multiplier); |
| 85 | + }; |
| 86 | +} |
0 commit comments