aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/misc/Modifier.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/misc/Modifier.hpp')
-rw-r--r--src/openvic-simulation/misc/Modifier.hpp53
1 files changed, 48 insertions, 5 deletions
diff --git a/src/openvic-simulation/misc/Modifier.hpp b/src/openvic-simulation/misc/Modifier.hpp
index 34acd9d..9665e07 100644
--- a/src/openvic-simulation/misc/Modifier.hpp
+++ b/src/openvic-simulation/misc/Modifier.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "openvic-simulation/types/IdentifierRegistry.hpp"
+#include <unordered_set>
namespace OpenVic {
struct ModifierManager;
@@ -10,7 +11,7 @@ namespace OpenVic {
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 */
+ INT /* A discrete quantity, e.g. building count limit */
};
friend std::unique_ptr<ModifierEffect> std::make_unique<ModifierEffect>(std::string_view&&, bool&&, format_t&&);
@@ -19,7 +20,7 @@ namespace OpenVic {
/* If true, positive values will be green and negative values will be red.
* If false, the colours will be switced.
*/
- const bool PROPERTY_CUSTOM_NAME(positive_good, is_positive_good);
+ const bool PROPERTY_CUSTOM_PREFIX(positive_good, is);
const format_t PROPERTY(format);
// TODO - format/precision, e.g. 80% vs 0.8 vs 0.800, 2 vs 2.0 vs 200%
@@ -72,12 +73,39 @@ namespace OpenVic {
/* A modifier can have no icon (zero). */
const icon_t PROPERTY(icon);
+ protected:
Modifier(std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon);
public:
Modifier(Modifier&&) = default;
};
+ struct TriggeredModifier : Modifier {
+ friend struct ModifierManager;
+
+ private:
+ // TODO - trigger condition
+
+ protected:
+ TriggeredModifier(std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon);
+
+ public:
+ TriggeredModifier(TriggeredModifier&&) = default;
+ };
+
+ struct Crime final : TriggeredModifier {
+ friend struct ModifierManager;
+
+ private:
+ const bool PROPERTY(default_active);
+ bool PROPERTY_RW(active);
+
+ Crime(std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon, bool new_default_active);
+
+ public:
+ Crime(Crime&&) = default;
+ };
+
struct ModifierInstance {
private:
@@ -97,7 +125,12 @@ namespace OpenVic {
*/
private:
IdentifierInstanceRegistry<ModifierEffect> modifier_effects;
+ string_set_t complex_modifiers;
+
+ IdentifierRegistry<Crime> crime_modifiers;
IdentifierRegistry<Modifier> event_modifiers;
+ IdentifierRegistry<Modifier> static_modifiers;
+ IdentifierRegistry<TriggeredModifier> triggered_modifiers;
/* effect_validator takes in ModifierEffect const& */
NodeTools::key_value_callback_t _modifier_effect_callback(
@@ -109,19 +142,29 @@ namespace OpenVic {
ModifierManager();
bool add_modifier_effect(
- std::string_view identifier, bool province_good,
+ std::string_view identifier, bool positive_good,
ModifierEffect::format_t format = ModifierEffect::format_t::PROPORTION_DECIMAL
);
IDENTIFIER_REGISTRY_ACCESSORS(modifier_effect)
- bool add_event_modifier(std::string_view identifier, ModifierValue&& values, Modifier::icon_t icon);
- IDENTIFIER_REGISTRY_ACCESSORS(event_modifier)
+ void register_complex_modifier(std::string_view identifier);
bool setup_modifier_effects();
+ bool add_crime_modifier(std::string_view identifier, ModifierValue&& values, Modifier::icon_t icon, bool active);
+ IDENTIFIER_REGISTRY_ACCESSORS(crime_modifier)
bool load_crime_modifiers(ast::NodeCPtr root);
+
+ bool add_event_modifier(std::string_view identifier, ModifierValue&& values, Modifier::icon_t icon);
+ IDENTIFIER_REGISTRY_ACCESSORS(event_modifier)
bool load_event_modifiers(ast::NodeCPtr root);
+
+ bool add_static_modifier(std::string_view identifier, ModifierValue&& values);
+ IDENTIFIER_REGISTRY_ACCESSORS(static_modifier)
bool load_static_modifiers(ast::NodeCPtr root);
+
+ bool add_triggered_modifier(std::string_view identifier, ModifierValue&& values, Modifier::icon_t icon);
+ IDENTIFIER_REGISTRY_ACCESSORS(triggered_modifier)
bool load_triggered_modifiers(ast::NodeCPtr root);
NodeTools::node_callback_t expect_validated_modifier_value_and_default(