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/LeaderTrait.cpp14
-rw-r--r--src/openvic-simulation/military/LeaderTrait.hpp6
-rw-r--r--src/openvic-simulation/military/Unit.cpp164
-rw-r--r--src/openvic-simulation/military/Unit.hpp140
4 files changed, 51 insertions, 273 deletions
diff --git a/src/openvic-simulation/military/LeaderTrait.cpp b/src/openvic-simulation/military/LeaderTrait.cpp
index df87e4e..46cd94a 100644
--- a/src/openvic-simulation/military/LeaderTrait.cpp
+++ b/src/openvic-simulation/military/LeaderTrait.cpp
@@ -4,22 +4,14 @@ using namespace OpenVic;
using namespace OpenVic::NodeTools;
LeaderTrait::LeaderTrait(std::string_view new_identifier, trait_type_t new_type, ModifierValue&& new_modifiers)
- : HasIdentifier { new_identifier }, type { new_type }, modifiers { std::move(new_modifiers) } {}
-
-LeaderTrait::trait_type_t LeaderTrait::get_trait_type() const {
- return type;
-}
+ : HasIdentifier { new_identifier }, trait_type { new_type }, modifiers { std::move(new_modifiers) } {}
bool LeaderTrait::is_personality_trait() const {
- return type == trait_type_t::PERSONALITY;
+ return trait_type == trait_type_t::PERSONALITY;
}
bool LeaderTrait::is_background_trait() const {
- return type == trait_type_t::BACKGROUND;
-}
-
-ModifierValue const& LeaderTrait::get_modifiers() const {
- return modifiers;
+ return trait_type == trait_type_t::BACKGROUND;
}
LeaderTraitManager::LeaderTraitManager() : leader_traits { "leader trait" } {}
diff --git a/src/openvic-simulation/military/LeaderTrait.hpp b/src/openvic-simulation/military/LeaderTrait.hpp
index 34de44d..4ec3b63 100644
--- a/src/openvic-simulation/military/LeaderTrait.hpp
+++ b/src/openvic-simulation/military/LeaderTrait.hpp
@@ -17,7 +17,7 @@ namespace OpenVic {
enum class trait_type_t { PERSONALITY, BACKGROUND };
private:
- const trait_type_t type;
+ const trait_type_t PROPERTY(trait_type);
/*
* Allowed modifiers for leaders:
* attack - integer
@@ -30,17 +30,15 @@ namespace OpenVic {
* experience - %
* reliability - decimal, mil gain or loss for associated POPs
*/
- const ModifierValue modifiers;
+ const ModifierValue PROPERTY(modifiers);
LeaderTrait(std::string_view new_identifier, trait_type_t new_type, ModifierValue&& new_modifiers);
public:
LeaderTrait(LeaderTrait&&) = default;
- trait_type_t get_trait_type() const;
bool is_personality_trait() const;
bool is_background_trait() const;
- ModifierValue const& get_modifiers() const;
};
struct LeaderTraitManager {
diff --git a/src/openvic-simulation/military/Unit.cpp b/src/openvic-simulation/military/Unit.cpp
index 5322a88..fce4082 100644
--- a/src/openvic-simulation/military/Unit.cpp
+++ b/src/openvic-simulation/military/Unit.cpp
@@ -24,74 +24,6 @@ Unit::Unit(
move_sound { move_sound }, select_sound { select_sound }, build_time { build_time }, build_cost { std::move(build_cost) },
supply_consumption { supply_consumption }, supply_cost { std::move(supply_cost) } {}
-Unit::icon_t Unit::get_icon() const {
- return icon;
-}
-
-Unit::type_t Unit::get_type() const {
- return type;
-}
-
-std::string_view Unit::get_sprite() const {
- return sprite;
-}
-
-bool Unit::is_active() const {
- return active;
-}
-
-std::string_view Unit::get_unit_type() const {
- return unit_type;
-}
-
-bool Unit::has_floating_flag() const {
- return floating_flag;
-}
-
-uint32_t Unit::get_priority() const {
- return priority;
-}
-
-fixed_point_t Unit::get_max_strength() const {
- return max_strength;
-}
-
-fixed_point_t Unit::get_default_organisation() const {
- return default_organisation;
-}
-
-fixed_point_t Unit::get_maximum_speed() const {
- return maximum_speed;
-}
-
-Timespan Unit::get_build_time() const {
- return build_time;
-}
-
-fixed_point_t Unit::get_weighted_value() const {
- return weighted_value;
-}
-
-std::string_view Unit::get_move_sound() const {
- return move_sound;
-}
-
-std::string_view Unit::get_select_sound() const {
- return select_sound;
-}
-
-Good::good_map_t const& Unit::get_build_cost() const {
- return build_cost;
-}
-
-fixed_point_t Unit::get_supply_consumption() const {
- return supply_consumption;
-}
-
-Good::good_map_t const& Unit::get_supply_cost() const {
- return supply_cost;
-}
-
LandUnit::LandUnit(
std::string_view identifier, UNIT_PARAMS, LAND_PARAMS
) : Unit { identifier, type_t::LAND, UNIT_ARGS }, primary_culture { primary_culture }, sprite_override { sprite_override },
@@ -99,50 +31,6 @@ LandUnit::LandUnit(
attack { attack }, defence { defence }, discipline { discipline }, support { support }, maneuver { maneuver },
siege { siege } {}
-bool LandUnit::get_primary_culture() const {
- return primary_culture;
-}
-
-std::string_view LandUnit::get_sprite_override() const {
- return sprite_override;
-}
-
-std::string_view LandUnit::get_sprite_mount() const {
- return sprite_mount;
-}
-
-std::string_view LandUnit::get_sprite_mount_attach_node() const {
- return sprite_mount_attach_node;
-}
-
-fixed_point_t LandUnit::get_reconnaissance() const {
- return reconnaissance;
-}
-
-fixed_point_t LandUnit::get_attack() const {
- return attack;
-}
-
-fixed_point_t LandUnit::get_defence() const {
- return defence;
-}
-
-fixed_point_t LandUnit::get_discipline() const {
- return discipline;
-}
-
-fixed_point_t LandUnit::get_support() const {
- return support;
-}
-
-fixed_point_t LandUnit::get_maneuver() const {
- return maneuver;
-}
-
-fixed_point_t LandUnit::get_siege() const {
- return siege;
-}
-
NavalUnit::NavalUnit(
std::string_view identifier, UNIT_PARAMS, NAVY_PARAMS
) : Unit { identifier, type_t::NAVAL, UNIT_ARGS }, naval_icon { naval_icon }, sail { sail }, transport { transport },
@@ -151,58 +39,6 @@ NavalUnit::NavalUnit(
supply_consumption_score { supply_consumption_score }, hull { hull }, gun_power { gun_power }, fire_range { fire_range },
evasion { evasion }, torpedo_attack { torpedo_attack } {};
-NavalUnit::icon_t NavalUnit::get_naval_icon() const {
- return naval_icon;
-}
-
-bool NavalUnit::can_sail() const {
- return sail;
-}
-
-bool NavalUnit::is_transport() const {
- return transport;
-}
-
-fixed_point_t NavalUnit::get_colonial_points() const {
- return colonial_points;
-}
-
-bool NavalUnit::can_build_overseas() const {
- return build_overseas;
-}
-
-uint32_t NavalUnit::get_min_port_level() const {
- return min_port_level;
-}
-
-int32_t NavalUnit::get_limit_per_port() const {
- return limit_per_port;
-}
-
-fixed_point_t NavalUnit::get_supply_consumption_score() const {
- return supply_consumption_score;
-}
-
-fixed_point_t NavalUnit::get_hull() const {
- return hull;
-}
-
-fixed_point_t NavalUnit::get_gun_power() const {
- return gun_power;
-}
-
-fixed_point_t NavalUnit::get_fire_range() const {
- return fire_range;
-}
-
-fixed_point_t NavalUnit::get_evasion() const {
- return evasion;
-}
-
-fixed_point_t NavalUnit::get_torpedo_attack() const {
- return torpedo_attack;
-}
-
UnitManager::UnitManager() : units { "units" } {}
bool UnitManager::_check_shared_parameters(std::string_view identifier, UNIT_PARAMS) {
diff --git a/src/openvic-simulation/military/Unit.hpp b/src/openvic-simulation/military/Unit.hpp
index ab371e8..632067e 100644
--- a/src/openvic-simulation/military/Unit.hpp
+++ b/src/openvic-simulation/military/Unit.hpp
@@ -32,128 +32,80 @@ namespace OpenVic {
enum struct type_t { LAND, NAVAL };
private:
- const type_t type;
- const icon_t icon;
- const std::string sprite;
- const bool active;
- const std::string unit_type;
- const bool floating_flag;
-
- const uint32_t priority;
- const fixed_point_t max_strength;
- const fixed_point_t default_organisation;
- const fixed_point_t maximum_speed;
- const fixed_point_t weighted_value;
-
- const std::string move_sound;
- const std::string select_sound;
-
- const Timespan build_time;
- const Good::good_map_t build_cost;
- const fixed_point_t supply_consumption;
- const Good::good_map_t supply_cost;
+ const type_t PROPERTY(type);
+ const icon_t PROPERTY(icon);
+ const std::string PROPERTY(sprite);
+ const bool PROPERTY_CUSTOM_NAME(active, is_active);
+ const std::string PROPERTY(unit_type);
+ const bool PROPERTY_CUSTOM_NAME(floating_flag, has_floating_flag);
+
+ const uint32_t PROPERTY(priority);
+ const fixed_point_t PROPERTY(max_strength);
+ const fixed_point_t PROPERTY(default_organisation);
+ const fixed_point_t PROPERTY(maximum_speed);
+ const fixed_point_t PROPERTY(weighted_value);
+
+ const std::string PROPERTY(move_sound);
+ const std::string PROPERTY(select_sound);
+
+ const Timespan PROPERTY(build_time);
+ const Good::good_map_t PROPERTY(build_cost);
+ const fixed_point_t PROPERTY(supply_consumption);
+ const Good::good_map_t PROPERTY(supply_cost);
protected:
Unit(std::string_view identifier, type_t type, UNIT_PARAMS);
public:
Unit(Unit&&) = default;
-
- icon_t get_icon() const;
- type_t get_type() const;
- std::string_view get_sprite() const;
- bool is_active() const;
- std::string_view get_unit_type() const;
- bool has_floating_flag() const;
-
- uint32_t get_priority() const;
- fixed_point_t get_max_strength() const;
- fixed_point_t get_default_organisation() const;
- fixed_point_t get_maximum_speed() const;
- fixed_point_t get_weighted_value() const;
-
- std::string_view get_move_sound() const;
- std::string_view get_select_sound() const;
-
- Timespan get_build_time() const;
- Good::good_map_t const& get_build_cost() const;
- fixed_point_t get_supply_consumption() const;
- Good::good_map_t const& get_supply_cost() const;
};
struct LandUnit : Unit {
friend struct UnitManager;
private:
- const bool primary_culture;
- const std::string sprite_override, sprite_mount, sprite_mount_attach_node;
- const fixed_point_t reconnaissance;
- const fixed_point_t attack;
- const fixed_point_t defence;
- const fixed_point_t discipline;
- const fixed_point_t support;
- const fixed_point_t maneuver;
- const fixed_point_t siege;
+ const bool PROPERTY_CUSTOM_NAME(primary_culture, is_primary_culture);
+ const std::string PROPERTY(sprite_override);
+ const std::string PROPERTY(sprite_mount);
+ const std::string PROPERTY(sprite_mount_attach_node);
+ const fixed_point_t PROPERTY(reconnaissance);
+ const fixed_point_t PROPERTY(attack);
+ const fixed_point_t PROPERTY(defence);
+ const fixed_point_t PROPERTY(discipline);
+ const fixed_point_t PROPERTY(support);
+ const fixed_point_t PROPERTY(maneuver);
+ const fixed_point_t PROPERTY(siege);
LandUnit(std::string_view identifier, UNIT_PARAMS, LAND_PARAMS);
public:
LandUnit(LandUnit&&) = default;
-
- bool get_primary_culture() const;
- std::string_view get_sprite_override() const;
- std::string_view get_sprite_mount() const;
- std::string_view get_sprite_mount_attach_node() const;
-
- fixed_point_t get_reconnaissance() const;
- fixed_point_t get_attack() const;
- fixed_point_t get_defence() const;
- fixed_point_t get_discipline() const;
- fixed_point_t get_support() const;
- fixed_point_t get_maneuver() const;
- fixed_point_t get_siege() const;
};
struct NavalUnit : Unit {
friend struct UnitManager;
private:
- const icon_t naval_icon;
- const bool sail;
- const bool transport;
- const bool capital;
- const fixed_point_t colonial_points;
- const bool build_overseas;
- const uint32_t min_port_level;
- const int32_t limit_per_port;
- const fixed_point_t supply_consumption_score;
-
- const fixed_point_t hull;
- const fixed_point_t gun_power;
- const fixed_point_t fire_range;
- const fixed_point_t evasion;
- const fixed_point_t torpedo_attack;
+ 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 fixed_point_t PROPERTY(colonial_points);
+ const bool PROPERTY_CUSTOM_NAME(build_overseas, can_build_overseas);
+ const uint32_t PROPERTY(min_port_level);
+ const int32_t PROPERTY(limit_per_port);
+ const fixed_point_t PROPERTY(supply_consumption_score);
+
+ const fixed_point_t PROPERTY(hull);
+ const fixed_point_t PROPERTY(gun_power);
+ const fixed_point_t PROPERTY(fire_range);
+ const fixed_point_t PROPERTY(evasion);
+ const fixed_point_t PROPERTY(torpedo_attack);
NavalUnit(std::string_view identifier, UNIT_PARAMS, NAVY_PARAMS);
public:
NavalUnit(NavalUnit&&) = default;
-
- icon_t get_naval_icon() const;
- bool can_sail() const;
- bool is_transport() const;
- bool is_capital() const;
- fixed_point_t get_colonial_points() const;
- bool can_build_overseas() const;
- uint32_t get_min_port_level() const;
- int32_t get_limit_per_port() const;
- fixed_point_t get_supply_consumption_score() const;
-
- fixed_point_t get_hull() const;
- fixed_point_t get_gun_power() const;
- fixed_point_t get_fire_range() const;
- fixed_point_t get_evasion() const;
- fixed_point_t get_torpedo_attack() const;
};
struct UnitManager {