aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/politics/NationalFocus.hpp
blob: 6e064f16131246853d13bb5439169883aa3eb9a3 (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
81
82
83
#pragma once

#include "openvic-simulation/economy/Good.hpp"
#include "openvic-simulation/misc/Modifier.hpp"
#include "openvic-simulation/politics/Ideology.hpp"
#include "openvic-simulation/pop/Pop.hpp"
#include "openvic-simulation/scripts/ConditionScript.hpp"
#include "openvic-simulation/types/IdentifierRegistry.hpp"
#include "openvic-simulation/utility/Getters.hpp"

namespace OpenVic {
   struct NationalFocusManager;

   struct NationalFocusGroup : HasIdentifier {
      friend struct NationalFocusManager;

   private:
      NationalFocusGroup(std::string_view new_identifier);
   };

   struct NationalFocus : HasIdentifier {
      friend struct NationalFocusManager;

   public:
      using pop_promotion_map_t = fixed_point_map_t<PopType const*>;
      using production_map_t = fixed_point_map_t<Good const*>;

   private:
      uint8_t PROPERTY(icon);
      NationalFocusGroup const& PROPERTY(group);
      ModifierValue PROPERTY(modifiers);
      pop_promotion_map_t PROPERTY(encouraged_promotion);
      production_map_t PROPERTY(encouraged_production);
      Ideology const* PROPERTY(loyalty_ideology);
      fixed_point_t PROPERTY(loyalty_value);
      ConditionScript PROPERTY(limit);

      NationalFocus(
         std::string_view new_identifier,
         uint8_t new_icon,
         NationalFocusGroup const& new_group,
         ModifierValue&& new_modifiers,
         pop_promotion_map_t&& new_encouraged_promotion,
         production_map_t&& new_encouraged_production,
         Ideology const* new_loyalty_ideology,
         fixed_point_t new_loyalty_value,
         ConditionScript&& new_limit
      );

      bool parse_scripts(GameManager const& game_manager);

   public:
      NationalFocus(NationalFocus&&) = default;
   };

   struct NationalFocusManager {
   private:
      IdentifierRegistry<NationalFocusGroup> IDENTIFIER_REGISTRY(national_focus_group);
      IdentifierRegistry<NationalFocus> IDENTIFIER_REGISTRY_CUSTOM_PLURAL(national_focus, national_foci);

   public:
      inline bool add_national_focus_group(std::string_view identifier);

      inline bool add_national_focus(
         std::string_view identifier,
         uint8_t icon,
         NationalFocusGroup const& group,
         ModifierValue&& modifiers,
         NationalFocus::pop_promotion_map_t&& encouraged_promotion,
         NationalFocus::production_map_t&& encouraged_production,
         Ideology const* loyalty_ideology,
         fixed_point_t loyalty_value,
         ConditionScript&& limit
      );

      bool load_national_foci_file(
         PopManager const& pop_manager, IdeologyManager const& ideology_manager, GoodManager const& good_manager,
         ModifierManager const& modifier_manager, ast::NodeCPtr root
      );

      bool parse_scripts(GameManager const& game_manager);
   };
} // namespace OpenVic