diff options
author | hop311 <hop3114@gmail.com> | 2024-09-20 14:02:17 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-09-20 14:06:40 +0200 |
commit | 3703851ced696a2d4559c3e3340c537982d5ebc7 (patch) | |
tree | 0f103095b45de46688206d0e33e24f0331afbabd /src/openvic-simulation/modifier/ModifierSum.hpp | |
parent | 7c312e21c6ac3a28fe5f7963ffe12b409cce643c (diff) |
Add ModifierSum and improve ModifierValue and RuleSet
Diffstat (limited to 'src/openvic-simulation/modifier/ModifierSum.hpp')
-rw-r--r-- | src/openvic-simulation/modifier/ModifierSum.hpp | 30 |
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; + }; +} |