aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation')
-rw-r--r--src/openvic-simulation/Modifier.cpp41
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp9
-rw-r--r--src/openvic-simulation/politics/NationalValue.cpp38
-rw-r--r--src/openvic-simulation/politics/NationalValue.hpp35
-rw-r--r--src/openvic-simulation/politics/PoliticsManager.hpp4
5 files changed, 107 insertions, 20 deletions
diff --git a/src/openvic-simulation/Modifier.cpp b/src/openvic-simulation/Modifier.cpp
index 97ddd8f..8910715 100644
--- a/src/openvic-simulation/Modifier.cpp
+++ b/src/openvic-simulation/Modifier.cpp
@@ -123,31 +123,34 @@ bool ModifierManager::setup_modifier_effects() {
using enum ModifierEffect::format_t;
- /* LEADER TRAIT MODIFIERS */
+ /* Generic Modifier Effects */
+ ret &= add_modifier_effect("assimilation_rate", true);
ret &= add_modifier_effect("attack", true, INT);
+ ret &= add_modifier_effect("attrition", false, RAW_DECIMAL);
+ ret &= add_modifier_effect("badboy", false, RAW_DECIMAL);
+ ret &= add_modifier_effect("combat_width", false);
ret &= add_modifier_effect("defence", true, INT);
- ret &= add_modifier_effect("reliability", true, RAW_DECIMAL);
- ret &= add_modifier_effect("morale", true);
- ret &= add_modifier_effect("organisation", true);
- ret &= add_modifier_effect("speed", true);
- ret &= add_modifier_effect("reconnaissance", true);
ret &= add_modifier_effect("experience", true);
- ret &= add_modifier_effect("attrition", false, RAW_DECIMAL);
- /* MISCELLANEOUS MODIFIERS */
- ret &= add_modifier_effect("movement_cost", false);
- ret &= add_modifier_effect("farm_rgo_size", true);
ret &= add_modifier_effect("farm_rgo_eff", true);
- ret &= add_modifier_effect("mine_rgo_size", true);
- ret &= add_modifier_effect("mine_rgo_eff", true);
- ret &= add_modifier_effect("supply_limit", true, RAW_DECIMAL);
- ret &= add_modifier_effect("combat_width", false);
- ret &= add_modifier_effect("local_ship_build", false);
- ret &= add_modifier_effect("research_points_modifier", true);
- ret &= add_modifier_effect("local_rgo_output", true);
+ ret &= add_modifier_effect("farm_rgo_size", true);
ret &= add_modifier_effect("immigrant_push", false);
- ret &= add_modifier_effect("population_growth", true);
+ ret &= add_modifier_effect("local_rgo_output", true);
ret &= add_modifier_effect("local_RGO_throughput", true);
- ret &= add_modifier_effect("assimilation_rate", true);
+ ret &= add_modifier_effect("local_ship_build", false);
+ ret &= add_modifier_effect("mine_rgo_eff", true);
+ ret &= add_modifier_effect("mine_rgo_size", true);
+ ret &= add_modifier_effect("mobilisation_size", true);
+ ret &= add_modifier_effect("mobilisation_economy_impact", false);
+ ret &= add_modifier_effect("mobilisation_impact", false);
+ ret &= add_modifier_effect("morale", true);
+ ret &= add_modifier_effect("movement_cost", false);
+ ret &= add_modifier_effect("organisation", true);
+ ret &= add_modifier_effect("population_growth", true);
+ ret &= add_modifier_effect("reconnaissance", true);
+ ret &= add_modifier_effect("reliability", true, RAW_DECIMAL);
+ ret &= add_modifier_effect("research_points_modifier", true);
+ ret &= add_modifier_effect("speed", true);
+ ret &= add_modifier_effect("supply_limit", true, RAW_DECIMAL);
/* These should be added automatically for each Building loaded (or at least
* non-factories), however currently we need modifier effects locked before we
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index 9a34713..475cdd1 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -621,6 +621,7 @@ bool Dataloader::load_defines(GameManager& game_manager) const {
static const fs::path graphical_culture_type_file = "common/graphicalculturetype.txt";
static const fs::path ideology_file = "common/ideologies.txt";
static const fs::path issues_file = "common/issues.txt";
+ static const fs::path national_values_file = "common/nationalvalues.txt";
static const fs::path production_types_file = "common/production_types.txt";
static const fs::path religion_file = "common/religion.txt";
static const fs::path leader_traits_file = "common/traits.txt";
@@ -679,6 +680,11 @@ bool Dataloader::load_defines(GameManager& game_manager) const {
Logger::error("Failed to load issues!");
ret = false;
}
+ if (!game_manager.get_politics_manager().get_national_value_manager().load_national_values_file(
+ game_manager.get_modifier_manager(), parse_defines(lookup_file(national_values_file)).get_file_node())) {
+ Logger::error("Failed to load national values!");
+ ret = false;
+ }
if (!_load_countries(game_manager, countries_file, parse_defines(lookup_file(countries_file)).get_file_node())) {
Logger::error("Failed to load countries!");
ret = false;
@@ -699,7 +705,8 @@ bool Dataloader::load_defines(GameManager& game_manager) const {
Logger::error("Failed to load map!");
ret = false;
}
- if (!game_manager.get_military_manager().get_leader_trait_manager().load_leader_traits_file(game_manager.get_modifier_manager(), parse_defines(lookup_file(leader_traits_file)).get_file_node())) {
+ if (!game_manager.get_military_manager().get_leader_trait_manager().load_leader_traits_file(
+ game_manager.get_modifier_manager(), parse_defines(lookup_file(leader_traits_file)).get_file_node())) {
Logger::error("Failed to load leader traits!");
ret = false;
}
diff --git a/src/openvic-simulation/politics/NationalValue.cpp b/src/openvic-simulation/politics/NationalValue.cpp
new file mode 100644
index 0000000..f1d8a3b
--- /dev/null
+++ b/src/openvic-simulation/politics/NationalValue.cpp
@@ -0,0 +1,38 @@
+#include "NationalValue.hpp"
+
+using namespace OpenVic;
+using namespace OpenVic::NodeTools;
+
+NationalValue::NationalValue(std::string_view new_identifier, ModifierValue&& new_modifiers)
+ : HasIdentifier { new_identifier }, modifiers { std::move(new_modifiers) } {}
+
+ModifierValue const& NationalValue::get_modifiers() const {
+ return modifiers;
+}
+
+NationalValueManager::NationalValueManager() : national_values { "national values" } {}
+
+bool NationalValueManager::add_national_value(std::string_view identifier, ModifierValue&& modifiers) {
+ if (identifier.empty()) {
+ Logger::error("Invalid national value identifier - empty!");
+ return false;
+ }
+
+ return national_values.add_item({ identifier, std::move(modifiers) });
+}
+
+bool NationalValueManager::load_national_values_file(ModifierManager const& modifier_manager, ast::NodeCPtr root) {
+ bool ret = expect_dictionary(
+ [this, &modifier_manager](std::string_view national_value_identifier, ast::NodeCPtr value) -> bool {
+ ModifierValue modifiers;
+
+ bool ret = modifier_manager.expect_modifier_value(move_variable_callback(modifiers))(value);
+
+ ret &= add_national_value(national_value_identifier, std::move(modifiers));
+ return ret;
+ }
+ )(root);
+ lock_national_values();
+
+ return ret;
+}
diff --git a/src/openvic-simulation/politics/NationalValue.hpp b/src/openvic-simulation/politics/NationalValue.hpp
new file mode 100644
index 0000000..09ef85e
--- /dev/null
+++ b/src/openvic-simulation/politics/NationalValue.hpp
@@ -0,0 +1,35 @@
+#pragma once
+
+#include "openvic-simulation/Modifier.hpp"
+#include "openvic-simulation/types/IdentifierRegistry.hpp"
+
+namespace OpenVic {
+ struct NationalValueManager;
+
+ struct NationalValue : HasIdentifier {
+ friend struct NationalValueManager;
+
+ private:
+ const ModifierValue modifiers;
+
+ NationalValue(std::string_view new_identifier, ModifierValue&& new_modifiers);
+
+ public:
+ NationalValue(NationalValue&&) = default;
+
+ ModifierValue const& get_modifiers() const;
+ };
+
+ struct NationalValueManager {
+ private:
+ IdentifierRegistry<NationalValue> national_values;
+
+ public:
+ NationalValueManager();
+
+ bool add_national_value(std::string_view identifier, ModifierValue&& modifiers);
+ IDENTIFIER_REGISTRY_ACCESSORS(national_value)
+
+ bool load_national_values_file(ModifierManager const& modifier_manager, ast::NodeCPtr root);
+ };
+} // namespace OpenVic
diff --git a/src/openvic-simulation/politics/PoliticsManager.hpp b/src/openvic-simulation/politics/PoliticsManager.hpp
index 9072d72..1423cf7 100644
--- a/src/openvic-simulation/politics/PoliticsManager.hpp
+++ b/src/openvic-simulation/politics/PoliticsManager.hpp
@@ -3,6 +3,7 @@
#include "openvic-simulation/politics/Government.hpp"
#include "openvic-simulation/politics/Ideology.hpp"
#include "openvic-simulation/politics/Issue.hpp"
+#include "openvic-simulation/politics/NationalValue.hpp"
namespace OpenVic {
struct PoliticsManager {
@@ -10,10 +11,13 @@ namespace OpenVic {
GovernmentTypeManager government_type_manager;
IdeologyManager ideology_manager;
IssueManager issue_manager;
+ NationalValueManager national_value_manager;
+
public:
REF_GETTERS(government_type_manager)
REF_GETTERS(ideology_manager)
REF_GETTERS(issue_manager)
+ REF_GETTERS(national_value_manager)
inline bool load_government_types_file(ast::NodeCPtr root) {
return government_type_manager.load_government_types_file(ideology_manager, root);