diff options
author | hop311 <hop3114@gmail.com> | 2024-10-19 12:31:40 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-10-19 12:31:40 +0200 |
commit | 35909d6e79d524f19f9b69dffd02fcf162be5093 (patch) | |
tree | fff57526931ab126e1250457e7ccc07c793504f4 /src/openvic-simulation/modifier/ModifierEffect.cpp | |
parent | 18ab144ec4ecf1efca68a26bc79b9d54e28e54f8 (diff) |
Switch to excluding given modifier effect targets rather than using a positive filter
Diffstat (limited to 'src/openvic-simulation/modifier/ModifierEffect.cpp')
-rw-r--r-- | src/openvic-simulation/modifier/ModifierEffect.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/openvic-simulation/modifier/ModifierEffect.cpp b/src/openvic-simulation/modifier/ModifierEffect.cpp index 8daf563..2ffb9a5 100644 --- a/src/openvic-simulation/modifier/ModifierEffect.cpp +++ b/src/openvic-simulation/modifier/ModifierEffect.cpp @@ -4,6 +4,38 @@ using namespace OpenVic; +std::string ModifierEffect::target_to_string(target_t target) { + using enum target_t; + + if (target == NO_TARGETS) { + return "NO TARGETS"; + } + + if (target == ALL_TARGETS) { + return "ALL TARGETS"; + } + + static constexpr std::string_view SEPARATOR = " | "; + + std::string ret; + + const auto append_target = [target, &ret](target_t check_target, std::string_view target_str) -> void { + if (!ModifierEffect::excludes_targets(target, check_target)) { + if (!ret.empty()) { + ret += SEPARATOR; + } + ret += target_str; + } + }; + + append_target(COUNTRY, "COUNTRY"); + append_target(PROVINCE, "PROVINCE"); + append_target(UNIT, "UNIT"); + append_target(~ALL_TARGETS, "INVALID TARGET"); + + return ret; +} + std::string ModifierEffect::make_default_modifier_effect_localisation_key(std::string_view identifier) { return "MODIFIER_" + StringUtils::string_toupper(identifier); } |