aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/tech/Technology.hpp
blob: e6ce2fa9a0e77d38a8ce35353bf362b138b4256b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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
   };
}