aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/military
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/military')
-rw-r--r--src/openvic-simulation/military/Deployment.hpp2
-rw-r--r--src/openvic-simulation/military/MilitaryManager.hpp14
-rw-r--r--src/openvic-simulation/military/Unit.cpp51
-rw-r--r--src/openvic-simulation/military/Unit.hpp16
-rw-r--r--src/openvic-simulation/military/Wargoal.hpp36
5 files changed, 82 insertions, 37 deletions
diff --git a/src/openvic-simulation/military/Deployment.hpp b/src/openvic-simulation/military/Deployment.hpp
index ead324e..597f727 100644
--- a/src/openvic-simulation/military/Deployment.hpp
+++ b/src/openvic-simulation/military/Deployment.hpp
@@ -99,7 +99,7 @@ namespace OpenVic {
bool add_deployment(
std::string_view path, std::vector<Army>&& armies, std::vector<Navy>&& navies, std::vector<Leader>&& leaders
);
- IDENTIFIER_REGISTRY_ACCESSORS(deployment)
+ IDENTIFIER_REGISTRY_ACCESSORS(deployment)
bool load_oob_file(
GameManager const& game_manager, Dataloader const& dataloader, std::string_view history_path,
diff --git a/src/openvic-simulation/military/MilitaryManager.hpp b/src/openvic-simulation/military/MilitaryManager.hpp
index ba13b70..aeb5a7b 100644
--- a/src/openvic-simulation/military/MilitaryManager.hpp
+++ b/src/openvic-simulation/military/MilitaryManager.hpp
@@ -8,15 +8,9 @@
namespace OpenVic {
struct MilitaryManager {
private:
- UnitManager unit_manager;
- LeaderTraitManager leader_trait_manager;
- DeploymentManager deployment_manager;
- WargoalTypeManager wargoal_manager;
-
- public:
- REF_GETTERS(unit_manager)
- REF_GETTERS(leader_trait_manager)
- REF_GETTERS(deployment_manager)
- REF_GETTERS(wargoal_manager)
+ UnitManager PROPERTY_REF(unit_manager);
+ LeaderTraitManager PROPERTY_REF(leader_trait_manager);
+ DeploymentManager PROPERTY_REF(deployment_manager);
+ WargoalTypeManager PROPERTY_REF(wargoal_manager);
};
}
diff --git a/src/openvic-simulation/military/Unit.cpp b/src/openvic-simulation/military/Unit.cpp
index fce4082..7995aeb 100644
--- a/src/openvic-simulation/military/Unit.cpp
+++ b/src/openvic-simulation/military/Unit.cpp
@@ -185,7 +185,56 @@ bool UnitManager::load_unit_file(GoodManager const& good_manager, ast::NodeCPtr
return ret;
}
- default: Logger::error("Unknown unit type for ", key, ": ", static_cast<int>(type)); return false;
+ default: Logger::error("Unknown unit type for ", key, ": ", static_cast<int>(type)); return false;
}
})(root);
}
+
+#define STAT_MODIFIER(name, positive_good, format) \
+ ret &= modifier_manager.add_modifier_effect(base_name + name, positive_good, ModifierEffect::format_t::format)
+
+bool UnitManager::generate_modifiers(ModifierManager& modifier_manager) {
+ std::function<bool(std::string_view, Unit::type_t)> generate_stat_modifiers = [this, &modifier_manager](std::string_view identifier, Unit::type_t type) -> bool {
+ modifier_manager.register_complex_modifier(identifier);
+ std::string base_name = std::string(identifier) + "_";
+ bool ret = true;
+
+ STAT_MODIFIER("default_organisation", true, RAW_DECIMAL);
+ STAT_MODIFIER("maximum_speed", true, RAW_DECIMAL);
+ STAT_MODIFIER("build_time", false, INT);
+ STAT_MODIFIER("supply_consumption", false, PROPORTION_DECIMAL);
+
+ switch (type) {
+ case Unit::type_t::LAND: {
+ STAT_MODIFIER("reconnaissance", true, RAW_DECIMAL);
+ STAT_MODIFIER("attack", true, RAW_DECIMAL);
+ STAT_MODIFIER("defence", true, RAW_DECIMAL);
+ STAT_MODIFIER("discipline", true, PROPORTION_DECIMAL);
+ STAT_MODIFIER("support", true, PROPORTION_DECIMAL);
+ STAT_MODIFIER("maneuver", true, INT);
+ STAT_MODIFIER("siege", true, RAW_DECIMAL);
+ break;
+ }
+ case Unit::type_t::NAVAL: {
+ STAT_MODIFIER("colonial_points", true, INT);
+ STAT_MODIFIER("supply_consumption_score", false, INT);
+ STAT_MODIFIER("hull", true, RAW_DECIMAL);
+ STAT_MODIFIER("gun_power", true, RAW_DECIMAL);
+ STAT_MODIFIER("fire_range", true, RAW_DECIMAL);
+ STAT_MODIFIER("evasion", true, PROPORTION_DECIMAL);
+ STAT_MODIFIER("torpedo_attack", true, RAW_DECIMAL);
+ break;
+ }
+ }
+
+ return ret;
+ };
+
+ bool ret = true;
+ ret &= generate_stat_modifiers("army_base", Unit::type_t::LAND);
+ ret &= generate_stat_modifiers("navy_base", Unit::type_t::NAVAL);
+ for (Unit const& unit : this->get_units())
+ ret &= generate_stat_modifiers(unit.get_identifier(), unit.get_type());
+
+ return ret;
+} \ No newline at end of file
diff --git a/src/openvic-simulation/military/Unit.hpp b/src/openvic-simulation/military/Unit.hpp
index 632067e..17228ce 100644
--- a/src/openvic-simulation/military/Unit.hpp
+++ b/src/openvic-simulation/military/Unit.hpp
@@ -3,6 +3,7 @@
#include <cstdint>
#include <string_view>
+#include "openvic-simulation/misc/Modifier.hpp"
#include "openvic-simulation/dataloader/NodeTools.hpp"
#include "openvic-simulation/economy/Good.hpp"
#include "openvic-simulation/types/Date.hpp"
@@ -35,9 +36,9 @@ namespace OpenVic {
const type_t PROPERTY(type);
const icon_t PROPERTY(icon);
const std::string PROPERTY(sprite);
- const bool PROPERTY_CUSTOM_NAME(active, is_active);
+ const bool PROPERTY_CUSTOM_PREFIX(active, is);
const std::string PROPERTY(unit_type);
- const bool PROPERTY_CUSTOM_NAME(floating_flag, has_floating_flag);
+ const bool PROPERTY_CUSTOM_PREFIX(floating_flag, has);
const uint32_t PROPERTY(priority);
const fixed_point_t PROPERTY(max_strength);
@@ -64,7 +65,7 @@ namespace OpenVic {
friend struct UnitManager;
private:
- const bool PROPERTY_CUSTOM_NAME(primary_culture, is_primary_culture);
+ const bool PROPERTY_CUSTOM_PREFIX(primary_culture, is);
const std::string PROPERTY(sprite_override);
const std::string PROPERTY(sprite_mount);
const std::string PROPERTY(sprite_mount_attach_node);
@@ -87,11 +88,11 @@ namespace OpenVic {
private:
const icon_t PROPERTY(naval_icon);
- const bool PROPERTY_CUSTOM_NAME(sail, can_sail);
- const bool PROPERTY_CUSTOM_NAME(transport, is_transport);
- const bool PROPERTY_CUSTOM_NAME(capital, is_capital);
+ const bool PROPERTY_CUSTOM_PREFIX(sail, can);
+ const bool PROPERTY_CUSTOM_PREFIX(transport, is);
+ const bool PROPERTY_CUSTOM_PREFIX(capital, is);
const fixed_point_t PROPERTY(colonial_points);
- const bool PROPERTY_CUSTOM_NAME(build_overseas, can_build_overseas);
+ const bool PROPERTY_CUSTOM_PREFIX(build_overseas, can);
const uint32_t PROPERTY(min_port_level);
const int32_t PROPERTY(limit_per_port);
const fixed_point_t PROPERTY(supply_consumption_score);
@@ -124,5 +125,6 @@ namespace OpenVic {
static NodeTools::callback_t<std::string_view> expect_type_str(NodeTools::Callback<Unit::type_t> auto callback);
bool load_unit_file(GoodManager const& good_manager, ast::NodeCPtr root);
+ bool generate_modifiers(ModifierManager& modifier_manager);
};
}
diff --git a/src/openvic-simulation/military/Wargoal.hpp b/src/openvic-simulation/military/Wargoal.hpp
index ef8170f..f696511 100644
--- a/src/openvic-simulation/military/Wargoal.hpp
+++ b/src/openvic-simulation/military/Wargoal.hpp
@@ -9,24 +9,24 @@ namespace OpenVic {
struct WargoalTypeManager;
enum class peace_options_t : uint32_t {
- PO_ANNEX = 0b100000000000000000,
- PO_DEMAND_STATE = 0b010000000000000000,
- PO_COLONY = 0b001000000000000000,
- PO_ADD_TO_SPHERE = 0b000100000000000000,
- PO_DISARMAMENT = 0b000010000000000000,
- PO_REMOVE_FORTS = 0b000001000000000000,
- PO_REMOVE_NAVAL_BASES = 0b000000100000000000,
- PO_REPARATIONS = 0b000000010000000000,
- PO_REPAY_DEBT = 0b000000001000000000,
- PO_REMOVE_PRESTIGE = 0b000000000100000000,
- PO_MAKE_PUPPET = 0b000000000010000000,
- PO_RELEASE_PUPPET = 0b000000000001000000,
- PO_STATUS_QUO = 0b000000000000100000,
- PO_INSTALL_COMMUNISM = 0b000000000000010000,
- PO_REMOVE_COMMUNISM = 0b000000000000001000,
- PO_REMOVE_CORES = 0b000000000000000100, // only usable with ANNEX, DEMAND_STATE, or TRANSFER_PROVINCES
- PO_TRANSFER_PROVINCES = 0b000000000000000010,
- PO_CLEAR_UNION_SPHERE = 0b000000000000000001
+ PO_ANNEX = 0b100000000000000000,
+ PO_DEMAND_STATE = 0b010000000000000000,
+ PO_COLONY = 0b001000000000000000,
+ PO_ADD_TO_SPHERE = 0b000100000000000000,
+ PO_DISARMAMENT = 0b000010000000000000,
+ PO_REMOVE_FORTS = 0b000001000000000000,
+ PO_REMOVE_NAVAL_BASES = 0b000000100000000000,
+ PO_REPARATIONS = 0b000000010000000000,
+ PO_REPAY_DEBT = 0b000000001000000000,
+ PO_REMOVE_PRESTIGE = 0b000000000100000000,
+ PO_MAKE_PUPPET = 0b000000000010000000,
+ PO_RELEASE_PUPPET = 0b000000000001000000,
+ PO_STATUS_QUO = 0b000000000000100000,
+ PO_INSTALL_COMMUNISM = 0b000000000000010000,
+ PO_REMOVE_COMMUNISM = 0b000000000000001000,
+ PO_REMOVE_CORES = 0b000000000000000100, // only usable with ANNEX, DEMAND_STATE, or TRANSFER_PROVINCES
+ PO_TRANSFER_PROVINCES = 0b000000000000000010,
+ PO_CLEAR_UNION_SPHERE = 0b000000000000000001
};
template<> struct enable_bitfield<peace_options_t> : std::true_type{};