From 51583b66feb1d13b285bb2e9c05364659c854130 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Tue, 3 Oct 2023 15:51:45 +0200 Subject: feat: implemented basic technology and school loading (modifier processing is still missing) --- src/openvic-simulation/tech/Technology.hpp | 80 ++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/openvic-simulation/tech/Technology.hpp (limited to 'src/openvic-simulation/tech/Technology.hpp') diff --git a/src/openvic-simulation/tech/Technology.hpp b/src/openvic-simulation/tech/Technology.hpp new file mode 100644 index 0000000..e6ce2fa --- /dev/null +++ b/src/openvic-simulation/tech/Technology.hpp @@ -0,0 +1,80 @@ +#pragma once + +#include "misc/Modifier.hpp" +#include "types/Date.hpp" +#include "types/IdentifierRegistry.hpp" +#include "types/fixed_point/FixedPoint.hpp" + +namespace OpenVic { + struct TechnologyFolder : HasIdentifier { + friend struct TechnologyManager; + + private: + TechnologyFolder(std::string_view identifier); + + public: + TechnologyFolder(TechnologyFolder&&) = default; + }; + + struct TechnologyArea : HasIdentifier { + friend struct TechnologyManager; + + private: + TechnologyFolder const& PROPERTY(folder); + + TechnologyArea(std::string_view identifier, TechnologyFolder const& folder); + + public: + TechnologyArea(TechnologyArea&&) = default; + }; + + struct Technology : Modifier { + friend struct TechnologyManager; + using year_t = Date::year_t; + + private: + TechnologyArea const& PROPERTY(area); + const year_t PROPERTY(year); + const fixed_point_t PROPERTY(cost); + const bool PROPERTY(unciv_military); + + //TODO: implement rules/modifiers and ai_chance + + Technology(std::string_view identifier, TechnologyArea const& area, year_t year, fixed_point_t cost, bool unciv_military, ModifierValue&& values); + + public: + Technology(Technology&&) = default; + }; + + struct TechnologySchool : Modifier { + friend struct TechnologyManager; + + private: + TechnologySchool(std::string_view new_identifier, ModifierValue&& new_values); + }; + + struct TechnologyManager { + IdentifierRegistry technology_folders; + IdentifierRegistry technology_areas; + IdentifierRegistry technologies; + IdentifierRegistry technology_schools; + + public: + TechnologyManager(); + + bool add_technology_folder(std::string_view identifier); + IDENTIFIER_REGISTRY_ACCESSORS(technology_folder) + + bool add_technology_area(std::string_view identifier, TechnologyFolder const* folder); + IDENTIFIER_REGISTRY_ACCESSORS(technology_area) + + bool add_technology(std::string_view identifier, TechnologyArea const* area, Technology::year_t year, fixed_point_t cost, bool unciv_military, ModifierValue&& values); + IDENTIFIER_REGISTRY_ACCESSORS_CUSTOM_PLURAL(technology, technologies) + + bool add_technology_school(std::string_view identifier, ModifierValue&& values); //, Modifier::icon_t icon); + IDENTIFIER_REGISTRY_ACCESSORS(technology_school); + + bool load_technology_file(ModifierManager const& modifier_manager, ast::NodeCPtr root); // common/technology.txt + bool load_technologies_file(ModifierManager const& modifier_manager, ast::NodeCPtr root); // technologies/*.txt + }; +} \ No newline at end of file -- cgit v1.2.3-56-ga3b1