aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/tech/Technology.hpp
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-10-03 15:51:45 +0200
committer zaaarf <zaaarf@proton.me>2023-10-22 00:03:36 +0200
commit51583b66feb1d13b285bb2e9c05364659c854130 (patch)
tree150dc88dd897a1072902dd00f58f122382ec8e9f /src/openvic-simulation/tech/Technology.hpp
parent0de3d5849cfb9faad0e3c8ce10a8152a916bba21 (diff)
feat: implemented basic technology and school loading (modifier processing is still missing)
Diffstat (limited to 'src/openvic-simulation/tech/Technology.hpp')
-rw-r--r--src/openvic-simulation/tech/Technology.hpp80
1 files changed, 80 insertions, 0 deletions
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<TechnologyFolder> technology_folders;
+ IdentifierRegistry<TechnologyArea> technology_areas;
+ IdentifierRegistry<Technology> technologies;
+ IdentifierRegistry<TechnologySchool> 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