aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/modifier/ModifierSum.hpp
blob: 957ffaba872a0150f308d675fc29ec0c43e0a0ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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;
   };
}