From 4e2e6e541f0dde406f90f668d6ff153f95d2aa45 Mon Sep 17 00:00:00 2001 From: Joel Machens Date: Sat, 4 Nov 2023 22:09:49 -0500 Subject: Implement Wargoal Loading --- src/openvic-simulation/military/Wargoal.hpp | 129 ++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 src/openvic-simulation/military/Wargoal.hpp (limited to 'src/openvic-simulation/military/Wargoal.hpp') diff --git a/src/openvic-simulation/military/Wargoal.hpp b/src/openvic-simulation/military/Wargoal.hpp new file mode 100644 index 0000000..fc9e3af --- /dev/null +++ b/src/openvic-simulation/military/Wargoal.hpp @@ -0,0 +1,129 @@ +#pragma once + +#include "openvic-simulation/types/IdentifierRegistry.hpp" +#include "openvic-simulation/types/EnumBitfield.hpp" +#include "openvic-simulation/Modifier.hpp" + +namespace OpenVic { + struct WargoalTypeManager; + + enum class peace_options_t : uint32_t { + PO_ANNEX = 0b1000000000000000, + PO_DEMAND_STATE = 0b0100000000000000, + PO_COLONY = 0b0010000000000000, + PO_ADD_TO_SPHERE = 0b0001000000000000, + PO_DISARMAMENT = 0b0000100000000000, + PO_REMOVE_FORTS = 0b0000100000000000, + PO_REMOVE_NAVAL_BASES = 0b0000100000000000, + PO_REPARATIONS = 0b0000010000000000, + PO_REPAY_DEBT = 0b0000001000000000, + PO_REMOVE_PRESTIGE = 0b0000000100000000, + PO_MAKE_PUPPET = 0b0000000010000000, + PO_RELEASE_PUPPET = 0b0000000001000000, + PO_STATUS_QUO = 0b0000000000100000, + PO_INSTALL_COMMUNISM = 0b0000000000010000, + PO_REMOVE_COMMUNISM = 0b0000000000001000, + PO_REMOVE_CORES = 0b0000000000000100, // only usable with ANNEX, DEMAND_STATE, or TRANSFER_PROVINCES + PO_TRANSFER_PROVINCES = 0b0000000000000010, + PO_CLEAR_UNION_SPHERE = 0b0000000000000001 + }; + template<> struct enable_bitfield : std::true_type{}; + + struct WargoalType : HasIdentifier { + friend struct WargoalTypeManager; + + enum class PEACE_MODIFIERS { + BADBOY_FACTOR, + PRESTIGE_FACTOR, + PEACE_COST_FACTOR, + PENALTY_FACTOR, + BREAK_TRUCE_PRESTIGE_FACTOR, + BREAK_TRUCE_INFAMY_FACTOR, + BREAK_TRUCE_MILITANCY_FACTOR, + GOOD_RELATION_PRESTIGE_FACTOR, + GOOD_RELATION_INFAMY_FACTOR, + GOOD_RELATION_MILITANCY_FACTOR, + WAR_SCORE_BATTLE_FACTOR, + CONSTRUCTION_SPEED + }; + using peace_modifiers_t = std::map; + + private: + const std::string sprite; + const std::string war_name; + const Timespan available_length; + const Timespan truce_length; + const bool triggered_only; // only able to be added via effects (or within the code) + const bool civil_war; + const bool constructing; // can be added to existing wars or justified + const bool crisis; // able to be added to crises + const bool great_war; // automatically add to great wars + const bool mutual; // attacked and defender share wargoal + const peace_modifiers_t modifiers; + const peace_options_t peace_options; + + // TODO: can_use, prerequisites, on_add, 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 + ); + + public: + WargoalType(WargoalType&&) = default; + + std::string_view get_sprite() const; + std::string_view get_war_name() const; + const Timespan get_available_length() const; + const Timespan get_truce_length() const; + const bool is_triggered_only() const; + const bool is_civil_war() const; + const bool is_constructing() const; + const bool is_crisis() const; + const bool is_great_war() const; + const bool is_mutual() const; + peace_modifiers_t const& get_modifiers() const; + const peace_options_t get_peace_options() const; + }; + + struct WargoalTypeManager { + private: + IdentifierRegistry wargoal_types; + std::vector peace_priorities; + + public: + WargoalTypeManager(); + + const std::vector& 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 + ); + IDENTIFIER_REGISTRY_ACCESSORS(wargoal_type) + + bool load_wargoal_file(ast::NodeCPtr root); + }; +} // namespace OpenVic \ No newline at end of file -- cgit v1.2.3-56-ga3b1