aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/military/Unit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/military/Unit.cpp')
-rw-r--r--src/openvic-simulation/military/Unit.cpp51
1 files changed, 50 insertions, 1 deletions
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