diff options
author | Joel Machens <ajmach6@gmail.com> | 2023-11-27 02:01:10 +0100 |
---|---|---|
committer | BrickPi <49528459+BrickPi@users.noreply.github.com> | 2023-11-28 14:53:38 +0100 |
commit | e78249bea71e2503be77f9e4cfab6ffdf164126b (patch) | |
tree | 117e2f59081629f89c6837c52bea00c34b0968b4 /src/openvic-simulation/map/State.hpp | |
parent | a54898b7770e0d66b729216173960686c67e58bb (diff) |
States First Pass
Diffstat (limited to 'src/openvic-simulation/map/State.hpp')
-rw-r--r-- | src/openvic-simulation/map/State.hpp | 51 |
1 files changed, 51 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..e9f41c4 --- /dev/null +++ b/src/openvic-simulation/map/State.hpp @@ -0,0 +1,51 @@ +#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 |