aboutsummaryrefslogtreecommitdiff
path: root/src/openvic/pop/Pop.hpp
blob: f5a7c4e6032b0c212f5263b02e7abc5699908e9e (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#pragma once

#include "openvic/pop/Culture.hpp"
#include "openvic/pop/Religion.hpp"

namespace OpenVic {

   struct PopManager;
   struct PopType;

   /* REQUIREMENTS:
    * POP-18, POP-19, POP-20, POP-21
    */
   struct Pop {
      friend struct PopManager;

      using pop_size_t = int64_t;

   private:
      PopType const& type;
      Culture const& culture;
      Religion const& religion;
      pop_size_t size, num_promoted, num_demoted, num_migrated;

      Pop(PopType const& new_type, Culture const& new_culture, Religion const& new_religion, pop_size_t new_size);

   public:
      Pop(Pop const&) = delete;
      Pop(Pop&&) = default;
      Pop& operator=(Pop const&) = delete;
      Pop& operator=(Pop&&) = delete;

      PopType const& get_type() const;
      Culture const& get_culture() const;
      Religion const& get_religion() const;
      pop_size_t get_size() const;
      pop_size_t get_num_promoted() const;
      pop_size_t get_num_demoted() const;
      pop_size_t get_num_migrated() const;
      pop_size_t get_pop_daily_change() const;
   };

   /* REQUIREMENTS:
    * POP-26
    */
   struct PopType : HasIdentifierAndColour {
      friend struct PopManager;

      using sprite_t = uint8_t;

   private:
      const enum class strata_t {
         POOR,
         MIDDLE,
         RICH
      } strata;
      const sprite_t sprite;
      const Pop::pop_size_t max_size, merge_max_size;
      const bool state_capital_only, demote_migrant, is_artisan, is_slave;

      // TODO - rebel composition, life/everyday/luxury needs, country and province migration targets, promote_to targets, ideologies and issues

      PopType(const std::string_view new_identifier, colour_t new_colour, strata_t new_strata, sprite_t new_sprite, Pop::pop_size_t new_max_size, Pop::pop_size_t new_merge_max_size,
         bool new_state_capital_only, bool new_demote_migrant, bool new_is_artisan, bool new_is_slave);

   public:
      PopType(PopType&&) = default;

      strata_t get_strata() const;
      sprite_t get_sprite() const;
      Pop::pop_size_t get_max_size() const;
      Pop::pop_size_t get_merge_max_size() const;
      bool get_state_capital_only() const;
      bool get_demote_migrant() const;
      bool get_is_artisan() const;
      bool get_is_slave() const;
   };

   struct Province;

   struct PopManager {
   private:
      IdentifierRegistry<PopType> pop_types;

   public:
      CultureManager culture_manager;
      ReligionManager religion_manager;

      PopManager();

      return_t add_pop_type(const std::string_view identifier, colour_t new_colour, PopType::strata_t strata, PopType::sprite_t sprite,
         Pop::pop_size_t max_size, Pop::pop_size_t merge_max_size, bool state_capital_only, bool demote_migrant,
         bool is_artisan, bool is_slave);
      void lock_pop_types();
      PopType const* get_pop_type_by_identifier(const std::string_view identifier) const;

      return_t load_pop_into_province(Province& province, ast::NodeCPtr root) const;
   };
}