Skip to content

Commit 6a80ee8

Browse files
committed
More condition execution callbacks
1 parent 0018971 commit 6a80ee8

File tree

10 files changed

+568
-136
lines changed

10 files changed

+568
-136
lines changed

src/openvic-simulation/country/CountryInstance.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,19 @@ void CountryInstance::_update_population() {
11401140
life_needs_fulfilled_by_strata /= population_by_strata;
11411141
everyday_needs_fulfilled_by_strata /= population_by_strata;
11421142
luxury_needs_fulfilled_by_strata /= population_by_strata;
1143+
1144+
unemployment_fraction = pop_type_unemployed_count.get_total() / total_population;
1145+
1146+
const fixed_point_map_const_iterator_t<Culture const*> largest_culture_it = get_largest_item(culture_distribution);
1147+
largest_culture = largest_culture_it != culture_distribution.end() ? largest_culture_it->first : nullptr;
1148+
1149+
const fixed_point_map_const_iterator_t<Religion const*> largest_religion_it = get_largest_item(religion_distribution);
1150+
largest_religion = largest_religion_it != religion_distribution.end() ? largest_religion_it->first : nullptr;
1151+
} else {
1152+
unemployment_fraction = fixed_point_t::_0();
1153+
1154+
largest_culture = nullptr;
1155+
largest_religion = nullptr;
11431156
}
11441157

11451158
daily_research_points = fixed_point_t::_0();
@@ -1186,9 +1199,16 @@ void CountryInstance::_update_military(
11861199
MilitaryDefines const& military_defines = define_manager.get_military_defines();
11871200

11881201
regiment_count = 0;
1202+
multi_unit_army_count = 0;
11891203

11901204
for (ArmyInstance const* army : armies) {
1191-
regiment_count += army->get_unit_count();
1205+
const size_t unit_count = army->get_unit_count();
1206+
1207+
regiment_count += unit_count;
1208+
1209+
if (unit_count > 1) {
1210+
multi_unit_army_count++;
1211+
}
11921212
}
11931213

11941214
ship_count = 0;

src/openvic-simulation/country/CountryInstance.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,15 @@ namespace OpenVic {
198198

199199
IndexedMap<PopType, pop_size_t> PROPERTY(pop_type_distribution);
200200
IndexedMap<PopType, pop_size_t> PROPERTY(pop_type_unemployed_count);
201+
fixed_point_t PROPERTY(unemployment_fraction);
201202
IndexedMap<Ideology, fixed_point_t> PROPERTY(ideology_distribution);
202203
fixed_point_map_t<Issue const*> PROPERTY(issue_distribution);
203204
IndexedMap<CountryParty, fixed_point_t> PROPERTY(vote_distribution);
204205
fixed_point_map_t<Culture const*> PROPERTY(culture_distribution);
205206
fixed_point_map_t<Religion const*> PROPERTY(religion_distribution);
207+
Culture const* PROPERTY(largest_culture, nullptr);
208+
Religion const* PROPERTY(largest_religion, nullptr);
209+
206210
size_t PROPERTY(national_focus_capacity, 0);
207211
// TODO - national foci
208212

@@ -265,6 +269,7 @@ namespace OpenVic {
265269
size_t PROPERTY(max_supported_regiment_count, 0);
266270
size_t PROPERTY(mobilisation_potential_regiment_count, 0);
267271
size_t PROPERTY(mobilisation_max_regiment_count, 0);
272+
size_t PROPERTY(multi_unit_army_count, 0);
268273
fixed_point_t PROPERTY(mobilisation_impact);
269274
fixed_point_t PROPERTY(mobilisation_economy_impact);
270275
fixed_point_t PROPERTY(supply_consumption);

src/openvic-simulation/map/ProvinceInstance.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,19 @@ void ProvinceInstance::_update_pops(InstanceManager const& instance_manager) {
332332
life_needs_fulfilled_by_strata /= population_by_strata;
333333
everyday_needs_fulfilled_by_strata /= population_by_strata;
334334
luxury_needs_fulfilled_by_strata /= population_by_strata;
335+
336+
unemployment_fraction = pop_type_unemployed_count.get_total() / total_population;
337+
338+
const fixed_point_map_const_iterator_t<Culture const*> largest_culture_it = get_largest_item(culture_distribution);
339+
largest_culture = largest_culture_it != culture_distribution.end() ? largest_culture_it->first : nullptr;
340+
341+
const fixed_point_map_const_iterator_t<Religion const*> largest_religion_it = get_largest_item(religion_distribution);
342+
largest_religion = largest_religion_it != religion_distribution.end() ? largest_religion_it->first : nullptr;
343+
} else {
344+
unemployment_fraction = fixed_point_t::_0();
345+
346+
largest_culture = nullptr;
347+
largest_religion = nullptr;
335348
}
336349
}
337350

src/openvic-simulation/map/ProvinceInstance.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,16 @@ namespace OpenVic {
123123

124124
IndexedMap<PopType, pop_size_t> PROPERTY(pop_type_distribution);
125125
IndexedMap<PopType, pop_size_t> PROPERTY(pop_type_unemployed_count);
126+
fixed_point_t PROPERTY(unemployment_fraction);
126127
IndexedMap<PopType, std::vector<Pop*>> PROPERTY(pops_cache_by_type);
127128
IndexedMap<Ideology, fixed_point_t> PROPERTY(ideology_distribution);
128129
fixed_point_map_t<Issue const*> PROPERTY(issue_distribution);
129130
IndexedMap<CountryParty, fixed_point_t> PROPERTY(vote_distribution);
130131
fixed_point_map_t<Culture const*> PROPERTY(culture_distribution);
131132
fixed_point_map_t<Religion const*> PROPERTY(religion_distribution);
133+
Culture const* PROPERTY(largest_culture, nullptr);
134+
Religion const* PROPERTY(largest_religion, nullptr);
135+
132136
size_t PROPERTY(max_supported_regiments, 0);
133137

134138
ProvinceInstance(

src/openvic-simulation/map/State.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,19 @@ void State::update_gamestate() {
156156
life_needs_fulfilled_by_strata /= population_by_strata;
157157
everyday_needs_fulfilled_by_strata /= population_by_strata;
158158
luxury_needs_fulfilled_by_strata /= population_by_strata;
159+
160+
unemployment_fraction = pop_type_unemployed_count.get_total() / total_population;
161+
162+
const fixed_point_map_const_iterator_t<Culture const*> largest_culture_it = get_largest_item(culture_distribution);
163+
largest_culture = largest_culture_it != culture_distribution.end() ? largest_culture_it->first : nullptr;
164+
165+
const fixed_point_map_const_iterator_t<Religion const*> largest_religion_it = get_largest_item(religion_distribution);
166+
largest_religion = largest_religion_it != religion_distribution.end() ? largest_religion_it->first : nullptr;
167+
} else {
168+
unemployment_fraction = fixed_point_t::_0();
169+
170+
largest_culture = nullptr;
171+
largest_religion = nullptr;
159172
}
160173

161174
// TODO - use actual values when State has factory data

src/openvic-simulation/map/State.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@ namespace OpenVic {
3838

3939
IndexedMap<PopType, pop_size_t> PROPERTY(pop_type_distribution);
4040
IndexedMap<PopType, pop_size_t> PROPERTY(pop_type_unemployed_count);
41+
fixed_point_t PROPERTY(unemployment_fraction);
4142
IndexedMap<PopType, std::vector<Pop*>> PROPERTY(pops_cache_by_type);
4243
IndexedMap<Ideology, fixed_point_t> PROPERTY(ideology_distribution);
4344
fixed_point_map_t<Issue const*> PROPERTY(issue_distribution);
4445
IndexedMap<CountryParty, fixed_point_t> PROPERTY(vote_distribution);
4546
fixed_point_map_t<Culture const*> PROPERTY(culture_distribution);
4647
fixed_point_map_t<Religion const*> PROPERTY(religion_distribution);
48+
Culture const* PROPERTY(largest_culture, nullptr);
49+
Religion const* PROPERTY(largest_religion, nullptr);
4750

4851
fixed_point_t PROPERTY(industrial_power);
4952

src/openvic-simulation/pop/Pop.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ void Pop::generate_political_distributions(InstanceManager const& instance_manag
131131
}
132132
}
133133
ideology_distribution.rescale(size);
134+
135+
issue_distribution.clear();
136+
for (auto const& [issue, conditional_weight] : type->get_issues()) {
137+
issue_distribution[issue] = conditional_weight.execute(instance_manager, this, this);
138+
}
139+
rescale_fixed_point_map(issue_distribution, size);
134140
}
135141

136142
bool Pop::convert_to_equivalent() {

0 commit comments

Comments
 (0)