aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/history/ProvinceHistory.hpp
diff options
context:
space:
mode:
author BrickPi <49528459+BrickPi@users.noreply.github.com>2023-10-26 21:18:31 +0200
committer Joel Machens <ajmach6@gmail.com>2023-10-27 02:17:12 +0200
commit17697f6216159f6a89dd8d64a22de0262dcf2aef (patch)
tree18bc1663bae8f82efdbdf9c3d9bb361beb8afc17 /src/openvic-simulation/history/ProvinceHistory.hpp
parent3d52445de9bd5fb7e77883f2f880587e140fe3bc (diff)
Implement Province History Loading
Diffstat (limited to 'src/openvic-simulation/history/ProvinceHistory.hpp')
-rw-r--r--src/openvic-simulation/history/ProvinceHistory.hpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/openvic-simulation/history/ProvinceHistory.hpp b/src/openvic-simulation/history/ProvinceHistory.hpp
new file mode 100644
index 0000000..4094403
--- /dev/null
+++ b/src/openvic-simulation/history/ProvinceHistory.hpp
@@ -0,0 +1,88 @@
+#pragma once
+
+#include <map>
+#include <vector>
+
+#include "openvic-simulation/map/Province.hpp"
+#include "openvic-simulation/map/TerrainType.hpp"
+#include "openvic-simulation/country/Country.hpp"
+#include "openvic-simulation/economy/Good.hpp"
+#include "openvic-simulation/economy/Building.hpp"
+#include "openvic-simulation/history/Bookmark.hpp"
+
+namespace OpenVic {
+ struct ProvinceHistoryManager;
+
+ struct ProvinceHistory {
+ friend struct ProvinceHistoryManager;
+
+ private:
+ Country const* owner;
+ Country const* controller;
+ std::vector<Country const*> cores;
+ Good const* rgo;
+ uint8_t life_rating;
+ TerrainType const* terrain_type;
+ std::map<Building const*, uint8_t> buildings;
+ std::map<Ideology const*, uint8_t> party_loyalties;
+
+ ProvinceHistory(
+ Country const* new_owner,
+ Country const* new_controller,
+ std::vector<Country const*>&& new_cores,
+ Good const* new_rgo,
+ uint8_t new_life_rating,
+ TerrainType const* new_terrain_type,
+ std::map<Building const*, uint8_t>&& new_buildings,
+ std::map<Ideology const*, uint8_t>&& new_party_loyalties
+ );
+
+ public:
+ Country const* get_owner() const;
+ Country const* get_controller() const;
+ const std::vector<Country const*>& get_cores() const;
+ bool is_core_of(Country const* country) const;
+ Good const* get_rgo() const;
+ uint8_t get_life_rating() const;
+ TerrainType const* get_terrain_type() const;
+ const std::map<Building const*, uint8_t>& get_buildings() const;
+ const std::map<Ideology const*, uint8_t>& get_party_loyalties() const;
+ };
+
+ struct ProvinceHistoryManager {
+ private:
+ std::map<Province const*, std::map<Date, ProvinceHistory>> province_histories;
+ bool locked = false;
+
+ inline bool _load_province_history_entry(GameManager& game_manager, std::string_view province, Date const& date, ast::NodeCPtr root);
+
+ public:
+ ProvinceHistoryManager() {}
+
+ bool add_province_history_entry(
+ Province const* province,
+ Date date,
+ Country const* owner,
+ Country const* controller,
+ std::vector<Country const*>&& cores,
+ Good const* rgo,
+ uint8_t life_rating,
+ TerrainType const* terrain_type,
+ std::map<Building const*, uint8_t>&& buildings,
+ std::map<Ideology const*, uint8_t>&& party_loyalties,
+ bool updated_cores,
+ bool updated_buildings,
+ bool updated_loyalties
+ );
+
+ void lock_province_histories();
+ bool is_locked() const;
+
+ /* Returns history of province at date, if date doesn't have an entry returns closest entry before date. Return can be nullptr if an error occurs. */
+ ProvinceHistory const* get_province_history(Province const* province, Date entry) const;
+ /* Returns history of province at bookmark date. Return can be nullptr if an error occurs. */
+ inline ProvinceHistory const* get_province_history(Province const* province, Bookmark const* bookmark) const;
+
+ bool load_province_history_file(GameManager& game_manager, std::string_view name, ast::NodeCPtr root);
+ };
+} // namespace OpenVic