diff options
author | BrickPi <49528459+BrickPi@users.noreply.github.com> | 2023-12-04 23:03:34 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2023-12-05 00:56:37 +0100 |
commit | 471d0c80ac0b62d7e5e538ccd921bf7c5c014307 (patch) | |
tree | c0411b2b6051bb274cc8d3fb39613fbd800df511 /src/openvic-simulation/map/State.hpp | |
parent | 444a27726695478e44e0166e75df1f354b6432d5 (diff) | |
parent | e78249bea71e2503be77f9e4cfab6ffdf164126b (diff) |
Merge pull request #79 from OpenVicProject/states
Diffstat (limited to 'src/openvic-simulation/map/State.hpp')
-rw-r--r-- | src/openvic-simulation/map/State.hpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/openvic-simulation/map/State.hpp b/src/openvic-simulation/map/State.hpp new file mode 100644 index 0000000..e403580 --- /dev/null +++ b/src/openvic-simulation/map/State.hpp @@ -0,0 +1,54 @@ +#pragma once + +#include "openvic-simulation/map/Province.hpp" +#include "openvic-simulation/map/Region.hpp" +#include "openvic-simulation/country/Country.hpp" + +#include <deque> + +namespace OpenVic { + struct State { + private: + Country const* PROPERTY_RW(owner); + Province const* PROPERTY_RW(capital); + Region::provinces_t PROPERTY(provinces); + Province::colony_status_t PROPERTY_RW(colony_status); + + public: + State( + Country const* owner, Province const* capital, Region::provinces_t&& provinces, + Province::colony_status_t colony_status + ); + }; + + inline bool operator==(const State& lhs, const State& rhs) { + return (lhs.get_owner() == rhs.get_owner() && lhs.get_colony_status() == rhs.get_colony_status()); + } + + struct StateSet { + using states_t = std::deque<State>; + + private: + Region const* PROPERTY(region); + states_t states; + + public: + StateSet(Region const* new_region); + + bool add_state(State&& state); + bool remove_state(State const* state); + states_t& get_states(); + }; + + /* Contains all current states.*/ + struct StateManager { + private: + std::vector<StateSet> PROPERTY(regions); + + public: + /* Creates states from current province gamestate & regions, sets province state value. + * After this function, the `regions` property is unmanaged and must be carefully updated and + * validated by functions that modify it. */ + void generate_states(Map const& map); + }; +} // namespace OpenVic |