-
Notifications
You must be signed in to change notification settings - Fork 8
Added producer types #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Added producer types #125
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #include "ArtisanalProducer.hpp" | ||
|
|
||
| using namespace OpenVic; | ||
|
|
||
| ArtisanalProducer::ArtisanalProducer( | ||
| ProductionType const& new_production_type, Good::good_map_t&& new_stockpile, const fixed_point_t new_current_production, | ||
| Good::good_map_t&& new_current_needs | ||
| ) | ||
| : production_type { new_production_type }, stockpile { std::move(new_stockpile) }, | ||
| current_production { new_current_production }, current_needs { std::move(new_current_needs) } {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #pragma once | ||
|
|
||
| #include "openvic-simulation/economy/Good.hpp" | ||
| #include "openvic-simulation/economy/ProductionType.hpp" | ||
| #include "openvic-simulation/types/fixed_point/FixedPoint.hpp" | ||
| #include "openvic-simulation/utility/Getters.hpp" | ||
|
|
||
| namespace OpenVic { | ||
| class ArtisanalProducer final { | ||
| private: | ||
| ProductionType const& PROPERTY(production_type); | ||
| Good::good_map_t PROPERTY(stockpile); | ||
| fixed_point_t PROPERTY(current_production); | ||
| Good::good_map_t PROPERTY(current_needs); | ||
|
|
||
| public: | ||
| ArtisanalProducer( | ||
| ProductionType const& new_production_type, Good::good_map_t&& new_stockpile, | ||
| const fixed_point_t new_current_production, Good::good_map_t&& new_current_needs | ||
| ); | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #include "FactoryProducer.hpp" | ||
|
|
||
| using namespace OpenVic; | ||
|
|
||
| FactoryProducer::FactoryProducer( | ||
| ProductionType const& new_production_type, const fixed_point_t new_size_multiplier, | ||
| const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday, | ||
| const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees, | ||
| Good::good_map_t&& new_stockpile, fixed_point_t new_budget, const fixed_point_t new_balance_yesterday, | ||
| const fixed_point_t new_received_investments_yesterday, const fixed_point_t new_market_spendings_yesterday, | ||
| const fixed_point_t new_paychecks_yesterday, const uint32_t new_unprofitable_days, const uint32_t new_subsidised_days, | ||
| const uint32_t new_days_without_input, const uint8_t new_hiring_priority, const uint8_t new_profit_history_current, | ||
| daily_profit_history_t&& new_daily_profit_history | ||
| ) | ||
| : production_type { new_production_type }, size_multiplier { new_size_multiplier }, | ||
| revenue_yesterday { new_revenue_yesterday }, output_quantity_yesterday { new_output_quantity_yesterday }, | ||
| unsold_quantity_yesterday { new_unsold_quantity_yesterday }, employees { std::move(new_employees) }, | ||
| stockpile { std::move(new_stockpile) }, budget { new_budget }, balance_yesterday { new_balance_yesterday }, | ||
| received_investments_yesterday { new_received_investments_yesterday }, | ||
| market_spendings_yesterday { new_market_spendings_yesterday }, paychecks_yesterday { new_paychecks_yesterday }, | ||
| unprofitable_days { new_unprofitable_days }, subsidised_days { new_subsidised_days }, | ||
| days_without_input { new_days_without_input }, hiring_priority { new_hiring_priority }, | ||
| profit_history_current { new_profit_history_current }, daily_profit_history { std::move(new_daily_profit_history) } {} | ||
| FactoryProducer::FactoryProducer(ProductionType const& new_production_type, const fixed_point_t new_size_multiplier) | ||
| : FactoryProducer { new_production_type, new_size_multiplier, 0, 0, 0, {}, {}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {} } {} | ||
|
|
||
| fixed_point_t FactoryProducer::get_profitability_yesterday() const { | ||
| return daily_profit_history[profit_history_current]; | ||
| } | ||
|
|
||
| fixed_point_t FactoryProducer::get_average_profitability_last_seven_days() const { | ||
| fixed_point_t sum = 0; | ||
|
|
||
| for (int i = 0; i <= profit_history_current; i++) { | ||
| sum += daily_profit_history[i]; | ||
| } | ||
|
|
||
| return sum / (1 + profit_history_current); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| #pragma once | ||
|
|
||
| #include <cstdint> | ||
|
|
||
| #include "openvic-simulation/economy/Good.hpp" | ||
| #include "openvic-simulation/economy/ProductionType.hpp" | ||
| #include "openvic-simulation/types/fixed_point/FixedPoint.hpp" | ||
| #include "openvic-simulation/utility/Getters.hpp" | ||
|
|
||
| namespace OpenVic { | ||
| class FactoryProducer final { | ||
| private: | ||
| static constexpr uint8_t DAYS_OF_HISTORY = 7; | ||
| using daily_profit_history_t = std::array<fixed_point_t, DAYS_OF_HISTORY>; | ||
|
|
||
| uint8_t PROPERTY(profit_history_current); | ||
| daily_profit_history_t PROPERTY(daily_profit_history); | ||
| ProductionType const& PROPERTY(production_type); | ||
| fixed_point_t PROPERTY(revenue_yesterday); | ||
| fixed_point_t PROPERTY(output_quantity_yesterday); | ||
| fixed_point_t PROPERTY(unsold_quantity_yesterday); | ||
| fixed_point_t PROPERTY(size_multiplier); | ||
| ordered_map<Pop*, Pop::pop_size_t> PROPERTY(employees); | ||
| Good::good_map_t PROPERTY(stockpile); | ||
| fixed_point_t PROPERTY(budget); | ||
| fixed_point_t PROPERTY(balance_yesterday); | ||
| fixed_point_t PROPERTY(received_investments_yesterday); | ||
| fixed_point_t PROPERTY(market_spendings_yesterday); | ||
| fixed_point_t PROPERTY(paychecks_yesterday); | ||
| uint32_t PROPERTY(unprofitable_days); | ||
| uint32_t PROPERTY(subsidised_days); | ||
| uint32_t PROPERTY(days_without_input); | ||
| uint8_t PROPERTY_RW(hiring_priority); | ||
|
|
||
| public: | ||
| FactoryProducer( | ||
| ProductionType const& new_production_type, const fixed_point_t new_size_multiplier, | ||
| const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday, | ||
| const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees, | ||
| Good::good_map_t&& new_stockpile, fixed_point_t new_budget, const fixed_point_t new_balance_yesterday, | ||
| const fixed_point_t new_received_investments_yesterday, const fixed_point_t new_market_spendings_yesterday, | ||
| const fixed_point_t new_paychecks_yesterday, const uint32_t new_unprofitable_days, | ||
| const uint32_t new_subsidised_days, const uint32_t new_days_without_input, const uint8_t new_hiring_priority, | ||
| const uint8_t new_profit_history_current, daily_profit_history_t&& new_daily_profit_history | ||
| ); | ||
| FactoryProducer(ProductionType const& new_production_type, const fixed_point_t new_size_multiplier); | ||
|
|
||
| fixed_point_t get_profitability_yesterday() const; | ||
| fixed_point_t get_average_profitability_last_seven_days() const; | ||
| }; | ||
| } | ||
16 changes: 16 additions & 0 deletions
16
src/openvic-simulation/economy/ResourceGatheringOperation.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #include "ResourceGatheringOperation.hpp" | ||
|
|
||
| using namespace OpenVic; | ||
|
|
||
| ResourceGatheringOperation::ResourceGatheringOperation( | ||
| ProductionType const& new_production_type, const fixed_point_t new_size_multiplier, | ||
| const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday, | ||
| const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees | ||
| ) | ||
| : production_type { new_production_type }, revenue_yesterday { new_revenue_yesterday }, | ||
| output_quantity_yesterday { new_output_quantity_yesterday }, unsold_quantity_yesterday { new_unsold_quantity_yesterday }, | ||
| size_multiplier { new_size_multiplier }, employees { std::move(new_employees) } {} | ||
| ResourceGatheringOperation::ResourceGatheringOperation( | ||
| ProductionType const& new_production_type, const fixed_point_t new_size_multiplier | ||
| ) | ||
| : ResourceGatheringOperation(new_production_type, new_size_multiplier, 0, 0, 0, {}) {} |
25 changes: 25 additions & 0 deletions
25
src/openvic-simulation/economy/ResourceGatheringOperation.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #pragma once | ||
|
|
||
| #include "openvic-simulation/economy/ProductionType.hpp" | ||
| #include "openvic-simulation/types/fixed_point/FixedPoint.hpp" | ||
| #include "openvic-simulation/utility/Getters.hpp" | ||
|
|
||
| namespace OpenVic { | ||
| class ResourceGatheringOperation final { | ||
| private: | ||
| ProductionType const& PROPERTY(production_type); | ||
| fixed_point_t PROPERTY(revenue_yesterday); | ||
| fixed_point_t PROPERTY(output_quantity_yesterday); | ||
| fixed_point_t PROPERTY(unsold_quantity_yesterday); | ||
| fixed_point_t PROPERTY(size_multiplier); | ||
| ordered_map<Pop*, Pop::pop_size_t> PROPERTY(employees); | ||
|
|
||
| public: | ||
| ResourceGatheringOperation( | ||
| ProductionType const& new_production_type, const fixed_point_t new_size_multiplier, | ||
| const fixed_point_t new_revenue_yesterday, const fixed_point_t new_output_quantity_yesterday, | ||
| const fixed_point_t new_unsold_quantity_yesterday, ordered_map<Pop*, Pop::pop_size_t>&& new_employees | ||
| ); | ||
| ResourceGatheringOperation(ProductionType const& new_production_type, const fixed_point_t new_size_multiplier); | ||
| }; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.