Skip to content

Commit 4e30654

Browse files
committed
More condition execution callbacks
1 parent 09de8f1 commit 4e30654

File tree

10 files changed

+569
-137
lines changed

10 files changed

+569
-137
lines changed

src/openvic-simulation/country/CountryInstance.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,19 @@ void CountryInstance::_update_population() {
12231223
life_needs_fulfilled_by_strata /= population_by_strata;
12241224
everyday_needs_fulfilled_by_strata /= population_by_strata;
12251225
luxury_needs_fulfilled_by_strata /= population_by_strata;
1226+
1227+
unemployment_fraction = pop_type_unemployed_count.get_total() / total_population;
1228+
1229+
const fixed_point_map_const_iterator_t<Culture const*> largest_culture_it = get_largest_item(culture_distribution);
1230+
largest_culture = largest_culture_it != culture_distribution.end() ? largest_culture_it->first : nullptr;
1231+
1232+
const fixed_point_map_const_iterator_t<Religion const*> largest_religion_it = get_largest_item(religion_distribution);
1233+
largest_religion = largest_religion_it != religion_distribution.end() ? largest_religion_it->first : nullptr;
1234+
} else {
1235+
unemployment_fraction = fixed_point_t::_0();
1236+
1237+
largest_culture = nullptr;
1238+
largest_religion = nullptr;
12261239
}
12271240

12281241
daily_research_points = fixed_point_t::_0();
@@ -1269,9 +1282,16 @@ void CountryInstance::_update_military(
12691282
MilitaryDefines const& military_defines = define_manager.get_military_defines();
12701283

12711284
regiment_count = 0;
1285+
multi_unit_army_count = 0;
12721286

12731287
for (ArmyInstance const* army : armies) {
1274-
regiment_count += army->get_unit_count();
1288+
const size_t unit_count = army->get_unit_count();
1289+
1290+
regiment_count += unit_count;
1291+
1292+
if (unit_count > 1) {
1293+
multi_unit_army_count++;
1294+
}
12751295
}
12761296

12771297
ship_count = 0;

src/openvic-simulation/country/CountryInstance.hpp

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

229229
IndexedMap<PopType, pop_size_t> PROPERTY(pop_type_distribution);
230230
IndexedMap<PopType, pop_size_t> PROPERTY(pop_type_unemployed_count);
231+
fixed_point_t PROPERTY(unemployment_fraction);
231232
IndexedMap<Ideology, fixed_point_t> PROPERTY(ideology_distribution);
232233
fixed_point_map_t<Issue const*> PROPERTY(issue_distribution);
233234
IndexedMap<CountryParty, fixed_point_t> PROPERTY(vote_distribution);
234235
fixed_point_map_t<Culture const*> PROPERTY(culture_distribution);
235236
fixed_point_map_t<Religion const*> PROPERTY(religion_distribution);
237+
Culture const* PROPERTY(largest_culture, nullptr);
238+
Religion const* PROPERTY(largest_religion, nullptr);
239+
236240
size_t PROPERTY(national_focus_capacity, 0);
237241
// TODO - national foci
238242

@@ -295,6 +299,7 @@ namespace OpenVic {
295299
size_t PROPERTY(max_supported_regiment_count, 0);
296300
size_t PROPERTY(mobilisation_potential_regiment_count, 0);
297301
size_t PROPERTY(mobilisation_max_regiment_count, 0);
302+
size_t PROPERTY(multi_unit_army_count, 0);
298303
fixed_point_t PROPERTY(mobilisation_impact);
299304
fixed_point_t PROPERTY(mobilisation_economy_impact);
300305
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
@@ -130,6 +130,12 @@ void Pop::generate_political_distributions(InstanceManager const& instance_manag
130130
}
131131
}
132132
ideology_distribution.rescale(size);
133+
134+
issue_distribution.clear();
135+
for (auto const& [issue, conditional_weight] : type->get_issues()) {
136+
issue_distribution[issue] = conditional_weight.execute(instance_manager, this, this);
137+
}
138+
rescale_fixed_point_map(issue_distribution, size);
133139
}
134140

135141
bool Pop::convert_to_equivalent() {

0 commit comments

Comments
 (0)