2#include "dcon_generated.hpp"
13 state.world.for_each_province([&](dcon::province_id
province) {
14 if(nation == state.world.province_get_nation_from_province_ownership(
province)) {
15 for(auto pop_loc : state.world.province_get_pop_location(province)) {
16 auto pop_id = pop_loc.get_pop();
17 total += pop_vote_weight(state, pop_id, nation);
30 return state.world.nation_get_demographics(nation, dkey) / total;
41 for(
auto province : state.world.nation_get_province_ownership(nation)) {
42 for(
auto pop_loc :
province.get_province().get_pop_location()) {
43 auto pop_id = pop_loc.get_pop();
45 support += vote_size * state.world.pop_get_demographics(pop_id.id, dkey);
48 return support / total;
52 return dcon::fatten(state.world, nation).get_government_type().get_can_appoint_ruling_party();
56 auto election_end_date =
dcon::fatten(state.world, nation).get_election_ends();
57 return election_end_date && election_end_date > state.current_date;
61 return dcon::fatten(state.world, nation).get_government_type().get_has_elections();
65 auto end_date = state.world.nation_get_election_ends(nation);
66 return end_date + int32_t(30.5f * state.world.nation_get_government_type(nation).get_duration());
70 dcon::reform_id result{};
71 auto it = state.lookup_key(name);
73 state.world.for_each_reform([&](dcon::reform_id reform_id) {
74 auto key = state.world.reform_get_name(reform_id);
84 dcon::issue_id result{};
85 auto it = state.lookup_key(name);
87 state.world.for_each_issue([&](dcon::issue_id issue_id) {
88 auto key = state.world.issue_get_name(issue_id);
98 auto reform = state.world.reform_option_get_parent_reform(reform_option);
99 return reform && reform_option == state.world.nation_get_reforms(nation, reform);
103 auto issue = state.world.issue_option_get_parent_issue(issue_option);
104 return issue && issue_option == state.world.nation_get_issues(nation, issue);
111 auto issue = state.world.issue_option_get_parent_issue(issue_option);
112 auto current = state.world.nation_get_issues(nation, issue.id).id;
113 auto allow = state.world.issue_option_get_allow(issue_option);
114 auto time_limit = state.world.nation_get_last_issue_or_reform_change(nation);
115 auto tag = state.world.nation_get_identity_from_identity_holder(nation);
116 auto start = state.world.national_identity_get_political_party_first(tag).id.index();
117 auto end = start + state.world.national_identity_get_political_party_count(tag);
118 auto count_party_issues = state.world.political_party_get_party_issues_size();
120 if(current != issue_option && (!time_limit || (time_limit + int32_t(state.defines.min_delay_between_reforms * 30) <= state.current_date)) &&
121 (!state.world.issue_get_is_next_step_only(issue.id) || current.index() + 1 == issue_option.index() ||
122 current.index() - 1 == issue_option.index()) &&
126 for(
uint32_t icounter = state.world.ideology_size(); icounter-- > 0;) {
127 dcon::ideology_id iid{dcon::ideology_id::value_base_t(icounter)};
128 auto condition = issue_option.index() > current.index() ? state.world.ideology_get_add_political_reform(iid) : state.world.ideology_get_remove_political_reform(iid);
129 auto upperhouse_weight = 0.01f * state.world.nation_get_upper_house(nation, iid);
131 float party_special_issues_support_total = 0.0f;
132 float count_found = 0.0f;
134 for(int32_t i = start; i < end; i++) {
135 auto pid = dcon::political_party_id(dcon::political_party_id::value_base_t(i));
137 && (state.world.nation_get_government_type(nation).get_ideologies_allowed() &
culture::to_bits(state.world.political_party_get_ideology(pid))) != 0
138 && state.world.political_party_get_ideology(pid) == iid) {
140 for(
uint32_t j = 0; j < count_party_issues; ++j) {
141 auto popt = state.world.political_party_get_party_issues(pid, dcon::issue_id{ dcon::issue_id::value_base_t(j) });
142 auto opt_mod = state.world.issue_option_get_support_modifiers(popt, issue_option);
154 if(count_found > 0.0f)
155 total += std::clamp(party_special_issues_support_total / count_found, -1.0f, 1.0f);
156 else if(condition && upperhouse_weight > 0.0f)
169 auto issue = state.world.issue_option_get_parent_issue(o);
170 auto current = state.world.nation_get_issues(n, issue.id).id;
171 auto allow = state.world.issue_option_get_allow(o);
172 auto time_limit = state.world.nation_get_last_issue_or_reform_change(n);
173 auto tag = state.world.nation_get_identity_from_identity_holder(n);
174 auto start = state.world.national_identity_get_political_party_first(tag).id.index();
175 auto end = start + state.world.national_identity_get_political_party_count(tag);
176 auto count_party_issues = state.world.political_party_get_party_issues_size();
178 if(current != o && (!time_limit || (time_limit + int32_t(state.defines.min_delay_between_reforms * 30) <= state.current_date)) &&
179 (!state.world.issue_get_is_next_step_only(issue.id) || current.index() + 1 == o.index() ||
180 current.index() - 1 == o.index()) &&
184 for(
uint32_t icounter = state.world.ideology_size(); icounter-- > 0;) {
185 dcon::ideology_id iid{dcon::ideology_id::value_base_t(icounter)};
186 auto condition = o.index() > current.index() ? state.world.ideology_get_add_social_reform(iid) : state.world.ideology_get_remove_social_reform(iid);
187 auto upperhouse_weight = 0.01f * state.world.nation_get_upper_house(n, iid);
189 float party_special_issues_support_total = 0.0f;
190 float count_found = 0.0f;
192 for(int32_t i = start; i < end; i++) {
193 auto pid = dcon::political_party_id(dcon::political_party_id::value_base_t(i));
195 && (state.world.nation_get_government_type(n).get_ideologies_allowed() &
culture::to_bits(state.world.political_party_get_ideology(pid))) != 0
196 && state.world.political_party_get_ideology(pid) == iid) {
198 for(
uint32_t j = 0; j < count_party_issues; ++j) {
199 auto popt = state.world.political_party_get_party_issues(pid, dcon::issue_id{ dcon::issue_id::value_base_t(j) });
200 auto opt_mod = state.world.issue_option_get_support_modifiers(popt, o);
212 if(count_found > 0.0f)
213 total += std::clamp(party_special_issues_support_total / count_found, -1.0f, 1.0f);
214 else if(condition && upperhouse_weight > 0.0f)
227 auto reform = state.world.reform_option_get_parent_reform(o);
228 auto current = state.world.nation_get_reforms(n, reform.id).id;
229 auto allow = state.world.reform_option_get_allow(o);
230 auto stored_rp = state.world.nation_get_research_points(n);
231 if(o.index() > current.index() && (!state.world.reform_get_is_next_step_only(reform.id) || current.index() + 1 == o.index()) &&
234 float base_cost = float(state.world.reform_option_get_technology_cost(o));
237 if(base_cost * reform_factor <= stored_rp)
247 auto reform = state.world.reform_option_get_parent_reform(o);
248 auto current = state.world.nation_get_reforms(n, reform.id).id;
249 auto allow = state.world.reform_option_get_allow(o);
250 auto stored_rp = state.world.nation_get_research_points(n);
251 if(o.index() > current.index() && (!state.world.reform_get_is_next_step_only(reform.id) || current.index() + 1 == o.index()) &&
254 float base_cost = float(state.world.reform_option_get_technology_cost(o));
257 if(base_cost * reform_factor <= stored_rp)
264 float reform_factor = 1.0f +
265 state.world.nation_get_modifier_values(n, sys::national_mod_offsets::self_unciv_military_modifier) +
266 state.world.nation_get_modifier_values(state.world.nation_get_in_sphere_of(n), sys::national_mod_offsets::unciv_military_modifier);
268 for(
uint32_t icounter = state.world.ideology_size(); icounter-- > 0;) {
269 dcon::ideology_id iid{dcon::ideology_id::value_base_t(icounter)};
270 auto condition = state.world.ideology_get_add_military_reform(iid);
271 auto upperhouse_weight = 0.01f * state.world.nation_get_upper_house(n, iid);
272 if(condition && upperhouse_weight > 0.0f)
275 return reform_factor;
279 float reform_factor = 1.0f +
280 state.world.nation_get_modifier_values(n, sys::national_mod_offsets::self_unciv_economic_modifier) +
281 state.world.nation_get_modifier_values(state.world.nation_get_in_sphere_of(n), sys::national_mod_offsets::unciv_economic_modifier);
283 for(
uint32_t icounter = state.world.ideology_size(); icounter-- > 0;) {
284 dcon::ideology_id iid{dcon::ideology_id::value_base_t(icounter)};
285 auto condition = state.world.ideology_get_add_economic_reform(iid);
286 auto upperhouse_weight = 0.01f * state.world.nation_get_upper_house(n, iid);
287 if(condition && upperhouse_weight > 0.0f)
290 return reform_factor;
294 auto start_date = state.world.political_party_get_start_date(p);
295 auto end_date = state.world.political_party_get_end_date(p);
296 bool b = (!start_date || start_date <= state.current_date) && (!end_date || end_date > state.current_date);
297 if(
auto k = state.world.political_party_get_trigger(p); b && k) {
304 state.world.nation_set_ruling_party(n, p);
305 for(
auto pi : state.culture_definitions.party_issues) {
306 state.world.nation_set_issues(n, pi, state.world.political_party_get_party_issues(p, pi));
312 for(
auto po : state.world.nation_get_province_ownership_as_nation(n)) {
313 for(
auto fl : po.get_province().get_factory_location()) {
321 auto tag = state.world.nation_get_identity_from_identity_holder(n);
322 auto start = state.world.national_identity_get_political_party_first(tag).id.index();
323 auto end = start + state.world.national_identity_get_political_party_count(tag);
325 for(int32_t i = start; i < end; i++) {
326 auto pid = dcon::political_party_id(dcon::political_party_id::value_base_t(i));
335 int32_t reform_totals = 0;
336 for(
auto preform : state.culture_definitions.political_issues) {
337 auto creform = state.world.nation_get_issues(n, preform);
338 auto base_reform = state.world.issue_get_options(preform)[0];
339 reform_totals += creform.id.index() - base_reform.index();
341 for(
auto preform : state.culture_definitions.social_issues) {
342 auto creform = state.world.nation_get_issues(n, preform);
343 auto base_reform = state.world.issue_get_options(preform)[0];
344 reform_totals += creform.id.index() - base_reform.index();
347 auto angry_value = (0.1f * float(reform_totals) + 1.0f) * state.defines.ruling_party_angry_change;
348 auto happy_value = state.defines.ruling_party_happy_change;
357 auto old_party = state.world.nation_get_ruling_party(n);
359 for(
auto pa_id : state.culture_definitions.party_issues) {
360 auto new_id = state.world.political_party_get_party_issues(p, pa_id);
361 auto old_id = state.world.political_party_get_party_issues(old_party, pa_id);
363 if(new_id != old_id) {
364 for(
auto pr : state.world.nation_get_province_ownership(n)) {
365 for(
auto pop : pr.get_province().get_pop_location()) {
366 auto base_mil = pop.get_pop().get_militancy();
369 pop.get_pop().set_militancy(adj_mil);
375 auto new_id = state.world.political_party_get_ideology(p);
376 auto old_id = state.world.political_party_get_ideology(old_party);
378 if(new_id != old_id) {
379 for(
auto pr : state.world.nation_get_province_ownership(n)) {
380 for(
auto pop : pr.get_province().get_pop_location()) {
381 auto base_mil = pop.get_pop().get_militancy();
384 pop.get_pop().set_militancy(std::clamp(adj_mil, 0.0f, 10.0f));
390 state.world.nation_set_ruling_party_last_appointed(n, state.current_date);
395 state.world.for_each_ideology([&](
auto iid) { state.world.nation_set_upper_house(n, iid, 0.0f); });
396 state.world.nation_set_upper_house(n,
id, 100.0f);
402 auto ident = state.world.nation_get_identity_from_identity_holder(
id);
403 auto gov_id = state.world.nation_get_government_type(
id);
404 assert(!gov_id || state.world.government_type_is_valid(gov_id));
406 state.world.nation_set_color(
id, state.world.national_identity_get_government_color(
ident, gov_id));
408 state.world.nation_set_color(
id, state.world.national_identity_get_color(
ident));
410 state.province_ownership_changed.store(
true, std::memory_order::release);
414 auto old_gov = state.world.nation_get_government_type(n);
415 if(old_gov != new_type) {
416 assert(state.world.government_type_is_valid(new_type));
417 state.world.nation_set_government_type(n, new_type);
419 if((state.world.government_type_get_ideologies_allowed(new_type) &
420 culture::to_bits(state.world.nation_get_ruling_party(n).get_ideology())) == 0) {
422 auto tag = state.world.nation_get_identity_from_identity_holder(n);
423 auto start = state.world.national_identity_get_political_party_first(tag).id.index();
424 auto end = start + state.world.national_identity_get_political_party_count(tag);
426 for(int32_t i = start; i < end; i++) {
427 auto pid = dcon::political_party_id(dcon::political_party_id::value_base_t(i));
429 (state.world.government_type_get_ideologies_allowed(new_type) &
441 state.world.nation_set_election_ends(n,
sys::date{});
459 auto type = state.world.pop_get_poptype(p);
460 if(state.world.pop_type_get_voting_forbidden(type))
463 auto size = state.world.pop_get_size(p);
468 return std::max(0.0f, state.world.nation_get_modifier_values(n, sys::national_mod_offsets::poor_vote));
470 return std::max(0.0f, state.world.nation_get_modifier_values(n, sys::national_mod_offsets::middle_vote));
472 return std::max(0.0f, state.world.nation_get_modifier_values(n, sys::national_mod_offsets::rich_vote));
478 auto rules = state.world.nation_get_combined_issue_rules(n);
480 if(state.world.pop_get_culture(p) == state.world.nation_get_primary_culture(n))
482 else if(state.world.pop_get_is_primary_or_accepted_culture(p))
483 return size * vmod * 0.5f;
487 if(state.world.pop_get_is_primary_or_accepted_culture(p))
506 static std::vector<float> accumulated_in_state;
507 accumulated_in_state.resize(state.world.ideology_size());
509 auto rules = state.world.nation_get_combined_issue_rules(n);
510 auto allowed_ideo = state.world.nation_get_government_type(n).get_ideologies_allowed();
514 auto rp_ideology = state.world.political_party_get_ideology(state.world.nation_get_ruling_party(n));
515 for(
auto i : state.world.in_ideology) {
516 state.world.nation_set_upper_house(n, i, 0.0f);
519 state.world.nation_set_upper_house(n, rp_ideology, 100.0f);
521 for(
auto i : state.world.in_ideology) {
522 state.world.nation_set_upper_house(n, i, 0.0f);
524 float state_total = 0.0f;
526 for(
auto si : state.world.nation_get_state_ownership(n)) {
527 if(si.get_state().get_capital().get_is_colonial())
530 for(
auto i : state.world.in_ideology) {
531 accumulated_in_state[i.id.index()] = 0.0f;
535 for(auto pop : state.world.province_get_pop_location(p)) {
536 auto weight = pop_vote_weight(state, pop.get_pop(), n);
538 for(auto i : state.world.in_ideology) {
539 if((allowed_ideo & culture::to_bits(i)) != 0)
540 accumulated_in_state[i.id.index()] +=
541 weight * state.world.pop_get_demographics(pop.get_pop(), pop_demographics::to_key(state, i));
547 for(
auto i : state.world.in_ideology) {
548 total += accumulated_in_state[i.id.index()];
551 for(
auto i : state.world.in_ideology) {
552 auto scaled = accumulated_in_state[i.id.index()] / total;
553 state_total += scaled;
554 state.world.nation_get_upper_house(n, i) += scaled;
559 if(state_total > 0) {
560 auto scale_factor = 100.0f / state_total;
561 for(
auto i : state.world.in_ideology) {
562 state.world.nation_get_upper_house(n, i) *= scale_factor;
565 auto rp_ideology = state.world.political_party_get_ideology(state.world.nation_get_ruling_party(n));
566 for(
auto i : state.world.in_ideology) {
567 state.world.nation_set_upper_house(n, i, 0.0f);
570 state.world.nation_set_upper_house(n, rp_ideology, 100.0f);
573 for(
auto i : state.world.in_ideology) {
574 state.world.nation_set_upper_house(n, i, 0.0f);
576 for(
auto p :
state.world.nation_get_province_ownership(n)) {
577 if(p.get_province().get_is_colonial())
580 for(
auto pop :
state.world.province_get_pop_location(p.get_province())) {
584 for(
auto i :
state.world.in_ideology) {
593 for(
auto i :
state.world.in_ideology) {
594 total +=
state.world.nation_get_upper_house(n, i);
597 auto scale_factor = 100.0f /
total;
598 for(
auto i :
state.world.in_ideology) {
599 state.world.nation_get_upper_house(n, i) *= scale_factor;
602 auto rp_ideology =
state.world.political_party_get_ideology(
state.world.nation_get_ruling_party(n));
603 for(
auto i :
state.world.in_ideology) {
604 state.world.nation_set_upper_house(n, i, 0.0f);
607 state.world.nation_set_upper_house(n, rp_ideology, 100.0f);
610 for(
auto i :
state.world.in_ideology) {
611 state.world.nation_set_upper_house(n, i, 0.0f);
613 for(
auto p :
state.world.nation_get_province_ownership(n)) {
614 if(p.get_province().get_is_colonial())
617 for(
auto pop :
state.world.province_get_pop_location(p.get_province())) {
620 for(
auto i :
state.world.in_ideology) {
622 state.world.nation_get_upper_house(n, i) +=
629 for(
auto i :
state.world.in_ideology) {
630 total +=
state.world.nation_get_upper_house(n, i);
633 auto scale_factor = 100.0f /
total;
634 for(
auto i :
state.world.in_ideology) {
635 state.world.nation_get_upper_house(n, i) *= scale_factor;
638 auto rp_ideology =
state.world.political_party_get_ideology(
state.world.nation_get_ruling_party(n));
639 for(
auto i :
state.world.in_ideology) {
640 state.world.nation_set_upper_house(n, i, 0.0f);
643 state.world.nation_set_upper_house(n, rp_ideology, 100.0f);
647 if(n ==
state.local_player_nation) {
651 for(
auto i :
state.world.in_ideology) {
652 auto frac =
state.world.nation_get_upper_house(n, i);
658 "msg_upper_house_title",
659 n, dcon::nation_id{}, dcon::nation_id{},
667 auto si = state.world.province_get_state_membership(p);
668 auto nf = state.world.state_instance_get_owner_focus(si);
669 auto party = state.world.national_focus_get_ideology(nf);
671 auto& l = state.world.province_get_party_loyalty(p, party);
672 l = std::clamp(l + state.world.national_focus_get_loyalty_value(nf), -1.0f, 1.0f);
683 auto ideological_share = state.world.pop_get_consciousness(pop) / 20.0f;
685 float ruling_party_support = p.get_modifier_values(sys::provincial_mod_offsets::local_ruling_party_support) +
686 n.get_modifier_values(sys::national_mod_offsets::ruling_party_support) + 1.0f;
687 float prov_vote_mod = p.get_modifier_values(sys::provincial_mod_offsets::number_of_voters) + 1.0f;
689 auto pid = state.world.political_party_get_ideology(par_id);
690 auto base_support = (p.get_party_loyalty(pid) + 1.0f) * prov_vote_mod *
691 (par_id == n.get_ruling_party() ? ruling_party_support : 1.0f) * weight;
692 auto issue_support = 0.0f;
693 for(
auto pi : state.culture_definitions.party_issues) {
694 auto party_pos = state.world.political_party_get_party_issues(par_id, pi);
698 return base_support * (issue_support * (1.0f - ideological_share) + ideology_support * ideological_share);
705 dcon::political_party_id
par;
710 if(state.world.nation_get_election_ends(n) < state.current_date) {
711 state.world.nation_set_election_ends(n, state.current_date + int32_t(state.defines.campaign_duration) * 30);
712 if(n == state.local_player_nation) {
713 auto end_date = state.world.nation_get_election_ends(n);
718 "msg_election_start_title",
719 n, dcon::nation_id{}, dcon::nation_id{},
729 static std::vector<party_vote> party_votes;
730 static std::vector<party_vote> provincial_party_votes;
732 for(
auto n : state.world.in_nation) {
738 if(n.get_election_ends() == state.current_date) {
742 float total_vote = 0.0f;
744 auto tag = state.world.nation_get_identity_from_identity_holder(n);
745 auto start = state.world.national_identity_get_political_party_first(tag).id.index();
746 auto end = start + state.world.national_identity_get_political_party_count(tag);
748 for(int32_t i = start; i < end; i++) {
749 auto pid = dcon::political_party_id(dcon::political_party_id::value_base_t(i));
751 && (n.get_government_type().get_ideologies_allowed() &
culture::to_bits(state.world.political_party_get_ideology(pid))) != 0) {
756 if(party_votes.size() == 0)
760 for(
auto p : n.get_province_ownership()) {
761 if(p.get_province().get_is_colonial())
764 provincial_party_votes.clear();
765 float province_total = 0.0f;
766 for(
auto& par : party_votes) {
770 float ruling_party_support =
771 p.get_province().get_modifier_values(sys::provincial_mod_offsets::local_ruling_party_support) +
772 n.get_modifier_values(sys::national_mod_offsets::ruling_party_support) + 1.0f;
773 float prov_vote_mod = p.get_province().get_modifier_values(sys::provincial_mod_offsets::number_of_voters) + 1.0f;
775 for(
auto pop : p.get_province().get_pop_location()) {
778 auto ideological_share = pop.get_pop().get_consciousness() / 20.0f;
779 for(
auto& par : provincial_party_votes) {
792 auto pid = state.world.political_party_get_ideology(par.par);
793 auto base_support = (p.get_province().get_party_loyalty(pid) + 1.0f)
794 * prov_vote_mod * (par.par == n.get_ruling_party() ? ruling_party_support : 1.0f) * weight;
795 auto issue_support = 0.0f;
796 for(
auto pi : state.culture_definitions.party_issues) {
797 auto party_pos = state.world.political_party_get_party_issues(par.par, pi);
801 auto total_support = base_support * (issue_support * (1.0f - ideological_share) + ideology_support * ideological_share);
803 province_total += total_support;
804 par.vote += total_support;
809 if(province_total > 0) {
821 float winner_amount = provincial_party_votes[0].vote;
822 for(
uint32_t i = 1; i < provincial_party_votes.size(); ++i) {
823 if(provincial_party_votes[i].vote > winner_amount) {
825 winner_amount = provincial_party_votes[i].vote;
829 auto pid = state.world.political_party_get_ideology(provincial_party_votes[winner].par);
830 auto& l = p.get_province().get_party_loyalty(pid);
831 l = std::clamp(l + state.defines.loyalty_boost_on_party_win *
832 (p.get_province().get_modifier_values(sys::provincial_mod_offsets::boost_strongest_party) + 1.0f)
833 * winner_amount / province_total,
835 auto national_rule = n.get_combined_issue_rules();
838 party_votes[winner].vote += winner_amount;
840 for(
uint32_t i = 0; i < provincial_party_votes.size(); ++i) {
841 party_votes[i].vote += provincial_party_votes[i].vote / province_total;
844 for(
uint32_t i = 0; i < provincial_party_votes.size(); ++i) {
845 party_votes[i].vote += provincial_party_votes[i].vote;
862 if(avg_mil <= 5.0f) {
863 static auto per_group = state.world.ideology_group_make_vectorizable_float_buffer();
864 for(
auto ig : state.world.in_ideology_group) {
865 per_group.set(ig, 0.0f);
867 for(
uint32_t i = 0; i < party_votes.size(); ++i) {
868 per_group.get(state.world.ideology_get_ideology_group_from_ideology_group_membership(
869 state.world.political_party_get_ideology(party_votes[i].par))) += party_votes[i].vote;
871 dcon::ideology_group_id winner;
872 float winner_amount = -1.0f;
874 for(
auto ig : state.world.in_ideology_group) {
875 if(per_group.get(ig) > winner_amount) {
876 winner_amount = per_group.get(ig);
882 float winner_amount_b = -1.0f;
883 for(
uint32_t i = 0; i < party_votes.size(); ++i) {
884 total += party_votes[i].vote;
885 if(state.world.ideology_get_ideology_group_from_ideology_group_membership(
886 state.world.political_party_get_ideology(party_votes[i].par)) == winner &&
887 party_votes[i].vote > winner_amount_b) {
889 winner_amount_b = party_votes[i].vote;
899 "msg_election_end_title",
900 n, dcon::nation_id{}, dcon::nation_id{},
905 float winner_amount = party_votes[0].vote;
907 for(
uint32_t i = 1; i < party_votes.size(); ++i) {
908 total += party_votes[i].vote;
909 if(party_votes[i].vote > winner_amount) {
911 winner_amount = party_votes[i].vote;
921 "msg_election_end_title",
922 n, dcon::nation_id{}, dcon::nation_id{},
930 }
else if(state.current_date < n.get_election_ends()) {
937 int32_t time_value = int32_t(state.defines.campaign_event_base_time / 2.0f);
939 int32_t first_roll = int32_t(
uint32_t(randoms.low) % time_value) + time_value;
940 int32_t second_roll = first_roll + int32_t(
uint32_t(randoms.low >> 32) % time_value) + time_value;
941 int32_t third_roll = second_roll + int32_t(
uint32_t(randoms.high) % time_value) + time_value;
942 int32_t fourth_roll = third_roll + int32_t(
uint32_t(randoms.high >> 32) % time_value) + time_value;
944 auto election_start = n.get_election_ends() - int32_t(state.defines.campaign_duration) * 30;
946 if(election_start + first_roll == state.current_date || election_start + second_roll == state.current_date
947 || election_start + third_roll == state.current_date || election_start + fourth_roll == state.current_date) {
958 auto parent = state.world.issue_option_get_parent_issue(opt);
959 auto effect_t = state.world.issue_option_get_on_execute_trigger(opt);
960 auto effect_k = state.world.issue_option_get_on_execute_effect(opt);
963 uint32_t((opt.index() << 2) ^ n.index()));
965 state.world.nation_set_issues(n, parent, opt);
968 auto parent = state.world.reform_option_get_parent_reform(opt);
969 auto effect_t = state.world.reform_option_get_on_execute_trigger(opt);
970 auto effect_k = state.world.reform_option_get_on_execute_effect(opt);
973 uint32_t((opt.index() << 2) ^ n.index()));
975 state.world.nation_set_reforms(n, parent, opt);
#define assert(condition)
constexpr uint64_t to_bits(dcon::ideology_id id)
void update_nation_issue_rules(sys::state &state, dcon::nation_id n_id)
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
constexpr dcon::demographics_key total(0)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
constexpr dcon::demographics_key militancy(4)
void bound_budget_settings(sys::state &state, dcon::nation_id n)
void set_factory_priority(sys::state &state, dcon::factory_id f, int32_t priority)
void execute(sys::state &state, dcon::effect_key key, int32_t primary, int32_t this_slot, int32_t from_slot, uint32_t r_lo, uint32_t r_hi)
void fire_fixed_event(sys::state &state, std::vector< nations::fixed_event > const &v, int32_t primary_slot, slot_type pt, dcon::nation_id this_slot, int32_t from_slot, slot_type ft)
constexpr uint32_t same_as_ruling_party
constexpr uint32_t state_vote
constexpr uint32_t culture_voting
constexpr uint32_t rich_only
constexpr uint32_t largest_share
constexpr uint32_t primary_culture_voting
constexpr uint32_t factory_priority
void post(sys::state &state, message &&m)
void daily_party_loyalty_update(sys::state &state)
bool can_enact_social_reform(sys::state &state, dcon::nation_id n, dcon::issue_option_id o)
float pop_vote_weight(sys::state &state, dcon::pop_id p, dcon::nation_id n)
float get_military_reform_multiplier(sys::state &state, dcon::nation_id n)
float vote_total(sys::state &state, dcon::nation_id nation)
bool can_enact_political_reform(sys::state &state, dcon::nation_id nation, dcon::issue_option_id issue_option)
float get_economic_reform_multiplier(sys::state &state, dcon::nation_id n)
float get_voter_support(sys::state &state, dcon::nation_id nation, dcon::issue_option_id issue_option)
bool reform_is_selected(sys::state &state, dcon::nation_id nation, dcon::reform_option_id reform_option)
void recalculate_upper_house(sys::state &state, dcon::nation_id n)
dcon::issue_id get_issue_by_name(sys::state &state, std::string_view name)
sys::date next_election_date(sys::state &state, dcon::nation_id nation)
void force_ruling_party_ideology(sys::state &state, dcon::nation_id n, dcon::ideology_id id)
void force_nation_ideology(sys::state &state, dcon::nation_id n, dcon::ideology_id id)
dcon::reform_id get_reform_by_name(sys::state &state, std::string_view name)
bool can_appoint_ruling_party(sys::state &state, dcon::nation_id nation)
void set_issue_option(sys::state &state, dcon::nation_id n, dcon::issue_option_id opt)
bool political_party_is_active(sys::state &state, dcon::nation_id n, dcon::political_party_id p)
void change_government_type(sys::state &state, dcon::nation_id n, dcon::government_type_id new_type)
void update_displayed_identity(sys::state &state, dcon::nation_id id)
float get_popular_support(sys::state &state, dcon::nation_id nation, dcon::issue_option_id issue_option)
bool can_enact_military_reform(sys::state &state, dcon::nation_id n, dcon::reform_option_id o)
void set_reform_option(sys::state &state, dcon::nation_id n, dcon::reform_option_id opt)
bool issue_is_selected(sys::state &state, dcon::nation_id nation, dcon::issue_option_id issue_option)
bool has_elections(sys::state &state, dcon::nation_id nation)
float party_total_support(sys::state &state, dcon::pop_id pop, dcon::political_party_id par_id, dcon::nation_id nat_id, dcon::province_id prov_id)
void appoint_ruling_party(sys::state &state, dcon::nation_id n, dcon::political_party_id p)
void update_elections(sys::state &state)
void set_ruling_party(sys::state &state, dcon::nation_id n, dcon::political_party_id p)
void start_election(sys::state &state, dcon::nation_id n)
bool is_election_ongoing(sys::state &state, dcon::nation_id nation)
bool can_enact_economic_reform(sys::state &state, dcon::nation_id n, dcon::reform_option_id o)
dcon::pop_demographics_key to_key(sys::state const &state, dcon::ideology_id v)
void for_each_province_in_state_instance(sys::state &state, dcon::state_instance_id s, F const &func)
void for_each_land_province(sys::state &state, F const &func)
random_pair get_random_pair(sys::state const &state, uint32_t value_in)
void update_single_nation_modifiers(sys::state &state, dcon::nation_id n)
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
int32_t to_generic(dcon::province_id v)
bool evaluate(sys::state &state, dcon::trigger_key key, int32_t primary, int32_t this_slot, int32_t from_slot)
float evaluate_additive_modifier(sys::state &state, dcon::value_modifier_key modifier, int32_t primary, int32_t this_slot, int32_t from_slot)
dcon::political_party_id par