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/Modifier.hpp | |
parent | 7c312e21c6ac3a28fe5f7963ffe12b409cce643c (diff) |
Add ModifierSum and improve ModifierValue and RuleSet
Diffstat (limited to 'src/openvic-simulation/modifier/Modifier.hpp')
-rw-r--r-- | src/openvic-simulation/modifier/Modifier.hpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/openvic-simulation/modifier/Modifier.hpp b/src/openvic-simulation/modifier/Modifier.hpp index f3cc0f6..f525d6a 100644 --- a/src/openvic-simulation/modifier/Modifier.hpp +++ b/src/openvic-simulation/modifier/Modifier.hpp @@ -57,14 +57,21 @@ namespace OpenVic { void clear(); bool empty() const; - fixed_point_t get_effect(ModifierEffect const* effect, bool* successful = nullptr); - bool has_effect(ModifierEffect const* effect) const; + fixed_point_t get_effect(ModifierEffect const& effect, bool* effect_found = nullptr) const; + bool has_effect(ModifierEffect const& effect) const; + void set_effect(ModifierEffect const& effect, fixed_point_t value); ModifierValue& operator+=(ModifierValue const& right); ModifierValue operator+(ModifierValue const& right) const; ModifierValue operator-() const; ModifierValue& operator-=(ModifierValue const& right); ModifierValue operator-(ModifierValue const& right) const; + ModifierValue& operator*=(fixed_point_t const& right); + ModifierValue operator*(fixed_point_t const& right) const; + + fixed_point_t& operator[](ModifierEffect const& effect); + + void multiply_add(ModifierValue const& other, fixed_point_t multiplier); friend std::ostream& operator<<(std::ostream& stream, ModifierValue const& value); }; @@ -105,10 +112,11 @@ namespace OpenVic { struct ModifierInstance { private: - Modifier const& PROPERTY(modifier); + Modifier const* PROPERTY(modifier); // We can assume this is never null Date PROPERTY(expiry_date); - ModifierInstance(Modifier const& modifier, Date expiry_date); + public: + ModifierInstance(Modifier const& new_modifier, Date new_expiry_date); }; template<typename Fn> |