aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/pop
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-09-10 00:04:30 +0200
committer GitHub <noreply@github.com>2024-09-10 00:04:30 +0200
commit7a9206e3869fbb659d296b854c90f5c81755a5ca (patch)
tree1e00781e634cbb7ea6f31343f6751f7755bd53ef /src/openvic-simulation/pop
parent79dbf71dd23623059ea9eabd87956f93604be1ed (diff)
parentd67cd2d08fe2859809e35b93f5a8358c48a3705e (diff)
Merge pull request #195 from OpenVicProject/ranking
Ranking System
Diffstat (limited to 'src/openvic-simulation/pop')
-rw-r--r--src/openvic-simulation/pop/Pop.cpp21
-rw-r--r--src/openvic-simulation/pop/Pop.hpp9
2 files changed, 29 insertions, 1 deletions
diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp
index 6dd0d1f..9221485 100644
--- a/src/openvic-simulation/pop/Pop.cpp
+++ b/src/openvic-simulation/pop/Pop.cpp
@@ -4,6 +4,7 @@
#include "openvic-simulation/country/CountryInstance.hpp"
#include "openvic-simulation/map/ProvinceInstance.hpp"
#include "openvic-simulation/military/UnitType.hpp"
+#include "openvic-simulation/misc/Define.hpp"
#include "openvic-simulation/politics/Ideology.hpp"
#include "openvic-simulation/politics/Issue.hpp"
#include "openvic-simulation/politics/Rebel.hpp"
@@ -40,7 +41,8 @@ Pop::Pop(PopBase const& pop_base, decltype(ideologies)::keys_t const& ideology_k
savings { 0 },
life_needs_fulfilled { 0 },
everyday_needs_fulfilled { 0 },
- luxury_needs_fulfilled { 0 } {}
+ luxury_needs_fulfilled { 0 },
+ max_supported_regiments { 0 } {}
void Pop::setup_pop_test_values(IssueManager const& issue_manager) {
/* Returns +/- range% of size. */
@@ -125,6 +127,23 @@ void Pop::set_location(ProvinceInstance const& new_location) {
}
}
+void Pop::update_gamestate(
+ DefineManager const& define_manager, CountryInstance const* owner, fixed_point_t const& pop_size_per_regiment_multiplier
+) {
+ if (type.get_can_be_recruited()) {
+ if (
+ size < define_manager.get_min_pop_size_for_regiment() || owner == nullptr ||
+ !RegimentType::allowed_cultures_check_culture_in_country(owner->get_allowed_regiment_cultures(), culture, *owner)
+ ) {
+ max_supported_regiments = 0;
+ } else {
+ max_supported_regiments = (fixed_point_t::parse(size) / (
+ fixed_point_t::parse(define_manager.get_pop_size_per_regiment()) * pop_size_per_regiment_multiplier
+ )).to_int64_t() + 1;
+ }
+ }
+}
+
Strata::Strata(std::string_view new_identifier) : HasIdentifier { new_identifier } {}
PopType::PopType(
diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp
index c74840f..e8cab42 100644
--- a/src/openvic-simulation/pop/Pop.hpp
+++ b/src/openvic-simulation/pop/Pop.hpp
@@ -26,6 +26,8 @@ namespace OpenVic {
struct IssueManager;
struct ProvinceInstance;
struct CountryParty;
+ struct DefineManager;
+ struct CountryInstance;
struct PopBase {
friend struct PopManager;
@@ -82,6 +84,8 @@ namespace OpenVic {
fixed_point_t PROPERTY(everyday_needs_fulfilled);
fixed_point_t PROPERTY(luxury_needs_fulfilled);
+ size_t PROPERTY(max_supported_regiments);
+
Pop(PopBase const& pop_base, decltype(ideologies)::keys_t const& ideology_keys);
public:
@@ -93,6 +97,11 @@ namespace OpenVic {
void setup_pop_test_values(IssueManager const& issue_manager);
void set_location(ProvinceInstance const& new_location);
+
+ void update_gamestate(
+ DefineManager const& define_manager, CountryInstance const* owner,
+ fixed_point_t const& pop_size_per_regiment_multiplier
+ );
};
struct Strata : HasIdentifier {