aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/misc/Modifier.cpp
blob: 2d95f0de949eb2116b8f95618d56a664bfabb95a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
#include "Modifier.hpp"

#include <string>

#include "openvic-simulation/types/OrderedContainers.hpp"
#include "openvic-simulation/utility/TslHelper.hpp"

using namespace OpenVic;
using namespace OpenVic::NodeTools;

ModifierEffect::ModifierEffect(std::string_view new_identifier, bool new_positive_good, format_t new_format)
   : HasIdentifier { new_identifier }, positive_good { new_positive_good }, format { new_format } {}

ModifierValue::ModifierValue() = default;
ModifierValue::ModifierValue(effect_map_t&& new_values) : values { std::move(new_values) } {}
ModifierValue::ModifierValue(ModifierValue const&) = default;
ModifierValue::ModifierValue(ModifierValue&&) = default;

ModifierValue& ModifierValue::operator=(ModifierValue const&) = default;
ModifierValue& ModifierValue::operator=(ModifierValue&&) = default;

void ModifierValue::trim() {
   erase_if(values, [](effect_map_t::value_type const& value) -> bool {
      return value.second == fixed_point_t::_0();
   });
}

size_t ModifierValue::get_effect_count() const {
   return values.size();
}

fixed_point_t ModifierValue::get_effect(ModifierEffect const* effect, bool* successful) {
   const effect_map_t::const_iterator it = values.find(effect);
   if (it != values.end()) {
      if (successful != nullptr) {
         *successful = true;
      }
      return it->second;
   }
   if (successful != nullptr) {
      *successful = false;
   }
   return fixed_point_t::_0();
}

bool ModifierValue::has_effect(ModifierEffect const* effect) const {
   return values.contains(effect);
}

ModifierValue& ModifierValue::operator+=(ModifierValue const& right) {
   for (effect_map_t::value_type const& value : right.values) {
      values[value.first] += value.second;
   }
   return *this;
}

ModifierValue ModifierValue::operator+(ModifierValue const& right) const {
   ModifierValue ret = *this;
   return ret += right;
}

ModifierValue ModifierValue::operator-() const {
   ModifierValue ret = *this;
   for (auto value : mutable_iterator(ret.values)) {
      value.second = -value.second;
   }
   return ret;
}

ModifierValue& ModifierValue::operator-=(ModifierValue const& right) {
   for (effect_map_t::value_type const& value : right.values) {
      values[value.first] -= value.second;
   }
   return *this;
}

ModifierValue ModifierValue::operator-(ModifierValue const& right) const {
   ModifierValue ret = *this;
   return ret -= right;
}

Modifier::Modifier(std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon)
   : HasIdentifier { new_identifier }, ModifierValue { std::move(new_values) }, icon { new_icon } {}

TriggeredModifier::TriggeredModifier(
   std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon, ConditionScript&& new_trigger
) : Modifier { new_identifier, std::move(new_values), new_icon }, trigger { std::move(new_trigger) } {}

bool TriggeredModifier::parse_scripts(GameManager const& game_manager) {
   return trigger.parse_script(false, game_manager);
}

ModifierInstance::ModifierInstance(Modifier const& modifier, Date expiry_date)
   : modifier { modifier }, expiry_date { expiry_date } {}

bool ModifierManager::add_modifier_effect(std::string_view identifier, bool positive_good, ModifierEffect::format_t format) {
   if (identifier.empty()) {
      Logger::error("Invalid modifier effect identifier - empty!");
      return false;
   }
   return modifier_effects.add_item(
      std::make_unique<ModifierEffect>(std::move(identifier), std::move(positive_good), std::move(format))
   );
}

bool ModifierManager::setup_modifier_effects() {
   bool ret = true;

   using enum ModifierEffect::format_t;

   /* Country Modifier Effects */
   ret &= add_modifier_effect("administrative_efficiency", true);
   ret &= add_modifier_effect("administrative_efficiency_modifier", true);
   ret &= add_modifier_effect("artisan_input", false);
   ret &= add_modifier_effect("artisan_output", true);
   ret &= add_modifier_effect("artisan_throughput", true);
   ret &= add_modifier_effect("badboy", false, RAW_DECIMAL);
   ret &= add_modifier_effect("cb_creation_speed", true); //seemingly works the same way as cb_generation_speed_modifier
   ret &= add_modifier_effect("cb_generation_speed_modifier", true);
   ret &= add_modifier_effect("colonial_life_rating", false, INT);
   ret &= add_modifier_effect("colonial_migration", true);
   ret &= add_modifier_effect("colonial_points", true, INT);
   ret &= add_modifier_effect("colonial_prestige", true);
   ret &= add_modifier_effect("core_pop_consciousness_modifier", false, RAW_DECIMAL);
   ret &= add_modifier_effect("core_pop_militancy_modifier", false, RAW_DECIMAL);
   ret &= add_modifier_effect("dig_in_cap", true, INT);
   ret &= add_modifier_effect("diplomatic_points", true);
   ret &= add_modifier_effect("diplomatic_points_modifier", true);
   ret &= add_modifier_effect("education_efficiency", true);
   ret &= add_modifier_effect("education_efficiency_modifier", true);
   ret &= add_modifier_effect("factory_cost", false);
   ret &= add_modifier_effect("factory_input", false);
   ret &= add_modifier_effect("factory_maintenance", false);
   ret &= add_modifier_effect("factory_output", true);
   ret &= add_modifier_effect("factory_owner_cost", false);
   ret &= add_modifier_effect("factory_throughput", true);
   ret &= add_modifier_effect("global_assimilation_rate", true);
   ret &= add_modifier_effect("global_immigrant_attract", true);
   ret &= add_modifier_effect("global_pop_consciousness_modifier", false, RAW_DECIMAL);
   ret &= add_modifier_effect("global_pop_growth", true);
   ret &= add_modifier_effect("global_pop_militancy_modifier", false, RAW_DECIMAL);
   ret &= add_modifier_effect("global_population_growth", true);
   ret &= add_modifier_effect("goods_demand", false);
   ret &= add_modifier_effect("import_cost", false);
   ret &= add_modifier_effect("increase_research", true);
   ret &= add_modifier_effect("influence", true);
   ret &= add_modifier_effect("influence_modifier", true);
   ret &= add_modifier_effect("issue_change_speed", true);
   ret &= add_modifier_effect("land_attack_modifier", true);
   ret &= add_modifier_effect("land_attrition", false);
   ret &= add_modifier_effect("land_defense_modifier", true);
   ret &= add_modifier_effect("land_organisation", true);
   ret &= add_modifier_effect("land_unit_start_experience", true, RAW_DECIMAL);
   ret &= add_modifier_effect("leadership", true, RAW_DECIMAL);
   ret &= add_modifier_effect("leadership_modifier", true);
   ret &= add_modifier_effect("literacy_con_impact", false);
   ret &= add_modifier_effect("loan_interest", false);
   ret &= add_modifier_effect("max_loan_modifier", true);
   ret &= add_modifier_effect("max_military_spending", true);
   ret &= add_modifier_effect("max_national_focus", true, INT);
   ret &= add_modifier_effect("max_social_spending", true);
   ret &= add_modifier_effect("max_tariff", true);
   ret &= add_modifier_effect("max_tax", true);
   ret &= add_modifier_effect("max_war_exhaustion", true, PERCENTAGE_DECIMAL);
   ret &= add_modifier_effect("military_tactics", true);
   ret &= add_modifier_effect("min_military_spending", true);
   ret &= add_modifier_effect("min_social_spending", true);
   ret &= add_modifier_effect("min_tariff", true);
   ret &= add_modifier_effect("min_tax", true);
   ret &= add_modifier_effect("mobilisation_economy_impact", false);
   ret &= add_modifier_effect("mobilisation_impact", false);
   ret &= add_modifier_effect("mobilisation_size", true);
   ret &= add_modifier_effect("mobilization_economy_impact", false);
   ret &= add_modifier_effect("mobilization_impact", false);
   ret &= add_modifier_effect("mobilization_size", true);
   ret &= add_modifier_effect("naval_attack_modifier", true);
   ret &= add_modifier_effect("naval_attrition", false);
   ret &= add_modifier_effect("naval_defense_modifier", true);
   ret &= add_modifier_effect("naval_organisation", true);
   ret &= add_modifier_effect("naval_unit_start_experience", true, RAW_DECIMAL);
   ret &= add_modifier_effect("non_accepted_pop_consciousness_modifier", false, RAW_DECIMAL);
   ret &= add_modifier_effect("non_accepted_pop_militancy_modifier", false, RAW_DECIMAL);
   ret &= add_modifier_effect("org_regain", true);
   ret &= add_modifier_effect("pension_level", true);
   ret &= add_modifier_effect("permanent_prestige", true, RAW_DECIMAL);
   ret &= add_modifier_effect("plurality", true, PERCENTAGE_DECIMAL);
   ret &= add_modifier_effect("political_reform_desire", false);
   ret &= add_modifier_effect("pop_growth", true);
   ret &= add_modifier_effect("prestige", true, RAW_DECIMAL);
   ret &= add_modifier_effect("regular_experience_level", true, RAW_DECIMAL);
   ret &= add_modifier_effect("reinforce_rate", true);
   ret &= add_modifier_effect("research_points", true, RAW_DECIMAL);
   ret &= add_modifier_effect("research_points_modifier", true);
   ret &= add_modifier_effect("research_points_on_conquer", true);
   ret &= add_modifier_effect("rgo_output", true);
   ret &= add_modifier_effect("RGO_output", true);
   ret &= add_modifier_effect("rgo_size", true);
   ret &= add_modifier_effect("RGO_size", true);
   ret &= add_modifier_effect("rgo_throughput", true);
   ret &= add_modifier_effect("RGO_throughput", true);
   ret &= add_modifier_effect("ruling_party_support", true);
   ret &= add_modifier_effect("shared_prestige", true, RAW_DECIMAL);
   ret &= add_modifier_effect("social_reform_desire", false);
   ret &= add_modifier_effect("soldier_to_pop_loss", true);
   ret &= add_modifier_effect("seperatism", false); // paradox typo
   ret &= add_modifier_effect("supply_consumption", false);
   ret &= add_modifier_effect("supply_range", true);
   ret &= add_modifier_effect("suppression_points_modifier", true);
   ret &= add_modifier_effect("tariff_efficiency_modifier", true);
   ret &= add_modifier_effect("tax_eff", true);
   ret &= add_modifier_effect("tax_efficiency", true);
   ret &= add_modifier_effect("unit_recruitment_time", false);
   ret &= add_modifier_effect("unit_start_experience", true, RAW_DECIMAL);
   ret &= add_modifier_effect("war_exhaustion", false);
   ret &= add_modifier_effect("civilization_progress_modifier", true);
   ret &= add_modifier_effect("administrative_multiplier", true);
   ret &= add_modifier_effect("unemployment_benefit", true);
   ret &= add_modifier_effect("minimum_wage", true);
   ret &= add_modifier_effect("war_exhaustion_effect", false);
   ret &= add_modifier_effect("reinforce_speed", true);

   /* Province Modifier Effects */
   ret &= add_modifier_effect("assimilation_rate", true);
   ret &= add_modifier_effect("boost_strongest_party", false);
   ret &= add_modifier_effect("farm_rgo_eff", true);
   ret &= add_modifier_effect("farm_RGO_eff", true);
   ret &= add_modifier_effect("farm_rgo_size", true);
   ret &= add_modifier_effect("farm_RGO_size", true);
   ret &= add_modifier_effect("flashpoint_tension", false);
   ret &= add_modifier_effect("immigrant_attract", true);
   ret &= add_modifier_effect("immigrant_push", false);
   ret &= add_modifier_effect("life_rating", true);
   ret &= add_modifier_effect("local_artisan_input", false);
   ret &= add_modifier_effect("local_artisan_output", true);
   ret &= add_modifier_effect("local_artisan_throughput", true);
   ret &= add_modifier_effect("local_factory_input", false);
   ret &= add_modifier_effect("local_factory_output", true);
   ret &= add_modifier_effect("local_factory_throughput", true);
   ret &= add_modifier_effect("local_repair", true);
   ret &= add_modifier_effect("local_rgo_output", true);
   ret &= add_modifier_effect("local_RGO_output", true);
   ret &= add_modifier_effect("local_rgo_throughput", true);
   ret &= add_modifier_effect("local_RGO_throughput", true);
   ret &= add_modifier_effect("local_ruling_party_support", true);
   ret &= add_modifier_effect("local_ship_build", false);
   ret &= add_modifier_effect("max_attrition", false, RAW_DECIMAL);
   ret &= add_modifier_effect("mine_rgo_eff", true);
   ret &= add_modifier_effect("mine_RGO_eff", true);
   ret &= add_modifier_effect("mine_rgo_size", true);
   ret &= add_modifier_effect("mine_RGO_size", true);
   ret &= add_modifier_effect("movement_cost", false);
   ret &= add_modifier_effect("number_of_voters", false);
   ret &= add_modifier_effect("pop_consciousness_modifier", false, RAW_DECIMAL);
   ret &= add_modifier_effect("pop_militancy_modifier", false, RAW_DECIMAL);
   ret &= add_modifier_effect("population_growth", true);
   ret &= add_modifier_effect("railroads", true); // capitalist likelihood for railroads vs factories
   ret &= add_modifier_effect("supply_limit", true, RAW_DECIMAL);

   /* Military Modifier Effects */
   ret &= add_modifier_effect("attack", true, INT);
   ret &= add_modifier_effect("attrition", false, RAW_DECIMAL);
   ret &= add_modifier_effect("combat_width", false);
   ret &= add_modifier_effect("defence", true, INT);
   ret &= add_modifier_effect("experience", true);
   ret &= add_modifier_effect("morale", true);
   ret &= add_modifier_effect("organisation", true);
   ret &= add_modifier_effect("reconnaissance", true);
   ret &= add_modifier_effect("reliability", true, RAW_DECIMAL);
   ret &= add_modifier_effect("speed", true);

   return ret;
}

bool ModifierManager::register_complex_modifier(std::string_view identifier) {
   if (complex_modifiers.emplace(identifier).second) {
      return true;
   } else {
      Logger::error("Duplicate complex modifier: ", identifier);
      return false;
   }
}

bool ModifierManager::add_event_modifier(std::string_view identifier, ModifierValue&& values, Modifier::icon_t icon) {
   if (identifier.empty()) {
      Logger::error("Invalid event modifier effect identifier - empty!");
      return false;
   }
   return event_modifiers.add_item({ identifier, std::move(values), icon }, duplicate_warning_callback);
}

bool ModifierManager::load_event_modifiers(ast::NodeCPtr root) {
   const bool ret = expect_dictionary_reserve_length(
      event_modifiers,
      [this](std::string_view key, ast::NodeCPtr value) -> bool {
         ModifierValue modifier_value;
         Modifier::icon_t icon = 0;
         bool ret = expect_modifier_value_and_keys(
            move_variable_callback(modifier_value),
            "icon", ZERO_OR_ONE, expect_uint(assign_variable_callback(icon))
         )(value);
         ret &= add_event_modifier(key, std::move(modifier_value), icon);
         return ret;
      }
   )(root);
   lock_event_modifiers();
   return ret;
}

bool ModifierManager::add_static_modifier(std::string_view identifier, ModifierValue&& values) {
   if (identifier.empty()) {
      Logger::error("Invalid static modifier effect identifier - empty!");
      return false;
   }
   return static_modifiers.add_item({ identifier, std::move(values), 0 }, duplicate_warning_callback);
}

bool ModifierManager::load_static_modifiers(ast::NodeCPtr root) {
   const bool ret = expect_dictionary_reserve_length(
      static_modifiers,
      [this](std::string_view key, ast::NodeCPtr value) -> bool {
         ModifierValue modifier_value;
         bool ret = expect_modifier_value(move_variable_callback(modifier_value))(value);
         ret &= add_static_modifier(key, std::move(modifier_value));
         return ret;
      }
   )(root);
   lock_static_modifiers();
   return ret;
}

bool ModifierManager::add_triggered_modifier(
   std::string_view identifier, ModifierValue&& values, Modifier::icon_t icon, ConditionScript&& trigger
) {
   if (identifier.empty()) {
      Logger::error("Invalid triggered modifier effect identifier - empty!");
      return false;
   }
   return triggered_modifiers.add_item({ identifier, std::move(values), icon, std::move(trigger) }, duplicate_warning_callback);
}

bool ModifierManager::load_triggered_modifiers(ast::NodeCPtr root) {
   const bool ret = expect_dictionary_reserve_length(
      triggered_modifiers,
      [this](std::string_view key, ast::NodeCPtr value) -> bool {
         ModifierValue modifier_value;
         Modifier::icon_t icon = 0;
         ConditionScript trigger { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE };

         bool ret = expect_modifier_value_and_keys(
            move_variable_callback(modifier_value),
            "icon", ZERO_OR_ONE, expect_uint(assign_variable_callback(icon)),
            "trigger", ONE_EXACTLY, trigger.expect_script()
         )(value);
         ret &= add_triggered_modifier(key, std::move(modifier_value), icon, std::move(trigger));
         return ret;
      }
   )(root);
   lock_triggered_modifiers();
   return ret;
}

bool ModifierManager::parse_scripts(GameManager const& game_manager) {
   bool ret = true;
   for (TriggeredModifier& modifier : triggered_modifiers.get_items()) {
      ret &= modifier.parse_scripts(game_manager);
   }
   return ret;
}

key_value_callback_t ModifierManager::_modifier_effect_callback(
   ModifierValue& modifier, key_value_callback_t default_callback, ModifierEffectValidator auto effect_validator
) const {
   const auto add_modifier_cb = [this, &modifier, effect_validator](ModifierEffect const* effect, ast::NodeCPtr value) -> bool {
      if (effect_validator(*effect)) {
         return expect_fixed_point(map_callback(modifier.values, effect))(value);
      } else {
         Logger::error("Failed to validate modifier effect: ", effect->get_identifier());
         return false;
      }
   };

   const auto add_flattened_modifier_cb = [this, add_modifier_cb](std::string_view prefix, std::string_view key, ast::NodeCPtr value) -> bool {
      const std::string flat_identifier = StringUtils::append_string_views(prefix, "_", key);
      ModifierEffect const* effect = get_modifier_effect_by_identifier(flat_identifier);
      if (effect != nullptr) {
         return add_modifier_cb(effect, value);
      } else {
         Logger::error("Could not find flattened modifier: ", flat_identifier);
         return false;
      }
   };

   return [this, default_callback, add_modifier_cb, add_flattened_modifier_cb](std::string_view key, ast::NodeCPtr value) -> bool {
      ModifierEffect const* effect = get_modifier_effect_by_identifier(key);
      if (effect != nullptr && value->is_type<ast::IdentifierNode>()) {
         return add_modifier_cb(effect, value);
      } else if (complex_modifiers.contains(key) && value->is_derived_from<ast::AbstractListNode>()) {
         if (key == "rebel_org_gain") { //because of course there's a special one
            std::string_view faction_identifier;
            ast::NodeCPtr value_node = nullptr;
            bool ret = expect_dictionary_keys(
               "faction", ONE_EXACTLY, expect_identifier(assign_variable_callback(faction_identifier)),
               "value", ONE_EXACTLY, assign_variable_callback(value_node)
            )(value);
            ret &= add_flattened_modifier_cb(key, faction_identifier, value_node);
            return ret;
         } else {
            return expect_dictionary(std::bind_front(add_flattened_modifier_cb, key))(value);
         }
      } else {
         return default_callback(key, value);
      }
   };
}

node_callback_t ModifierManager::expect_validated_modifier_value_and_default(
   callback_t<ModifierValue&&> modifier_callback, key_value_callback_t default_callback,
   ModifierEffectValidator auto effect_validator
) const {
   return [this, modifier_callback, default_callback, effect_validator](ast::NodeCPtr root) -> bool {
      ModifierValue modifier;
      bool ret = expect_dictionary_reserve_length(
         modifier.values,
         _modifier_effect_callback(modifier, default_callback, effect_validator)
      )(root);
      ret &= modifier_callback(std::move(modifier));
      return ret;
   };
}
node_callback_t ModifierManager::expect_validated_modifier_value(
   callback_t<ModifierValue&&> modifier_callback, ModifierEffectValidator auto effect_validator
) const {
   return expect_validated_modifier_value_and_default(modifier_callback, key_value_invalid_callback, effect_validator);
}

node_callback_t ModifierManager::expect_modifier_value_and_default(
   callback_t<ModifierValue&&> modifier_callback, key_value_callback_t default_callback
) const {
   return expect_validated_modifier_value_and_default(modifier_callback, default_callback, [](ModifierEffect const&) -> bool {
      return true;
   });
}

node_callback_t ModifierManager::expect_modifier_value(callback_t<ModifierValue&&> modifier_callback) const {
   return expect_modifier_value_and_default(modifier_callback, key_value_invalid_callback);
}

node_callback_t ModifierManager::expect_whitelisted_modifier_value_and_default(
   callback_t<ModifierValue&&> modifier_callback, string_set_t const& whitelist, key_value_callback_t default_callback
) const {
   return expect_validated_modifier_value_and_default(
      modifier_callback, default_callback,
      [&whitelist](ModifierEffect const& effect) -> bool {
         return whitelist.contains(effect.get_identifier());
      }
   );
}

node_callback_t ModifierManager::expect_whitelisted_modifier_value(
   callback_t<ModifierValue&&> modifier_callback, string_set_t const& whitelist
) const {
   return expect_whitelisted_modifier_value_and_default(modifier_callback, whitelist, key_value_invalid_callback);
}

node_callback_t ModifierManager::expect_modifier_value_and_key_map_and_default(
   callback_t<ModifierValue&&> modifier_callback, key_value_callback_t default_callback, key_map_t&& key_map
) const {
   return [this, modifier_callback, default_callback, key_map = std::move(key_map)](ast::NodeCPtr node) mutable -> bool {
      bool ret = expect_modifier_value_and_default(
         modifier_callback,
         dictionary_keys_callback(key_map, default_callback)
      )(node);
      ret &= check_key_map_counts(key_map);
      return ret;
   };
}

node_callback_t ModifierManager::expect_modifier_value_and_key_map(
   callback_t<ModifierValue&&> modifier_callback, key_map_t&& key_map
) const {
   return expect_modifier_value_and_key_map_and_default(modifier_callback, key_value_invalid_callback, std::move(key_map));
}

namespace OpenVic { // so the compiler shuts up
   std::ostream& operator<<(std::ostream& stream, ModifierValue const& value) {
      for (ModifierValue::effect_map_t::value_type const& effect : value.values) {
         stream << effect.first << ": " << effect.second << "\n";
      }
      return stream;
   }
}