aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/modifier/ModifierSum.hpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-10-19 12:31:40 +0200
committer hop311 <hop3114@gmail.com>2024-10-19 12:31:40 +0200
commit35909d6e79d524f19f9b69dffd02fcf162be5093 (patch)
treefff57526931ab126e1250457e7ccc07c793504f4 /src/openvic-simulation/modifier/ModifierSum.hpp
parent18ab144ec4ecf1efca68a26bc79b9d54e28e54f8 (diff)
Switch to excluding given modifier effect targets rather than using a positive filter
Diffstat (limited to 'src/openvic-simulation/modifier/ModifierSum.hpp')
-rw-r--r--src/openvic-simulation/modifier/ModifierSum.hpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/openvic-simulation/modifier/ModifierSum.hpp b/src/openvic-simulation/modifier/ModifierSum.hpp
index 7c1b238..858ca71 100644
--- a/src/openvic-simulation/modifier/ModifierSum.hpp
+++ b/src/openvic-simulation/modifier/ModifierSum.hpp
@@ -13,16 +13,32 @@ namespace OpenVic {
struct ModifierSum {
using modifier_source_t = std::variant<CountryInstance const*, ProvinceInstance const*>;
+ static std::string_view source_to_string(modifier_source_t const& source);
+
struct modifier_entry_t {
Modifier const* modifier;
fixed_point_t multiplier;
modifier_source_t source;
- ModifierEffect::target_t targets;
+ ModifierEffect::target_t excluded_targets;
constexpr modifier_entry_t(
- Modifier const* new_modifier, fixed_point_t new_multiplier, modifier_source_t const& new_source,
- ModifierEffect::target_t new_targets
- ) : modifier { new_modifier }, multiplier { new_multiplier }, source { new_source }, targets { new_targets } {}
+ Modifier const* new_modifier,
+ fixed_point_t new_multiplier,
+ modifier_source_t const& new_source,
+ ModifierEffect::target_t new_excluded_targets
+ ) : modifier { new_modifier },
+ multiplier { new_multiplier },
+ source { new_source },
+ excluded_targets { new_excluded_targets } {}
+
+ constexpr bool operator==(modifier_entry_t const& other) const {
+ return modifier == other.modifier
+ && multiplier == other.multiplier
+ && source_to_string(source) == source_to_string(other.source)
+ && excluded_targets == other.excluded_targets;
+ }
+
+ std::string to_string() const;
};
private:
@@ -45,14 +61,14 @@ namespace OpenVic {
void add_modifier(
Modifier const& modifier, modifier_source_t const& source, fixed_point_t multiplier = fixed_point_t::_1(),
- ModifierEffect::target_t targets = ModifierEffect::target_t::ALL_TARGETS
+ ModifierEffect::target_t excluded_targets = ModifierEffect::target_t::ALL_TARGETS
);
void add_modifier_nullcheck(
Modifier const* modifier, modifier_source_t const& source, fixed_point_t multiplier = fixed_point_t::_1(),
- ModifierEffect::target_t targets = ModifierEffect::target_t::ALL_TARGETS
+ ModifierEffect::target_t excluded_targets = ModifierEffect::target_t::ALL_TARGETS
);
void add_modifier_sum(ModifierSum const& modifier_sum);
- void add_modifier_sum_filter_targets(ModifierSum const& modifier_sum, ModifierEffect::target_t targets);
+ void add_modifier_sum_exclude_targets(ModifierSum const& modifier_sum, ModifierEffect::target_t excluded_targets);
void add_modifier_sum_exclude_source(ModifierSum const& modifier_sum, modifier_source_t const& excluded_source);
void push_contributing_modifiers(ModifierEffect const& effect, std::vector<modifier_entry_t>& contributions) const;