diff options
Diffstat (limited to 'src/openvic-simulation/military')
-rw-r--r-- | src/openvic-simulation/military/Deployment.cpp | 15 | ||||
-rw-r--r-- | src/openvic-simulation/military/Deployment.hpp | 4 | ||||
-rw-r--r-- | src/openvic-simulation/military/Unit.cpp | 4 | ||||
-rw-r--r-- | src/openvic-simulation/military/Wargoal.cpp | 8 | ||||
-rw-r--r-- | src/openvic-simulation/military/Wargoal.hpp | 52 |
5 files changed, 42 insertions, 41 deletions
diff --git a/src/openvic-simulation/military/Deployment.cpp b/src/openvic-simulation/military/Deployment.cpp index da860ad..d4a092b 100644 --- a/src/openvic-simulation/military/Deployment.cpp +++ b/src/openvic-simulation/military/Deployment.cpp @@ -7,9 +7,9 @@ using namespace OpenVic::NodeTools; Leader::Leader( std::string_view new_name, Unit::type_t new_type, Date new_date, LeaderTrait const* new_personality, - LeaderTrait const* new_background, fixed_point_t new_prestige + LeaderTrait const* new_background, fixed_point_t new_prestige, std::string_view new_picture ) : name { new_name }, type { new_type }, date { new_date }, personality { new_personality }, background { new_background }, - prestige { new_prestige } {} + prestige { new_prestige }, picture { new_picture } {} Regiment::Regiment(std::string_view new_name, Unit const* new_type, Province const* new_home) : name { new_name }, type { new_type }, home { new_home } {} @@ -76,9 +76,10 @@ bool DeploymentManager::load_oob_file( LeaderTrait const* leader_personality = nullptr; LeaderTrait const* leader_background = nullptr; fixed_point_t leader_prestige = 0; + std::string_view picture {}; bool ret = expect_dictionary_keys( - "name", ONE_EXACTLY, expect_string(assign_variable_callback(leader_name)), + "name", ONE_EXACTLY, expect_identifier_or_string(assign_variable_callback(leader_name)), "date", ONE_EXACTLY, expect_identifier_or_string(expect_date_str(assign_variable_callback(leader_date))), "type", ONE_EXACTLY, expect_identifier(UnitManager::expect_type_str(assign_variable_callback(leader_type))), "personality", ONE_EXACTLY, game_manager.get_military_manager().get_leader_trait_manager() @@ -86,7 +87,7 @@ bool DeploymentManager::load_oob_file( "background", ONE_EXACTLY, game_manager.get_military_manager().get_leader_trait_manager() .expect_leader_trait_identifier(assign_variable_callback_pointer(leader_background)), "prestige", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(leader_prestige)), - "picture", ZERO_OR_ONE, success_callback + "picture", ZERO_OR_ONE, expect_identifier_or_string(assign_variable_callback(picture)) )(node); if (!leader_personality->is_personality_trait()) { @@ -104,7 +105,7 @@ bool DeploymentManager::load_oob_file( ret = false; } leaders.emplace_back( - leader_name, leader_type, leader_date, leader_personality, leader_background, leader_prestige + leader_name, leader_type, leader_date, leader_personality, leader_background, leader_prestige, picture ); return ret; }, @@ -134,7 +135,7 @@ bool DeploymentManager::load_oob_file( army_regiments.emplace_back(regiment_name, regiment_type, regiment_home); return ret; }, - /* another paradox gem, tested in game and they don't lead the army or even show up */ + /* Another paradox gem, tested in game and they don't lead the army or even show up */ "leader", ZERO_OR_MORE, success_callback )(node); armies.emplace_back(army_name, army_location, std::move(army_regiments)); @@ -160,7 +161,7 @@ bool DeploymentManager::load_oob_file( navy_ships.emplace_back(ship_name, ship_type); return ret; }, - /* another paradox gem, tested in game and they don't lead the army or even show up */ + /* Another paradox gem, tested in game and they don't lead the army or even show up */ "leader", ZERO_OR_MORE, success_callback )(node); navies.emplace_back(navy_name, navy_location, std::move(navy_ships)); diff --git a/src/openvic-simulation/military/Deployment.hpp b/src/openvic-simulation/military/Deployment.hpp index 2aef314..a952823 100644 --- a/src/openvic-simulation/military/Deployment.hpp +++ b/src/openvic-simulation/military/Deployment.hpp @@ -1,6 +1,5 @@ #pragma once -#include <filesystem> #include <string> #include <string_view> #include <vector> @@ -22,11 +21,12 @@ namespace OpenVic { LeaderTrait const* PROPERTY(personality); LeaderTrait const* PROPERTY(background); fixed_point_t PROPERTY(prestige); + std::string PROPERTY(picture); public: Leader( std::string_view new_name, Unit::type_t new_type, Date new_date, LeaderTrait const* new_personality, - LeaderTrait const* new_background, fixed_point_t new_prestige + LeaderTrait const* new_background, fixed_point_t new_prestige, std::string_view new_picture ); }; diff --git a/src/openvic-simulation/military/Unit.cpp b/src/openvic-simulation/military/Unit.cpp index 9981c86..d0f6435 100644 --- a/src/openvic-simulation/military/Unit.cpp +++ b/src/openvic-simulation/military/Unit.cpp @@ -104,10 +104,10 @@ bool UnitManager::load_unit_file(GoodManager const& good_manager, ast::NodeCPtr } key_map_t key_map; - // shared + /* Shared dictionary entries */ ret &= add_key_map_entries(key_map, "icon", ONE_EXACTLY, expect_uint(assign_variable_callback(icon)), - "type", ONE_EXACTLY, success_callback, + "type", ONE_EXACTLY, success_callback, /* Already loaded above using expect_key */ "sprite", ONE_EXACTLY, expect_identifier(assign_variable_callback(sprite)), "active", ZERO_OR_ONE, expect_bool(assign_variable_callback(active)), "unit_type", ONE_EXACTLY, expect_identifier(assign_variable_callback(unit_type)), diff --git a/src/openvic-simulation/military/Wargoal.cpp b/src/openvic-simulation/military/Wargoal.cpp index 6351ce3..4045fa5 100644 --- a/src/openvic-simulation/military/Wargoal.cpp +++ b/src/openvic-simulation/military/Wargoal.cpp @@ -41,7 +41,7 @@ bool WargoalTypeManager::add_wargoal_type( 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, + bool always, WargoalType::peace_modifiers_t&& modifiers, WargoalType::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 @@ -75,14 +75,14 @@ bool WargoalTypeManager::load_wargoal_file(ast::NodeCPtr root) { return true; } - using enum peace_options_t; + using enum WargoalType::peace_options_t; std::string_view war_name; Timespan available {}, truce {}; WargoalType::sprite_t sprite_index = 0; bool triggered_only = false, civil_war = false, constructing = true, crisis = true, great_war_obligatory = false, mutual = false, all_allowed_states = false, always = false; - peace_options_t peace_options = NO_PEACE_OPTIONS; + WargoalType::peace_options_t peace_options = NO_PEACE_OPTIONS; WargoalType::peace_modifiers_t modifiers; ConditionScript can_use { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::COUNTRY }; ConditionScript is_valid { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::COUNTRY }; @@ -92,7 +92,7 @@ bool WargoalTypeManager::load_wargoal_file(ast::NodeCPtr root) { ConditionScript allowed_countries { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::COUNTRY }; EffectScript on_add, on_po_accepted; //country as default scope for both - const auto expect_peace_option = [&peace_options](peace_options_t peace_option) -> node_callback_t { + const auto expect_peace_option = [&peace_options](WargoalType::peace_options_t peace_option) -> node_callback_t { return expect_bool([&peace_options, peace_option](bool val) -> bool { if (val) { peace_options |= peace_option; diff --git a/src/openvic-simulation/military/Wargoal.hpp b/src/openvic-simulation/military/Wargoal.hpp index a4f2e7c..d9d51f6 100644 --- a/src/openvic-simulation/military/Wargoal.hpp +++ b/src/openvic-simulation/military/Wargoal.hpp @@ -1,6 +1,5 @@ #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" @@ -10,35 +9,12 @@ namespace OpenVic { struct WargoalTypeManager; - enum class peace_options_t : uint32_t { - 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 { + enum class PEACE_MODIFIERS : uint8_t { BADBOY_FACTOR, PRESTIGE_FACTOR, PEACE_COST_FACTOR, @@ -54,6 +30,28 @@ namespace OpenVic { }; using peace_modifiers_t = fixed_point_map_t<PEACE_MODIFIERS>; + enum class peace_options_t : uint32_t { + 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 + }; + private: std::string PROPERTY(war_name); const Timespan PROPERTY(available_length); @@ -94,6 +92,8 @@ namespace OpenVic { WargoalType(WargoalType&&) = default; }; + template<> struct enable_bitfield<WargoalType::peace_options_t> : std::true_type{}; + struct WargoalTypeManager { private: IdentifierRegistry<WargoalType> IDENTIFIER_REGISTRY(wargoal_type); @@ -104,7 +104,7 @@ namespace OpenVic { 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, + bool always, WargoalType::peace_modifiers_t&& modifiers, WargoalType::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 |