aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/modifier/ModifierSum.hpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-09-20 14:18:59 +0200
committer GitHub <noreply@github.com>2024-09-20 14:18:59 +0200
commit85da7fb84197d617d1b3cde6969bf7bcfbb93d1d (patch)
tree0f103095b45de46688206d0e33e24f0331afbabd /src/openvic-simulation/modifier/ModifierSum.hpp
parent7fe8ba2b3bd3bafad374a691280bbf5102b58678 (diff)
parent3703851ced696a2d4559c3e3340c537982d5ebc7 (diff)
Merge pull request #203 from OpenVicProject/modifier-sum
Add ModifierSum and improve ModifierValue
Diffstat (limited to 'src/openvic-simulation/modifier/ModifierSum.hpp')
-rw-r--r--src/openvic-simulation/modifier/ModifierSum.hpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/openvic-simulation/modifier/ModifierSum.hpp b/src/openvic-simulation/modifier/ModifierSum.hpp
new file mode 100644
index 0000000..957ffab
--- /dev/null
+++ b/src/openvic-simulation/modifier/ModifierSum.hpp
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "openvic-simulation/modifier/Modifier.hpp"
+#include "openvic-simulation/types/fixed_point/FixedPointMap.hpp"
+
+namespace OpenVic {
+ struct ModifierSum {
+ private:
+ fixed_point_map_t<Modifier const*> PROPERTY(modifiers);
+ ModifierValue PROPERTY(value_sum);
+
+ public:
+ ModifierSum() = default;
+ ModifierSum(ModifierSum&&) = default;
+
+ void clear();
+ bool empty();
+
+ fixed_point_t get_effect(ModifierEffect const& effect, bool* effect_found = nullptr) const;
+ bool has_effect(ModifierEffect const& effect) const;
+
+ void add_modifier(Modifier const& modifier, fixed_point_t multiplier = fixed_point_t::_1());
+ void add_modifier_sum(ModifierSum const& modifier_sum);
+
+ ModifierSum& operator+=(Modifier const& modifier);
+ ModifierSum& operator+=(ModifierSum const& modifier_sum);
+
+ std::vector<std::pair<Modifier const*, fixed_point_t>> get_contributing_modifiers(ModifierEffect const& effect) const;
+ };
+}