aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/modifier/Modifier.hpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-09-25 23:10:21 +0200
committer hop311 <hop3114@gmail.com>2024-10-05 22:48:41 +0200
commit4f9fd8a327b6de5fb32792a07453e9a2e245dc84 (patch)
treedc92397c8d16df21d612ad5159b8fd9b19353eb7 /src/openvic-simulation/modifier/Modifier.hpp
parentfb6b9439c219239691eb0201ec3f431b5dfe4893 (diff)
Add ModifierEffect targets
Diffstat (limited to 'src/openvic-simulation/modifier/Modifier.hpp')
-rw-r--r--src/openvic-simulation/modifier/Modifier.hpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/openvic-simulation/modifier/Modifier.hpp b/src/openvic-simulation/modifier/Modifier.hpp
index 4b032c0..a848cb8 100644
--- a/src/openvic-simulation/modifier/Modifier.hpp
+++ b/src/openvic-simulation/modifier/Modifier.hpp
@@ -10,31 +10,43 @@ namespace OpenVic {
struct ModifierEffect : HasIdentifier {
friend struct ModifierManager;
- enum class format_t {
+ enum class format_t : uint8_t {
PROPORTION_DECIMAL, /* An unscaled fraction/ratio, with 1 being "full"/"whole" */
PERCENTAGE_DECIMAL, /* A fraction/ratio scaled so that 100 is "full"/"whole" */
RAW_DECIMAL, /* A continuous quantity, e.g. attack strength */
INT /* A discrete quantity, e.g. building count limit */
};
+ enum class target_t : uint8_t {
+ NO_TARGETS = 0,
+ COUNTRY = 1 << 0,
+ PROVINCE = 1 << 1,
+ UNIT = 1 << 2,
+ ALL_TARGETS = (1 << 3) - 1
+ };
+
private:
/* If true, positive values will be green and negative values will be red.
* If false, the colours will be switced.
*/
const bool PROPERTY_CUSTOM_PREFIX(positive_good, is);
const format_t PROPERTY(format);
+ const target_t PROPERTY(targets);
std::string PROPERTY(localisation_key);
// TODO - format/precision, e.g. 80% vs 0.8 vs 0.800, 2 vs 2.0 vs 200%
ModifierEffect(
- std::string_view new_identifier, bool new_positive_good, format_t new_format, std::string_view new_localisation_key
+ std::string_view new_identifier, bool new_positive_good, format_t new_format, target_t mew_targets,
+ std::string_view new_localisation_key
);
public:
ModifierEffect(ModifierEffect&&) = default;
};
+ template<> struct enable_bitfield<ModifierEffect::target_t> : std::true_type {};
+
struct ModifierValue {
friend struct ModifierManager;
@@ -70,7 +82,8 @@ namespace OpenVic {
ModifierValue& operator*=(fixed_point_t const& right);
ModifierValue operator*(fixed_point_t const& right) const;
- void multiply_add(ModifierValue const& other, fixed_point_t multiplier);
+ void apply_target_filter(ModifierEffect::target_t targets);
+ void multiply_add_filter(ModifierValue const& other, fixed_point_t multiplier, ModifierEffect::target_t targets);
friend std::ostream& operator<<(std::ostream& stream, ModifierValue const& value);
};
@@ -167,6 +180,7 @@ namespace OpenVic {
bool add_modifier_effect(
std::string_view identifier, bool positive_good,
ModifierEffect::format_t format,
+ ModifierEffect::target_t targets,
std::string_view localisation_key = {}
);