From 67d7a855992ab25ff2c47b12860c2eb7c9241ae2 Mon Sep 17 00:00:00 2001 From: Joel Machens Date: Sat, 4 Nov 2023 22:47:41 -0500 Subject: Diplomacy History Loading --- .../history/DiplomaticHistory.hpp | 131 +++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 src/openvic-simulation/history/DiplomaticHistory.hpp (limited to 'src/openvic-simulation/history/DiplomaticHistory.hpp') diff --git a/src/openvic-simulation/history/DiplomaticHistory.hpp b/src/openvic-simulation/history/DiplomaticHistory.hpp new file mode 100644 index 0000000..84c2bd7 --- /dev/null +++ b/src/openvic-simulation/history/DiplomaticHistory.hpp @@ -0,0 +1,131 @@ +#pragma once + +#include +#include +#include +#include + +#include "openvic-simulation/country/Country.hpp" +#include "openvic-simulation/military/Wargoal.hpp" + +namespace OpenVic { + struct DiplomaticHistoryManager; + + struct WarHistory { + friend struct DiplomaticHistoryManager; + + struct added_wargoal_t { + friend struct DiplomaticHistoryManager; + + private: + Date added; + Country const* actor; + Country const* receiver; + WargoalType const* wargoal; + std::optional third_party; + std::optional target; + + added_wargoal_t(Date new_added, Country const* new_actor, Country const* new_receiver, WargoalType const* new_wargoal, std::optional new_third_party, std::optional new_target); + + public: + Date get_date_added() const; + Country const* get_actor() const; + Country const* get_receiver() const; + WargoalType const* get_wargoal_type() const; + std::optional const& get_third_party() const; + std::optional const& get_target() const; + }; + + struct war_participant_t { + friend struct DiplomaticHistoryManager; + + private: + Country const* country; + Date joined; + std::optional exited; + + war_participant_t(Country const* new_country, Date new_joined, std::optional new_exited); + + public: + Country const* get_country() const; + Date get_date_joined() const; + std::optional get_date_exited() const; + }; + + private: + std::string war_name; // edge cases where this is empty/undef for some reason, probably need to just generate war names like usual for that. + std::vector attackers; + std::vector defenders; + std::vector wargoals; + + WarHistory(std::string_view new_war_name, std::vector&& new_attackers, std::vector&& new_defenders, std::vector&& new_wargoals); + + public: + std::string_view get_war_name() const; + std::vector const& get_attackers() const; + std::vector const& get_defenders() const; + std::vector const& get_wargoals() const; + }; + + struct AllianceHistory { + friend struct DiplomaticHistoryManager; + + private: + Country const* first; + Country const* second; + const Date start; + const Date end; + + AllianceHistory(Country const* new_first, Country const* new_second, const Date new_start, const Date new_end); + + public: + Country const* get_first() const; + Country const* get_second() const; + }; + + struct SubjectHistory { + friend struct DiplomaticHistoryManager; + + enum class type_t { + VASSAL, + UNION, + SUBSTATE + }; + + private: + Country const* overlord; + Country const* subject; + const type_t type; + const Date start; + const Date end; + + SubjectHistory(Country const* new_overlord, Country const* new_subject, const type_t new_type, const Date new_start, const Date new_end); + + public: + Country const* get_overlord() const; + Country const* get_subject() const; + const type_t get_subject_type() const; + }; + + struct DiplomaticHistoryManager { + private: + std::vector alliances; + std::vector subjects; + std::vector wars; + bool locked = false; + + public: + DiplomaticHistoryManager() {} + + void lock_diplomatic_history(); + bool is_locked() const; + + std::vector get_alliances(Date date) const; + std::vector get_subjects(Date date) const; + /* Returns all wars that begin before date. NOTE: Some wargoals may be added or countries may join after date, should be checked for by functions that use get_wars() */ + std::vector get_wars(Date date) const; + + bool load_diplomacy_history_file(GameManager& game_manager, ast::NodeCPtr root); + bool load_war_history_file(GameManager& game_manager, ast::NodeCPtr root); + }; +} // namespace OpenVic \ No newline at end of file -- cgit v1.2.3-56-ga3b1