From d325f1070fda2c0aaee2aa9dccbbf89b7fae7153 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Thu, 28 Dec 2023 00:53:02 +0100 Subject: feat: rule and modifier loading for issues and reforms --- src/openvic-simulation/politics/Issue.hpp | 52 +++++++++++++++++-------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'src/openvic-simulation/politics/Issue.hpp') diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp index 0b3d4d3..a034959 100644 --- a/src/openvic-simulation/politics/Issue.hpp +++ b/src/openvic-simulation/politics/Issue.hpp @@ -1,8 +1,7 @@ #pragma once -#include -#include - +#include "openvic-simulation/politics/Rule.hpp" +#include "openvic-simulation/misc/Modifier.hpp" #include "openvic-simulation/dataloader/NodeTools.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" @@ -21,16 +20,19 @@ namespace OpenVic { }; // Issue (i.e. protectionism) - struct Issue : HasIdentifier { + struct Issue : Modifier { friend struct IssueManager; private: IssueGroup const& PROPERTY(group); - - // TODO: policy modifiers, policy rule changes + const RuleSet PROPERTY(rules); + const bool PROPERTY_CUSTOM_PREFIX(jingoism, is); protected: - Issue(std::string_view identifier, IssueGroup const& group); + Issue( + std::string_view new_identifier, ModifierValue&& new_values, IssueGroup const& new_group, + RuleSet&& new_rules, bool new_jingoism + ); public: Issue(Issue&&) = default; @@ -41,10 +43,10 @@ namespace OpenVic { friend struct IssueManager; private: - bool uncivilised; // whether this group is available to non-westernised countries + bool PROPERTY_CUSTOM_PREFIX(uncivilised, is); // whether this group is available to non-westernised countries // in vanilla education, military and economic reforms are hardcoded to true and the rest to false - ReformType(std::string_view new_identifier, bool uncivilised); + ReformType(std::string_view new_identifier, bool new_uncivilised); public: ReformType(ReformType&&) = default; @@ -59,7 +61,7 @@ namespace OpenVic { const bool PROPERTY_CUSTOM_PREFIX(ordered, is); // next_step_only const bool PROPERTY_CUSTOM_PREFIX(administrative, is); - ReformGroup(std::string_view identifier, ReformType const& type, bool ordered, bool administrative); + ReformGroup(std::string_view new_identifier, ReformType const& new_type, bool new_ordered, bool new_administrative); public: ReformGroup(ReformGroup&&) = default; @@ -68,14 +70,17 @@ namespace OpenVic { // Reform (i.e. yes_slavery) struct Reform : Issue { friend struct IssueManager; + using tech_cost_t = uint32_t; private: ReformGroup const& PROPERTY(reform_group); // stores an already casted reference const size_t PROPERTY(ordinal); // assigned by the parser to allow policy sorting + const tech_cost_t PROPERTY(technology_cost); - Reform(std::string_view new_identifier, ReformGroup const& group, size_t ordinal); - - // TODO: conditions to allow, + Reform( + std::string_view new_identifier, ModifierValue&& new_values, ReformGroup const& new_group, size_t new_ordinal, + RuleSet&& new_rules, tech_cost_t new_technology_cost + ); public: Reform(Reform&&) = default; @@ -91,23 +96,24 @@ namespace OpenVic { IdentifierRegistry IDENTIFIER_REGISTRY(reform); bool _load_issue_group(size_t& expected_issues, std::string_view identifier, ast::NodeCPtr node); - bool _load_issue(std::string_view identifier, IssueGroup const* group, ast::NodeCPtr node); + bool _load_issue( + ModifierManager const& modifier_manager, RuleManager const& rule_manager, std::string_view identifier, + IssueGroup const* group, ast::NodeCPtr node + ); bool _load_reform_group( size_t& expected_reforms, std::string_view identifier, ReformType const* type, ast::NodeCPtr node ); - bool _load_reform(size_t& ordinal, std::string_view identifier, ReformGroup const* group, ast::NodeCPtr node); + bool _load_reform( + ModifierManager const& modifier_manager, RuleManager const& rule_manager, size_t ordinal, std::string_view identifier, + ReformGroup const* group, ast::NodeCPtr node + ); public: bool add_issue_group(std::string_view identifier); - - bool add_issue(std::string_view identifier, IssueGroup const* group); - + bool add_issue(std::string_view identifier, ModifierValue&& values, IssueGroup const* group, RuleSet&& rules, bool jingoism); bool add_reform_type(std::string_view identifier, bool uncivilised); - bool add_reform_group(std::string_view identifier, ReformType const* type, bool ordered, bool administrative); - - bool add_reform(std::string_view identifier, ReformGroup const* group, size_t ordinal); - - bool load_issues_file(ast::NodeCPtr root); + bool add_reform(std::string_view identifier, ModifierValue&& values, ReformGroup const* group, size_t ordinal, RuleSet&& rules, Reform::tech_cost_t technology_cost); + bool load_issues_file(ModifierManager const& modifier_manager, RuleManager const& rule_manager, ast::NodeCPtr root); }; } -- cgit v1.2.3-56-ga3b1