-
Notifications
You must be signed in to change notification settings - Fork 8
Government salaries and social income #363
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,53 @@ | ||
#include "SharedCountryValues.hpp" | ||
|
||
#include "openvic-simulation/defines/PopsDefines.hpp" | ||
#include "openvic-simulation/economy/GoodInstance.hpp" | ||
#include "openvic-simulation/pop/PopNeedsMacro.hpp" | ||
#include "openvic-simulation/pop/PopType.hpp" | ||
#include "openvic-simulation/types/IndexedMap.hpp" | ||
|
||
using namespace OpenVic; | ||
|
||
SharedCountryValues::SharedCountryValues( | ||
ModifierEffectCache const& new_modifier_effect_cache, | ||
CountryDefines const& new_country_defines, | ||
PopsDefines const& new_pop_defines, | ||
decltype(shared_pop_type_values)::keys_type const& pop_type_keys | ||
) : modifier_effect_cache { new_modifier_effect_cache }, | ||
country_defines { new_country_defines }, | ||
pop_defines { new_pop_defines }, | ||
shared_pop_type_values { &pop_type_keys } | ||
{} | ||
|
||
void SharedCountryValues::update_costs(GoodInstanceManager const& good_instance_manager) { | ||
for (auto [pop_type, value] : shared_pop_type_values) { | ||
value.update_costs(pop_type, pop_defines, good_instance_manager); | ||
} | ||
} | ||
|
||
void SharedPopTypeValues::update_costs(PopType const& pop_type, PopsDefines const& pop_defines, GoodInstanceManager const& good_instance_manager) { | ||
administration_salary_base = education_salary_base = military_salary_base = fixed_point_t::_0(); | ||
using enum PopType::income_type_t; | ||
|
||
#define UPDATE_NEED_COSTS(need_category) \ | ||
base_##need_category##_need_costs = fixed_point_t::_0(); \ | ||
for (auto const& [good_definition_ptr, quantity] : pop_type.get_##need_category##_needs()) { \ | ||
GoodInstance const& good_instance = good_instance_manager.get_good_instance_from_definition(*good_definition_ptr); \ | ||
base_##need_category##_need_costs += good_instance.get_price() * quantity; \ | ||
} \ | ||
base_##need_category##_need_costs *= pop_defines.get_base_goods_demand(); \ | ||
if ((pop_type.get_##need_category##_needs_income_types() & ADMINISTRATION) == ADMINISTRATION) { \ | ||
administration_salary_base += base_##need_category##_need_costs; \ | ||
} \ | ||
if ((pop_type.get_##need_category##_needs_income_types() & EDUCATION) == EDUCATION) { \ | ||
education_salary_base += base_##need_category##_need_costs; \ | ||
} \ | ||
if ((pop_type.get_##need_category##_needs_income_types() & MILITARY) == MILITARY) { \ | ||
military_salary_base += base_##need_category##_need_costs; \ | ||
} | ||
wvpm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
DO_FOR_ALL_NEED_CATEGORIES(UPDATE_NEED_COSTS) | ||
#undef UPDATE_NEED_COSTS | ||
} | ||
|
||
#undef DO_FOR_ALL_NEED_CATEGORIES |
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,53 @@ | ||
#pragma once | ||
|
||
#include "openvic-simulation/pop/PopNeedsMacro.hpp" | ||
#include "openvic-simulation/types/IndexedMap.hpp" | ||
#include "openvic-simulation/types/fixed_point/FixedPoint.hpp" | ||
#include "openvic-simulation/utility/Getters.hpp" | ||
|
||
namespace OpenVic { | ||
struct CountryDefines; | ||
struct GoodInstanceManager; | ||
struct ModifierEffectCache; | ||
struct PopsDefines; | ||
struct PopType; | ||
|
||
struct SharedPopTypeValues { | ||
private: | ||
#define NEED_COST_FIELD(need_category) \ | ||
fixed_point_t base_##need_category##_need_costs; | ||
DO_FOR_ALL_NEED_CATEGORIES(NEED_COST_FIELD) | ||
#undef NEED_COST_FIELD | ||
|
||
fixed_point_t PROPERTY(administration_salary_base); | ||
fixed_point_t PROPERTY(education_salary_base); | ||
fixed_point_t PROPERTY(military_salary_base); | ||
|
||
public: | ||
void update_costs(PopType const& pop_type, PopsDefines const& pop_defines, GoodInstanceManager const& good_instance_manager); | ||
constexpr fixed_point_t get_social_income_variant_base() const { | ||
return 2 * base_life_need_costs; | ||
} | ||
}; | ||
|
||
struct SharedCountryValues { | ||
private: | ||
ModifierEffectCache const& PROPERTY(modifier_effect_cache); | ||
CountryDefines const& PROPERTY(country_defines); | ||
PopsDefines const& pop_defines; | ||
IndexedMap<PopType, SharedPopTypeValues> PROPERTY(shared_pop_type_values); | ||
|
||
public: | ||
SharedCountryValues( | ||
wvpm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ModifierEffectCache const& new_modifier_effect_cache, | ||
CountryDefines const& new_country_defines, | ||
PopsDefines const& new_pop_defines, | ||
decltype(shared_pop_type_values)::keys_type const& pop_type_keys | ||
); | ||
SharedCountryValues(SharedCountryValues&&) = default; | ||
|
||
void update_costs(GoodInstanceManager const& good_instance_manager); | ||
}; | ||
} | ||
|
||
#undef DO_FOR_ALL_NEED_CATEGORIES |
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
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
Oops, something went wrong.
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.