diff options
author | hop311 <hop3114@gmail.com> | 2023-12-31 01:47:31 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-01-02 14:41:28 +0100 |
commit | 5f64f983d0cead266a28791be42162c443fd2a75 (patch) | |
tree | da5fbb48d6c01d6faedd16b46ff846c65fdb4c33 /src/openvic-simulation/military/Wargoal.hpp | |
parent | 9988b21278dc1c8df044631bd2935a7e450a7bff (diff) |
Added framework for loading all Conditions and Effects
Diffstat (limited to 'src/openvic-simulation/military/Wargoal.hpp')
-rw-r--r-- | src/openvic-simulation/military/Wargoal.hpp | 115 |
1 files changed, 59 insertions, 56 deletions
diff --git a/src/openvic-simulation/military/Wargoal.hpp b/src/openvic-simulation/military/Wargoal.hpp index 66fce90..a4f2e7c 100644 --- a/src/openvic-simulation/military/Wargoal.hpp +++ b/src/openvic-simulation/military/Wargoal.hpp @@ -1,6 +1,8 @@ #pragma once #include "openvic-simulation/misc/Modifier.hpp" +#include "openvic-simulation/scripts/ConditionScript.hpp" +#include "openvic-simulation/scripts/EffectScript.hpp" #include "openvic-simulation/types/EnumBitfield.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" #include "openvic-simulation/utility/Getters.hpp" @@ -9,30 +11,33 @@ namespace OpenVic { struct WargoalTypeManager; enum class peace_options_t : uint32_t { - PO_ANNEX = 0b100000000000000000, - PO_DEMAND_STATE = 0b010000000000000000, - PO_COLONY = 0b001000000000000000, - PO_ADD_TO_SPHERE = 0b000100000000000000, - PO_DISARMAMENT = 0b000010000000000000, - PO_REMOVE_FORTS = 0b000001000000000000, - PO_REMOVE_NAVAL_BASES = 0b000000100000000000, - PO_REPARATIONS = 0b000000010000000000, - PO_REPAY_DEBT = 0b000000001000000000, - PO_REMOVE_PRESTIGE = 0b000000000100000000, - PO_MAKE_PUPPET = 0b000000000010000000, - PO_RELEASE_PUPPET = 0b000000000001000000, - PO_STATUS_QUO = 0b000000000000100000, - PO_INSTALL_COMMUNISM = 0b000000000000010000, - PO_REMOVE_COMMUNISM = 0b000000000000001000, - PO_REMOVE_CORES = 0b000000000000000100, // only usable with ANNEX, DEMAND_STATE, or TRANSFER_PROVINCES - PO_TRANSFER_PROVINCES = 0b000000000000000010, - PO_CLEAR_UNION_SPHERE = 0b000000000000000001 + NO_PEACE_OPTIONS = 0, + PO_ANNEX = 1 << 0, + PO_DEMAND_STATE = 1 << 1, + PO_COLONY = 1 << 2, + PO_ADD_TO_SPHERE = 1 << 3, + PO_DISARMAMENT = 1 << 4, + PO_REMOVE_FORTS = 1 << 5, + PO_REMOVE_NAVAL_BASES = 1 << 6, + PO_REPARATIONS = 1 << 7, + PO_REPAY_DEBT = 1 << 8, + PO_REMOVE_PRESTIGE = 1 << 9, + PO_MAKE_PUPPET = 1 << 10, + PO_RELEASE_PUPPET = 1 << 11, + PO_STATUS_QUO = 1 << 12, + PO_INSTALL_COMMUNISM = 1 << 13, + PO_REMOVE_COMMUNISM = 1 << 14, + PO_REMOVE_CORES = 1 << 15, // only usable with ANNEX, DEMAND_STATE, or TRANSFER_PROVINCES + PO_TRANSFER_PROVINCES = 1 << 16, + PO_CLEAR_UNION_SPHERE = 1 << 17 }; template<> struct enable_bitfield<peace_options_t> : std::true_type{}; struct WargoalType : HasIdentifier { friend struct WargoalTypeManager; + using sprite_t = uint8_t; + enum class PEACE_MODIFIERS { BADBOY_FACTOR, PRESTIGE_FACTOR, @@ -50,37 +55,41 @@ namespace OpenVic { using peace_modifiers_t = fixed_point_map_t<PEACE_MODIFIERS>; private: - const std::string PROPERTY(sprite); - const std::string PROPERTY(war_name); + std::string PROPERTY(war_name); const Timespan PROPERTY(available_length); const Timespan PROPERTY(truce_length); - const bool PROPERTY(triggered_only); // only able to be added via effects (or within the code) - const bool PROPERTY(civil_war); + const sprite_t PROPERTY(sprite_index); + const bool PROPERTY_CUSTOM_PREFIX(triggered_only, is); // only able to be added via effects or on_actions + const bool PROPERTY_CUSTOM_PREFIX(civil_war, is); const bool PROPERTY(constructing); // can be added to existing wars or justified const bool PROPERTY(crisis); // able to be added to crises - const bool PROPERTY(great_war); // automatically add to great wars - const bool PROPERTY(mutual); // attacked and defender share wargoal - const peace_modifiers_t PROPERTY(modifiers); - const peace_options_t PROPERTY(peace_options); - - // TODO: can_use, prerequisites, on_add, on_po_accepted + const bool PROPERTY_CUSTOM_PREFIX(great_war_obligatory, is); // automatically add to great war peace offers/demands + const bool PROPERTY_CUSTOM_PREFIX(mutual, is); // attacked and defender share wargoal + const bool PROPERTY(all_allowed_states); // take all valid states rather than just one + const bool PROPERTY(always); // available without justifying + peace_modifiers_t PROPERTY(modifiers); + peace_options_t PROPERTY(peace_options); + ConditionScript PROPERTY(can_use); + ConditionScript PROPERTY(is_valid); + ConditionScript PROPERTY(allowed_states); + ConditionScript PROPERTY(allowed_substate_regions); + ConditionScript PROPERTY(allowed_states_in_crisis); + ConditionScript PROPERTY(allowed_countries); + EffectScript PROPERTY(on_add); + EffectScript PROPERTY(on_po_accepted); WargoalType( - std::string_view new_identifier, - std::string_view new_sprite, - std::string_view new_war_name, - Timespan new_available_length, - Timespan new_truce_length, - bool new_triggered_only, - bool new_civil_war, - bool new_constructing, - bool new_crisis, - bool new_great_war, - bool new_mutual, - const peace_modifiers_t&& new_modifiers, - peace_options_t new_peace_options + std::string_view new_identifier, std::string_view new_war_name, Timespan new_available_length, + Timespan new_truce_length, sprite_t new_sprite_index, bool new_triggered_only, bool new_civil_war, + bool new_constructing, bool new_crisis, bool new_great_war_obligatory, bool new_mutual, + bool new_all_allowed_states, bool new_always, peace_modifiers_t&& new_modifiers, peace_options_t new_peace_options, + ConditionScript&& new_can_use, ConditionScript&& new_is_valid, ConditionScript&& new_allowed_states, + ConditionScript&& new_allowed_substate_regions, ConditionScript&& new_allowed_states_in_crisis, + ConditionScript&& new_allowed_countries, EffectScript&& new_on_add, EffectScript&& new_on_po_accepted ); + bool parse_scripts(GameManager& game_manager); + public: WargoalType(WargoalType&&) = default; }; @@ -91,24 +100,18 @@ namespace OpenVic { std::vector<WargoalType const*> PROPERTY(peace_priorities); public: - const std::vector<WargoalType const*>& get_peace_priority_list() const; - bool add_wargoal_type( - std::string_view identifier, - std::string_view sprite, - std::string_view war_name, - Timespan available_length, - Timespan truce_length, - bool triggered_only, - bool civil_war, - bool constructing, - bool crisis, - bool great_war, - bool mutual, - WargoalType::peace_modifiers_t&& modifiers, - peace_options_t peace_options + std::string_view identifier, std::string_view war_name, Timespan available_length, + Timespan truce_length, WargoalType::sprite_t sprite_index, bool triggered_only, bool civil_war, + bool constructing, bool crisis, bool great_war_obligatory, bool mutual, bool all_allowed_states, + bool always, WargoalType::peace_modifiers_t&& modifiers, peace_options_t peace_options, + ConditionScript&& can_use, ConditionScript&& is_valid, ConditionScript&& allowed_states, + ConditionScript&& allowed_substate_regions, ConditionScript&& allowed_states_in_crisis, + ConditionScript&& allowed_countries, EffectScript&& on_add, EffectScript&& on_po_accepted ); bool load_wargoal_file(ast::NodeCPtr root); + + bool parse_scripts(GameManager& game_manager); }; } // namespace OpenVic
\ No newline at end of file |