diff options
author | George L. Albany <Megacake1234@gmail.com> | 2024-01-19 12:08:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-19 12:08:19 +0100 |
commit | 04e8d365687e5ce6d803f1b3d4c8fb7f2358079b (patch) | |
tree | 4b911cea0cf5e5ac467bbbd2073144866c52b265 /src/openvic-simulation/diplomacy/DiplomaticAction.hpp | |
parent | c1bac9acee88a7ce1123aed3a748712fb2441762 (diff) | |
parent | 3f9911dd1cbfca513c8615d778a8295906d8b7d5 (diff) |
Merge pull request #119 from OpenVicProject/add/country-relations
Diffstat (limited to 'src/openvic-simulation/diplomacy/DiplomaticAction.hpp')
-rw-r--r-- | src/openvic-simulation/diplomacy/DiplomaticAction.hpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/openvic-simulation/diplomacy/DiplomaticAction.hpp b/src/openvic-simulation/diplomacy/DiplomaticAction.hpp index 8f659c6..352b16e 100644 --- a/src/openvic-simulation/diplomacy/DiplomaticAction.hpp +++ b/src/openvic-simulation/diplomacy/DiplomaticAction.hpp @@ -8,17 +8,20 @@ #include <variant> #include "openvic-simulation/country/Country.hpp" +#include "openvic-simulation/country/CountryInstance.hpp" #include "openvic-simulation/types/FunctionRef.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" namespace OpenVic { + struct GameManager; + struct DiplomaticActionType { friend struct DiplomaticActionManager; friend struct CancelableDiplomaticActionType; struct Argument { - Country& sender; - Country& reciever; + CountryInstance* sender; + CountryInstance* reciever; std::any context_data; }; @@ -68,7 +71,7 @@ namespace OpenVic { allowed_to_cancel_func allowed_cancel = allowed_to_cancel_default; operator DiplomaticActionType::Initializer() { - return {commit, allowed, get_acceptance}; + return { commit, allowed, get_acceptance }; } }; @@ -87,7 +90,7 @@ namespace OpenVic { constexpr DiplomaticActionTypeStorage(std::string_view identifier, T&& t) : HasIdentifier(identifier), base_type(t) {} template<class Visitor> - constexpr decltype(auto) visit(Visitor&& vis){ + constexpr decltype(auto) visit(Visitor&& vis) { return std::visit(std::forward<Visitor>(vis), *this); } @@ -99,7 +102,7 @@ namespace OpenVic { constexpr bool is_cancelable() const { return visit([](auto&& arg) -> bool { using T = std::decay_t<decltype(arg)>; - if constexpr(std::same_as<T, CancelableDiplomaticActionType>) { + if constexpr (std::same_as<T, CancelableDiplomaticActionType>) { return true; } else { return false; @@ -123,11 +126,14 @@ namespace OpenVic { DiplomaticActionManager(); bool add_diplomatic_action(std::string_view identifier, DiplomaticActionType::Initializer&& initializer); - bool add_cancelable_diplomatic_action(std::string_view identifier, CancelableDiplomaticActionType::Initializer&& initializer); + bool add_cancelable_diplomatic_action( + std::string_view identifier, CancelableDiplomaticActionType::Initializer&& initializer + ); - DiplomaticActionTickCache - create_diplomatic_action_tick(std::string_view identifier, Country& sender, Country& reciever, std::any context_data); + DiplomaticActionTickCache create_diplomatic_action_tick( + std::string_view identifier, CountryInstance* sender, CountryInstance* reciever, std::any context_data + ); - bool setup_diplomatic_actions(); + bool setup_diplomatic_actions(GameManager& manager); }; } |