diff options
41 files changed, 179 insertions, 1059 deletions
diff --git a/src/openvic-simulation/country/Country.cpp b/src/openvic-simulation/country/Country.cpp index 6ad13ee..935c409 100644 --- a/src/openvic-simulation/country/Country.cpp +++ b/src/openvic-simulation/country/Country.cpp @@ -27,22 +27,6 @@ CountryParty::CountryParty( ) : HasIdentifier { new_identifier }, start_date { new_start_date }, end_date { new_end_date }, ideology { new_ideology }, policies { std::move(new_policies) } {} -Date CountryParty::get_start_date() const { - return start_date; -} - -Date CountryParty::get_end_date() const { - return end_date; -} - -Ideology const& CountryParty::get_ideology() const { - return ideology; -} - -CountryParty::policy_map_t const& CountryParty::get_policies() const { - return policies; -} - Country::Country( std::string_view new_identifier, colour_t new_colour, GraphicalCultureType const& new_graphical_culture, IdentifierRegistry<CountryParty>&& new_parties, unit_names_map_t&& new_unit_names, bool new_dynamic_tag, @@ -51,22 +35,6 @@ Country::Country( parties { std::move(new_parties) }, unit_names { std::move(new_unit_names) }, dynamic_tag { new_dynamic_tag }, alternative_colours { std::move(new_alternative_colours) } {} -GraphicalCultureType const& Country::get_graphical_culture() const { - return graphical_culture; -} - -Country::unit_names_map_t const& Country::get_unit_names() const { - return unit_names; -} - -bool Country::is_dynamic_tag() const { - return dynamic_tag; -} - -Country::government_colour_map_t const& Country::get_alternative_colours() const { - return alternative_colours; -} - CountryManager::CountryManager() : countries { "countries" } {} bool CountryManager::add_country( diff --git a/src/openvic-simulation/country/Country.hpp b/src/openvic-simulation/country/Country.hpp index db1e40b..5b5c528 100644 --- a/src/openvic-simulation/country/Country.hpp +++ b/src/openvic-simulation/country/Country.hpp @@ -32,10 +32,10 @@ namespace OpenVic { using policy_map_t = std::map<IssueGroup const*, Issue const*>; private: - const Date start_date; - const Date end_date; - Ideology const& ideology; - const policy_map_t policies; + const Date PROPERTY(start_date); + const Date PROPERTY(end_date); + Ideology const& PROPERTY(ideology); + const policy_map_t PROPERTY(policies); CountryParty( std::string_view new_identifier, Date new_start_date, Date new_end_date, Ideology const& new_ideology, @@ -44,11 +44,6 @@ namespace OpenVic { public: CountryParty(CountryParty&&) = default; - - Date get_start_date() const; - Date get_end_date() const; - Ideology const& get_ideology() const; - policy_map_t const& get_policies() const; }; /* Generic information about a TAG */ @@ -59,14 +54,14 @@ namespace OpenVic { using government_colour_map_t = std::map<GovernmentType const*, colour_t>; private: - GraphicalCultureType const& graphical_culture; + GraphicalCultureType const& PROPERTY(graphical_culture); /* Not const to allow elements to be moved, otherwise a copy is forced * which causes a compile error as the copy constructor has been deleted. */ IdentifierRegistry<CountryParty> parties; - const unit_names_map_t unit_names; - const bool dynamic_tag; - const government_colour_map_t alternative_colours; + const unit_names_map_t PROPERTY(unit_names); + const bool PROPERTY_CUSTOM_NAME(dynamic_tag, is_dynamic_tag); + const government_colour_map_t PROPERTY(alternative_colours); Country( std::string_view new_identifier, colour_t new_colour, GraphicalCultureType const& new_graphical_culture, @@ -78,11 +73,6 @@ namespace OpenVic { Country(Country&&) = default; IDENTIFIER_REGISTRY_ACCESSORS_CUSTOM_PLURAL(party, parties) - - GraphicalCultureType const& get_graphical_culture() const; - unit_names_map_t const& get_unit_names() const; - bool is_dynamic_tag() const; - government_colour_map_t const& get_alternative_colours() const; }; struct CountryManager { diff --git a/src/openvic-simulation/economy/BuildingInstance.cpp b/src/openvic-simulation/economy/BuildingInstance.cpp index 417cdda..597b89e 100644 --- a/src/openvic-simulation/economy/BuildingInstance.cpp +++ b/src/openvic-simulation/economy/BuildingInstance.cpp @@ -3,17 +3,13 @@ using namespace OpenVic; BuildingInstance::BuildingInstance(BuildingType const& new_building_type, level_t new_level) - : HasIdentifier { building_type.get_identifier() }, building_type { new_building_type }, level { new_level }, + : HasIdentifier { new_building_type.get_identifier() }, building_type { new_building_type }, level { new_level }, expansion_state { ExpansionState::CannotExpand } {} bool BuildingInstance::_can_expand() const { return level < building_type.get_max_level(); } -void BuildingInstance::set_level(BuildingInstance::level_t new_level) { - level = new_level; -} - bool BuildingInstance::expand() { if (expansion_state == ExpansionState::CanExpand) { expansion_state = ExpansionState::Preparing; diff --git a/src/openvic-simulation/economy/BuildingInstance.hpp b/src/openvic-simulation/economy/BuildingInstance.hpp index 9fc9df1..00e2dd6 100644 --- a/src/openvic-simulation/economy/BuildingInstance.hpp +++ b/src/openvic-simulation/economy/BuildingInstance.hpp @@ -12,7 +12,7 @@ namespace OpenVic { private: BuildingType const& PROPERTY(building_type); - level_t PROPERTY(level); + level_t PROPERTY_RW(level); ExpansionState PROPERTY(expansion_state); Date PROPERTY(start_date) Date PROPERTY(end_date); @@ -24,8 +24,6 @@ namespace OpenVic { BuildingInstance(BuildingType const& new_building_type, level_t new_level = 0); BuildingInstance(BuildingInstance&&) = default; - void set_level(level_t new_level); - bool expand(); void update_state(Date today); void tick(Date today); diff --git a/src/openvic-simulation/economy/Good.cpp b/src/openvic-simulation/economy/Good.cpp index 4c1f7ba..b068644 100644 --- a/src/openvic-simulation/economy/Good.cpp +++ b/src/openvic-simulation/economy/Good.cpp @@ -16,38 +16,6 @@ Good::Good( assert(base_price > NULL_PRICE); } -GoodCategory const& Good::get_category() const { - return category; -} - -Good::price_t Good::get_base_price() const { - return base_price; -} - -Good::price_t Good::get_price() const { - return price; -} - -bool Good::get_available_from_start() const { - return available_from_start; -} - -bool Good::get_available() const { - return available; -} - -bool Good::get_tradeable() const { - return tradeable; -} - -bool Good::get_money() const { - return money; -} - -bool Good::get_overseas_penalty() { - return overseas_penalty; -} - void Good::reset_to_defaults() { available = available_from_start; price = base_price; diff --git a/src/openvic-simulation/economy/Good.hpp b/src/openvic-simulation/economy/Good.hpp index 805e6a5..ac85cbd 100644 --- a/src/openvic-simulation/economy/Good.hpp +++ b/src/openvic-simulation/economy/Good.hpp @@ -36,11 +36,15 @@ namespace OpenVic { using good_map_t = fixed_point_map_t<Good const*>; private: - GoodCategory const& category; - const price_t base_price; - price_t price; - const bool available_from_start, tradeable, money, overseas_penalty; - bool available; + GoodCategory const& PROPERTY(category); + const price_t PROPERTY(base_price); + const bool PROPERTY_CUSTOM_NAME(available_from_start, is_available_from_start); + const bool PROPERTY_CUSTOM_NAME(tradeable, is_tradeable); + const bool PROPERTY(money); + const bool PROPERTY(overseas_penalty); + + price_t PROPERTY_RW(price); + bool PROPERTY_RW(available); Good( std::string_view new_identifier, colour_t new_colour, GoodCategory const& new_category, price_t new_base_price, @@ -49,15 +53,6 @@ namespace OpenVic { public: Good(Good&&) = default; - - GoodCategory const& get_category() const; - price_t get_base_price() const; - price_t get_price() const; - bool get_available_from_start() const; - bool get_available() const; - bool get_tradeable() const; - bool get_money() const; - bool get_overseas_penalty(); void reset_to_defaults(); }; diff --git a/src/openvic-simulation/economy/ProductionType.cpp b/src/openvic-simulation/economy/ProductionType.cpp index 6eb7ff9..6bd3858 100644 --- a/src/openvic-simulation/economy/ProductionType.cpp +++ b/src/openvic-simulation/economy/ProductionType.cpp @@ -1,7 +1,5 @@ #include "ProductionType.hpp" -#include <set> - using namespace OpenVic; using namespace OpenVic::NodeTools; @@ -10,80 +8,12 @@ EmployedPop::EmployedPop( ) : pop_type { pop_type }, artisan { artisan }, effect { effect }, effect_multiplier { effect_multiplier }, amount { amount } {} -PopType const* EmployedPop::get_pop_type() const { - return pop_type; -} - -bool EmployedPop::is_artisan() const { - return artisan; -} - -EmployedPop::effect_t EmployedPop::get_effect() const { - return effect; -} - -fixed_point_t EmployedPop::get_effect_multiplier() const { - return effect_multiplier; -} - -fixed_point_t EmployedPop::get_amount() const { - return amount; -} - ProductionType::ProductionType( PRODUCTION_TYPE_ARGS ) : HasIdentifier { identifier }, owner { owner }, employees { employees }, type { type }, workforce { workforce }, input_goods { std::move(input_goods) }, output_goods { output_goods }, value { value }, bonuses { std::move(bonuses) }, efficiency { std::move(efficiency) }, coastal { coastal }, farm { farm }, mine { mine } {} -EmployedPop const& ProductionType::get_owner() const { - return owner; -} - -std::vector<EmployedPop> const& ProductionType::get_employees() const { - return employees; -} - -ProductionType::type_t ProductionType::get_type() const { - return type; -} - -Pop::pop_size_t ProductionType::get_workforce() const { - return workforce; -} - -Good::good_map_t const& ProductionType::get_input_goods() const { - return input_goods; -} - -Good const* ProductionType::get_output_goods() const { - return output_goods; -} - -fixed_point_t ProductionType::get_value() const { - return value; -} - -std::vector<Bonus> const& ProductionType::get_bonuses() const { - return bonuses; -} - -Good::good_map_t const& ProductionType::get_efficiency() const { - return efficiency; -} - -bool ProductionType::is_coastal() const { - return coastal; -} - -bool ProductionType::is_farm() const { - return farm; -} - -bool ProductionType::is_mine() const { - return mine; -} - ProductionTypeManager::ProductionTypeManager() : production_types { "production types" } {} node_callback_t ProductionTypeManager::_expect_employed_pop( diff --git a/src/openvic-simulation/economy/ProductionType.hpp b/src/openvic-simulation/economy/ProductionType.hpp index 13862a7..b03f16b 100644 --- a/src/openvic-simulation/economy/ProductionType.hpp +++ b/src/openvic-simulation/economy/ProductionType.hpp @@ -19,11 +19,11 @@ namespace OpenVic { enum struct effect_t { INPUT, OUTPUT, THROUGHPUT }; private: - PopType const* pop_type; // poptype - bool artisan; // set by the parser if the magic "artisan" poptype is passed - effect_t effect; - fixed_point_t effect_multiplier; - fixed_point_t amount; + PopType const* PROPERTY(pop_type); // poptype + bool PROPERTY(artisan); // set by the parser if the magic "artisan" poptype is passed + effect_t PROPERTY(effect); + fixed_point_t PROPERTY(effect_multiplier); + fixed_point_t PROPERTY(amount); EmployedPop( PopType const* pop_type, bool artisan, effect_t effect, fixed_point_t effect_multiplier, fixed_point_t amount @@ -31,12 +31,6 @@ namespace OpenVic { public: EmployedPop() = default; - - PopType const* get_pop_type() const; - bool is_artisan() const; - effect_t get_effect() const; - fixed_point_t get_effect_multiplier() const; - fixed_point_t get_amount() const; }; struct Bonus { @@ -48,42 +42,26 @@ namespace OpenVic { friend struct ProductionTypeManager; private: - const EmployedPop owner; - const std::vector<EmployedPop> employees; - const enum struct type_t { FACTORY, RGO, ARTISAN } type; + const EmployedPop PROPERTY(owner); + const std::vector<EmployedPop> PROPERTY(employees); + const enum struct type_t { FACTORY, RGO, ARTISAN } PROPERTY(type); const Pop::pop_size_t workforce; - const Good::good_map_t input_goods; - Good const* output_goods; - const fixed_point_t value; - const std::vector<Bonus> bonuses; + const Good::good_map_t PROPERTY(input_goods); + Good const* PROPERTY(output_goods); + const fixed_point_t PROPERTY(value); + const std::vector<Bonus> PROPERTY(bonuses); - const Good::good_map_t efficiency; - const bool coastal; // is_coastal + const Good::good_map_t PROPERTY(efficiency); + const bool PROPERTY_CUSTOM_NAME(coastal, is_coastal); // is_coastal - const bool farm; - const bool mine; + const bool PROPERTY_CUSTOM_NAME(farm, is_farm); + const bool PROPERTY_CUSTOM_NAME(mine, is_mine); ProductionType(PRODUCTION_TYPE_ARGS); public: ProductionType(ProductionType&&) = default; - - EmployedPop const& get_owner() const; - std::vector<EmployedPop> const& get_employees() const; - type_t get_type() const; - Pop::pop_size_t get_workforce() const; - - Good::good_map_t const& get_input_goods() const; - Good const* get_output_goods() const; - fixed_point_t get_value() const; - std::vector<Bonus> const& get_bonuses() const; - - Good::good_map_t const& get_efficiency() const; - bool is_coastal() const; - - bool is_farm() const; - bool is_mine() const; }; struct ProductionTypeManager { diff --git a/src/openvic-simulation/history/Bookmark.cpp b/src/openvic-simulation/history/Bookmark.cpp index 92d8de5..483b49b 100644 --- a/src/openvic-simulation/history/Bookmark.cpp +++ b/src/openvic-simulation/history/Bookmark.cpp @@ -17,26 +17,6 @@ Bookmark::Bookmark( ) : HasIdentifier { std::to_string(new_index) }, name { new_name }, description { new_description }, date { new_date }, initial_camera_x { new_initial_camera_x }, initial_camera_y { new_initial_camera_y } {} -std::string_view Bookmark::get_name() const { - return name; -} - -std::string_view Bookmark::get_description() const { - return description; -} - -Date Bookmark::get_date() const { - return date; -} - -uint32_t Bookmark::get_initial_camera_x() const { - return initial_camera_x; -} - -uint32_t Bookmark::get_initial_camera_y() const { - return initial_camera_y; -} - BookmarkManager::BookmarkManager() : bookmarks { "bookmarks" } {} bool BookmarkManager::add_bookmark( diff --git a/src/openvic-simulation/history/Bookmark.hpp b/src/openvic-simulation/history/Bookmark.hpp index d5253fe..18375fb 100644 --- a/src/openvic-simulation/history/Bookmark.hpp +++ b/src/openvic-simulation/history/Bookmark.hpp @@ -13,11 +13,11 @@ namespace OpenVic { friend struct BookmarkManager; private: - const std::string name; - const std::string description; - const Date date; - const uint32_t initial_camera_x; - const uint32_t initial_camera_y; + const std::string PROPERTY(name); + const std::string PROPERTY(description); + const Date PROPERTY(date); + const uint32_t PROPERTY(initial_camera_x); + const uint32_t PROPERTY(initial_camera_y); Bookmark( size_t new_index, std::string_view new_name, std::string_view new_description, Date new_date, @@ -26,12 +26,6 @@ namespace OpenVic { public: Bookmark(Bookmark&&) = default; - - std::string_view get_name() const; - std::string_view get_description() const; - Date get_date() const; - uint32_t get_initial_camera_x() const; - uint32_t get_initial_camera_y() const; }; struct BookmarkManager { diff --git a/src/openvic-simulation/history/DiplomaticHistory.cpp b/src/openvic-simulation/history/DiplomaticHistory.cpp index 5cbafe7..5c560ea 100644 --- a/src/openvic-simulation/history/DiplomaticHistory.cpp +++ b/src/openvic-simulation/history/DiplomaticHistory.cpp @@ -15,48 +15,12 @@ WarHistory::added_wargoal_t::added_wargoal_t( std::optional<Province const*> new_target ) : added { new_added }, actor { new_actor }, receiver { new_receiver }, wargoal { new_wargoal }, third_party { new_third_party }, target { new_target } {} -Country const* WarHistory::added_wargoal_t::get_actor() const { - return actor; -} - -Country const* WarHistory::added_wargoal_t::get_receiver() const { - return receiver; -} - -WargoalType const* WarHistory::added_wargoal_t::get_wargoal_type() const { - return wargoal; -} - -std::optional<Country const*> const& WarHistory::added_wargoal_t::get_third_party() const { - return third_party; -} - -std::optional<Province const*> const& WarHistory::added_wargoal_t::get_target() const { - return target; -} - -Date WarHistory::added_wargoal_t::get_date_added() const { - return added; -} - WarHistory::war_participant_t::war_participant_t( Country const* new_country, Date new_joined, std::optional<Date> new_exited ) : country { new_country }, joined { new_joined }, exited { new_exited } {} -Country const* WarHistory::war_participant_t::get_country() const { - return country; -} - -Date WarHistory::war_participant_t::get_date_joined() const { - return joined; -} - -std::optional<Date> WarHistory::war_participant_t::get_date_exited() const { - return exited; -} - WarHistory::WarHistory( std::string_view new_war_name, std::vector<war_participant_t>&& new_attackers, @@ -64,52 +28,16 @@ WarHistory::WarHistory( std::vector<added_wargoal_t>&& new_wargoals ) : war_name { new_war_name }, attackers { std::move(new_attackers) }, defenders { std::move(new_defenders) }, wargoals { std::move(new_wargoals) } {} -std::string_view WarHistory::get_war_name() const { - return war_name; -} - -std::vector<WarHistory::war_participant_t> const& WarHistory::get_attackers() const { - return attackers; -} - -std::vector<WarHistory::war_participant_t> const& WarHistory::get_defenders() const { - return defenders; -} - -std::vector<WarHistory::added_wargoal_t> const& WarHistory::get_wargoals() const { - return wargoals; -} - AllianceHistory::AllianceHistory( Country const* new_first, Country const* new_second, Date new_start, Date new_end ) : first { new_first }, second { new_second }, start { new_start }, end { new_end } {} -Country const* AllianceHistory::get_first() const { - return first; -} - -Country const* AllianceHistory::get_second() const { - return second; -} - SubjectHistory::SubjectHistory( Country const* new_overlord, Country const* new_subject, const type_t new_type, const Date new_start, const Date new_end ) : overlord { new_overlord }, subject { new_subject }, type { new_type }, start { new_start }, end { new_end } {} -Country const* SubjectHistory::get_overlord() const { - return overlord; -} - -Country const* SubjectHistory::get_subject() const { - return subject; -} - -const SubjectHistory::type_t SubjectHistory::get_subject_type() const { - return type; -} - void DiplomaticHistoryManager::lock_diplomatic_history() { Logger::info("Locked diplomacy history registry after registering ", alliances.size() + subjects.size() + wars.size(), " items"); locked = true; diff --git a/src/openvic-simulation/history/DiplomaticHistory.hpp b/src/openvic-simulation/history/DiplomaticHistory.hpp index 64529c2..3ed253f 100644 --- a/src/openvic-simulation/history/DiplomaticHistory.hpp +++ b/src/openvic-simulation/history/DiplomaticHistory.hpp @@ -19,69 +19,46 @@ namespace OpenVic { friend struct DiplomaticHistoryManager; private: - Date added; - Country const* actor; - Country const* receiver; - WargoalType const* wargoal; - std::optional<Country const*> third_party; - std::optional<Province const*> target; + Date PROPERTY_CUSTOM_NAME(added, get_date_added); + Country const* PROPERTY(actor); + Country const* PROPERTY(receiver); + WargoalType const* PROPERTY(wargoal); + std::optional<Country const*> PROPERTY(third_party); + std::optional<Province const*> PROPERTY(target); added_wargoal_t(Date new_added, Country const* new_actor, Country const* new_receiver, WargoalType const* new_wargoal, std::optional<Country const*> new_third_party, std::optional<Province const*> new_target); - - public: - Date get_date_added() const; - Country const* get_actor() const; - Country const* get_receiver() const; - WargoalType const* get_wargoal_type() const; - std::optional<Country const*> const& get_third_party() const; - std::optional<Province const*> const& get_target() const; }; struct war_participant_t { friend struct DiplomaticHistoryManager; private: - Country const* country; - Date joined; - std::optional<Date> exited; + Country const* PROPERTY(country); + Date PROPERTY_CUSTOM_NAME(joined, get_date_joined); + std::optional<Date> PROPERTY_CUSTOM_NAME(exited, get_date_exited); war_participant_t(Country const* new_country, Date new_joined, std::optional<Date> new_exited); - - public: - Country const* get_country() const; - Date get_date_joined() const; - std::optional<Date> get_date_exited() const; }; private: - std::string war_name; // edge cases where this is empty/undef for some reason, probably need to just generate war names like usual for that. - std::vector<war_participant_t> attackers; - std::vector<war_participant_t> defenders; - std::vector<added_wargoal_t> wargoals; + std::string PROPERTY(war_name); // edge cases where this is empty/undef for some reason, probably need to just generate war names like usual for that. + std::vector<war_participant_t> PROPERTY(attackers); + std::vector<war_participant_t> PROPERTY(defenders); + std::vector<added_wargoal_t> PROPERTY(wargoals); WarHistory(std::string_view new_war_name, std::vector<war_participant_t>&& new_attackers, std::vector<war_participant_t>&& new_defenders, std::vector<added_wargoal_t>&& new_wargoals); - - public: - std::string_view get_war_name() const; - std::vector<war_participant_t> const& get_attackers() const; - std::vector<war_participant_t> const& get_defenders() const; - std::vector<added_wargoal_t> const& get_wargoals() const; }; struct AllianceHistory { friend struct DiplomaticHistoryManager; private: - Country const* first; - Country const* second; + Country const* PROPERTY(first); + Country const* PROPERTY(second); const Date start; const Date end; AllianceHistory(Country const* new_first, Country const* new_second, const Date new_start, const Date new_end); - - public: - Country const* get_first() const; - Country const* get_second() const; }; struct SubjectHistory { @@ -94,18 +71,13 @@ namespace OpenVic { }; private: - Country const* overlord; - Country const* subject; - const type_t type; + Country const* PROPERTY(overlord); + Country const* PROPERTY(subject); + const type_t PROPERTY_CUSTOM_NAME(type, get_subject_type); const Date start; const Date end; SubjectHistory(Country const* new_overlord, Country const* new_subject, const type_t new_type, const Date new_start, const Date new_end); - - public: - Country const* get_overlord() const; - Country const* get_subject() const; - const type_t get_subject_type() const; }; struct DiplomaticHistoryManager { diff --git a/src/openvic-simulation/map/Map.cpp b/src/openvic-simulation/map/Map.cpp index 6df7537..549e539 100644 --- a/src/openvic-simulation/map/Map.cpp +++ b/src/openvic-simulation/map/Map.cpp @@ -21,10 +21,6 @@ const Mapmode Mapmode::ERROR_MAPMODE { "mapmode_error", 0, [](Map const& map, Province const& province) -> colour_t { return 0xFFFF0000; } }; -Mapmode::index_t Mapmode::get_index() const { - return index; -} - Mapmode::base_stripe_t Mapmode::get_base_stripe_colours(Map const& map, Province const& province) const { return colour_func ? colour_func(map, province) : NULL_COLOUR; } diff --git a/src/openvic-simulation/map/Map.hpp b/src/openvic-simulation/map/Map.hpp index 189713c..4f87237 100644 --- a/src/openvic-simulation/map/Map.hpp +++ b/src/openvic-simulation/map/Map.hpp @@ -21,7 +21,7 @@ namespace OpenVic { using index_t = size_t; private: - const index_t index; + const index_t PROPERTY(index); const colour_func_t colour_func; Mapmode(std::string_view new_identifier, index_t new_index, colour_func_t new_colour_func); @@ -31,7 +31,6 @@ namespace OpenVic { Mapmode(Mapmode&&) = default; - index_t get_index() const; base_stripe_t get_base_stripe_colours(Map const& map, Province const& province) const; }; diff --git a/src/openvic-simulation/map/TerrainType.cpp b/src/openvic-simulation/map/TerrainType.cpp index f138cb2..3048b66 100644 --- a/src/openvic-simulation/map/TerrainType.cpp +++ b/src/openvic-simulation/map/TerrainType.cpp @@ -10,36 +10,13 @@ TerrainType::TerrainType( ) : HasIdentifierAndColour { new_identifier, new_colour, false, false }, modifier { std::move(new_modifier) }, is_water { new_is_water } {} -ModifierValue const& TerrainType::get_modifier() const { - return modifier; -} - -bool TerrainType::get_is_water() const { - return is_water; -} TerrainTypeMapping::TerrainTypeMapping( std::string_view new_identifier, TerrainType const& new_type, std::vector<index_t>&& new_terrain_indicies, index_t new_priority, bool new_has_texture -) : HasIdentifier { new_identifier }, type { new_type }, terrain_indicies { std::move(new_terrain_indicies) }, +) : HasIdentifier { new_identifier }, type { new_type }, terrain_indices { std::move(new_terrain_indicies) }, priority { new_priority }, has_texture { new_has_texture } {} -TerrainType const& TerrainTypeMapping::get_type() const { - return type; -} - -std::vector<TerrainTypeMapping::index_t> const& TerrainTypeMapping::get_terrain_indicies() const { - return terrain_indicies; -} - -TerrainTypeMapping::index_t TerrainTypeMapping::get_priority() const { - return priority; -} - -bool TerrainTypeMapping::get_has_texture() const { - return has_texture; -} - TerrainTypeManager::TerrainTypeManager() : terrain_types { "terrain types" }, terrain_type_mappings { "terrain type mappings" } {} diff --git a/src/openvic-simulation/map/TerrainType.hpp b/src/openvic-simulation/map/TerrainType.hpp index 92f78dd..0fd5157 100644 --- a/src/openvic-simulation/map/TerrainType.hpp +++ b/src/openvic-simulation/map/TerrainType.hpp @@ -9,16 +9,13 @@ namespace OpenVic { friend struct TerrainTypeManager; private: - const ModifierValue modifier; - const bool is_water; + const ModifierValue PROPERTY(modifier); + const bool PROPERTY(is_water); TerrainType(std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_modifier, bool new_is_water); public: TerrainType(TerrainType&&) = default; - - ModifierValue const& get_modifier() const; - bool get_is_water() const; }; struct TerrainTypeMapping : HasIdentifier { @@ -27,10 +24,10 @@ namespace OpenVic { using index_t = uint8_t; private: - TerrainType const& type; - const std::vector<index_t> terrain_indicies; - const index_t priority; - const bool has_texture; + TerrainType const& PROPERTY(type); + const std::vector<index_t> PROPERTY(terrain_indices); + const index_t PROPERTY(priority); + const bool PROPERTY(has_texture); TerrainTypeMapping( std::string_view new_identifier, TerrainType const& new_type, std::vector<index_t>&& new_terrain_indicies, @@ -39,11 +36,6 @@ namespace OpenVic { public: TerrainTypeMapping(TerrainTypeMapping&&) = default; - - TerrainType const& get_type() const; - std::vector<index_t> const& get_terrain_indicies() const; - index_t get_priority() const; - bool get_has_texture() const; }; struct TerrainTypeManager { 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 { diff --git a/src/openvic-simulation/misc/Modifier.cpp b/src/openvic-simulation/misc/Modifier.cpp index 0386833..89a411c 100644 --- a/src/openvic-simulation/misc/Modifier.cpp +++ b/src/openvic-simulation/misc/Modifier.cpp @@ -6,14 +6,6 @@ using namespace OpenVic::NodeTools; ModifierEffect::ModifierEffect(std::string_view new_identifier, bool new_positive_good, format_t new_format) : HasIdentifier { new_identifier }, positive_good { new_positive_good }, format { new_format } {} -bool ModifierEffect::get_positive_good() const { - return positive_good; -} - -ModifierEffect::format_t ModifierEffect::get_format() const { - return format; -} - ModifierValue::ModifierValue() = default; ModifierValue::ModifierValue(effect_map_t&& new_values) : values { std::move(new_values) } {} ModifierValue::ModifierValue(ModifierValue const&) = default; @@ -85,21 +77,9 @@ ModifierValue ModifierValue::operator-(ModifierValue const& right) const { Modifier::Modifier(std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon) : HasIdentifier { new_identifier }, ModifierValue { std::move(new_values) }, icon { new_icon } {} -Modifier::icon_t Modifier::get_icon() const { - return icon; -} - ModifierInstance::ModifierInstance(Modifier const& modifier, Date expiry_date) : modifier { modifier }, expiry_date { expiry_date } {} -Modifier const& ModifierInstance::get_modifier() const { - return modifier; -} - -Date ModifierInstance::get_expiry_date() const { - return expiry_date; -} - ModifierManager::ModifierManager() : modifier_effects { "modifier effects" }, event_modifiers { "event modifiers" } {} bool ModifierManager::add_modifier_effect(std::string_view identifier, bool positive_good, ModifierEffect::format_t format) { diff --git a/src/openvic-simulation/misc/Modifier.hpp b/src/openvic-simulation/misc/Modifier.hpp index e6ea54e..34acd9d 100644 --- a/src/openvic-simulation/misc/Modifier.hpp +++ b/src/openvic-simulation/misc/Modifier.hpp @@ -19,8 +19,8 @@ namespace OpenVic { /* If true, positive values will be green and negative values will be red. * If false, the colours will be switced. */ - const bool positive_good; - const format_t format; + const bool PROPERTY_CUSTOM_NAME(positive_good, is_positive_good); + const format_t PROPERTY(format); // TODO - format/precision, e.g. 80% vs 0.8 vs 0.800, 2 vs 2.0 vs 200% @@ -28,9 +28,6 @@ namespace OpenVic { public: ModifierEffect(ModifierEffect&&) = default; - - bool get_positive_good() const; - format_t get_format() const; }; struct ModifierValue { @@ -73,27 +70,21 @@ namespace OpenVic { private: /* A modifier can have no icon (zero). */ - const icon_t icon; + const icon_t PROPERTY(icon); Modifier(std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon); public: Modifier(Modifier&&) = default; - - icon_t get_icon() const; }; struct ModifierInstance { private: - Modifier const& modifier; - Date expiry_date; + Modifier const& PROPERTY(modifier); + Date PROPERTY(expiry_date); ModifierInstance(Modifier const& modifier, Date expiry_date); - - public: - Modifier const& get_modifier() const; - Date get_expiry_date() const; }; template<typename Fn> diff --git a/src/openvic-simulation/politics/Government.cpp b/src/openvic-simulation/politics/Government.cpp index 3b0f28d..0d1d063 100644 --- a/src/openvic-simulation/politics/Government.cpp +++ b/src/openvic-simulation/politics/Government.cpp @@ -16,26 +16,6 @@ bool GovernmentType::is_ideology_compatible(Ideology const* ideology) const { return std::find(ideologies.begin(), ideologies.end(), ideology) != ideologies.end(); } -std::vector<Ideology const*> const& GovernmentType::get_ideologies() const { - return ideologies; -} - -bool GovernmentType::holds_elections() const { - return elections; -} - -bool GovernmentType::can_appoint_ruling_party() const { - return appoint_ruling_party; -} - -Timespan GovernmentType::get_term_duration() const { - return term_duration; -} - -std::string_view GovernmentType::get_flag_type() const { - return flag_type_identifier; -} - GovernmentTypeManager::GovernmentTypeManager() : government_types { "government types" } {} bool GovernmentTypeManager::add_government_type( diff --git a/src/openvic-simulation/politics/Government.hpp b/src/openvic-simulation/politics/Government.hpp index 9fff111..fde7d32 100644 --- a/src/openvic-simulation/politics/Government.hpp +++ b/src/openvic-simulation/politics/Government.hpp @@ -9,10 +9,11 @@ namespace OpenVic { friend struct GovernmentTypeManager; private: - const std::vector<Ideology const*> ideologies; - const bool elections, appoint_ruling_party; - const Timespan term_duration; - const std::string flag_type_identifier; + const std::vector<Ideology const*> PROPERTY(ideologies); + const bool PROPERTY_CUSTOM_NAME(elections, holds_elections); + const bool PROPERTY_CUSTOM_NAME(appoint_ruling_party, can_appoint_ruling_party); + const Timespan PROPERTY(term_duration); + const std::string PROPERTY_CUSTOM_NAME(flag_type_identifier, get_flag_type); GovernmentType( std::string_view new_identifier, std::vector<Ideology const*>&& new_ideologies, bool new_elections, @@ -23,11 +24,6 @@ namespace OpenVic { GovernmentType(GovernmentType&&) = default; bool is_ideology_compatible(Ideology const* ideology) const; - std::vector<Ideology const*> const& get_ideologies() const; - bool holds_elections() const; - bool can_appoint_ruling_party() const; - Timespan get_term_duration() const; - std::string_view get_flag_type() const; }; struct GovernmentTypeManager { diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp index 148d6ac..569f834 100644 --- a/src/openvic-simulation/politics/Ideology.cpp +++ b/src/openvic-simulation/politics/Ideology.cpp @@ -11,22 +11,6 @@ Ideology::Ideology( ) : HasIdentifierAndColour { new_identifier, new_colour, false, false }, group { new_group }, uncivilised { new_uncivilised }, can_reduce_militancy { new_can_reduce_militancy }, spawn_date { new_spawn_date } {} -IdeologyGroup const& Ideology::get_group() const { - return group; -} - -bool Ideology::is_uncivilised() const { - return uncivilised; -} - -bool Ideology::get_can_reduce_militancy() const { - return can_reduce_militancy; -} - -Date Ideology::get_spawn_date() const { - return spawn_date; -} - IdeologyManager::IdeologyManager() : ideology_groups { "ideology groups" }, ideologies { "ideologies" } {} bool IdeologyManager::add_ideology_group(std::string_view identifier) { diff --git a/src/openvic-simulation/politics/Ideology.hpp b/src/openvic-simulation/politics/Ideology.hpp index bdf9f91..47ae45b 100644 --- a/src/openvic-simulation/politics/Ideology.hpp +++ b/src/openvic-simulation/politics/Ideology.hpp @@ -19,9 +19,10 @@ namespace OpenVic { friend struct IdeologyManager; private: - IdeologyGroup const& group; - const bool uncivilised, can_reduce_militancy; - const Date spawn_date; + IdeologyGroup const& PROPERTY(group); + const bool PROPERTY_CUSTOM_NAME(uncivilised, is_uncivilised); + const bool PROPERTY(can_reduce_militancy); + const Date PROPERTY(spawn_date); // TODO - willingness to repeal/pass reforms (and its modifiers) @@ -32,11 +33,6 @@ namespace OpenVic { public: Ideology(Ideology&&) = default; - - IdeologyGroup const& get_group() const; - bool is_uncivilised() const; - bool get_can_reduce_militancy() const; - Date get_spawn_date() const; }; struct IdeologyManager { diff --git a/src/openvic-simulation/politics/Issue.cpp b/src/openvic-simulation/politics/Issue.cpp index cc3c12b..9164831 100644 --- a/src/openvic-simulation/politics/Issue.cpp +++ b/src/openvic-simulation/politics/Issue.cpp @@ -7,43 +7,15 @@ IssueGroup::IssueGroup(std::string_view new_identifier) : HasIdentifier { new_id Issue::Issue(std::string_view identifier, IssueGroup const& group) : HasIdentifier { identifier }, group { group } {} -IssueGroup const& Issue::get_group() const { - return group; -} - ReformType::ReformType(std::string_view new_identifier, bool uncivilised) : HasIdentifier { new_identifier }, uncivilised { uncivilised } {} ReformGroup::ReformGroup(std::string_view identifier, ReformType const& type, bool ordered, bool administrative) : IssueGroup { identifier }, type { type }, ordered { ordered }, administrative { administrative } {} -ReformType const& ReformGroup::get_type() const { - return type; -} - -bool ReformGroup::is_ordered() const { - return ordered; -} - -bool ReformGroup::is_administrative() const { - return administrative; -} - Reform::Reform(std::string_view identifier, ReformGroup const& group, size_t ordinal) : Issue { identifier, group }, ordinal { ordinal }, reform_group { group } {} -ReformGroup const& Reform::get_reform_group() const { - return reform_group; -} - -ReformType const& Reform::get_type() const { - return get_reform_group().get_type(); -} - -size_t Reform::get_ordinal() const { - return ordinal; -} - IssueManager::IssueManager() : issue_groups { "issue groups" }, issues { "issues" }, reform_types { "reform types" }, reform_groups { "reform groups" }, reforms { "reforms" } {} diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp index 84aa886..0dceae9 100644 --- a/src/openvic-simulation/politics/Issue.hpp +++ b/src/openvic-simulation/politics/Issue.hpp @@ -25,7 +25,7 @@ namespace OpenVic { friend struct IssueManager; private: - IssueGroup const& group; + IssueGroup const& PROPERTY(group); // TODO: policy modifiers, policy rule changes @@ -34,7 +34,6 @@ namespace OpenVic { public: Issue(Issue&&) = default; - IssueGroup const& get_group() const; }; // Reform type (i.e. political_issues) @@ -56,17 +55,14 @@ namespace OpenVic { friend struct IssueManager; private: - ReformType const& type; - const bool ordered; // next_step_only - const bool administrative; + ReformType const& PROPERTY(type); + const bool PROPERTY_CUSTOM_NAME(ordered, is_ordered); // next_step_only + const bool PROPERTY_CUSTOM_NAME(administrative, is_administrative); ReformGroup(std::string_view identifier, ReformType const& type, bool ordered, bool administrative); public: ReformGroup(ReformGroup&&) = default; - ReformType const& get_type() const; - bool is_ordered() const; - bool is_administrative() const; }; // Reform (i.e. yes_slavery) @@ -74,8 +70,8 @@ namespace OpenVic { friend struct IssueManager; private: - ReformGroup const& reform_group; // stores an already casted reference - const size_t ordinal; // assigned by the parser to allow policy sorting + ReformGroup const& PROPERTY(reform_group); // stores an already casted reference + const size_t PROPERTY(ordinal); // assigned by the parser to allow policy sorting Reform(std::string_view new_identifier, ReformGroup const& group, size_t ordinal); @@ -83,9 +79,6 @@ namespace OpenVic { public: Reform(Reform&&) = default; - ReformGroup const& get_reform_group() const; - ReformType const& get_type() const; - size_t get_ordinal() const; }; // Issue manager - holds the registries diff --git a/src/openvic-simulation/politics/NationalValue.cpp b/src/openvic-simulation/politics/NationalValue.cpp index f1d8a3b..3760eec 100644 --- a/src/openvic-simulation/politics/NationalValue.cpp +++ b/src/openvic-simulation/politics/NationalValue.cpp @@ -6,10 +6,6 @@ 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) { diff --git a/src/openvic-simulation/politics/NationalValue.hpp b/src/openvic-simulation/politics/NationalValue.hpp index 625be36..824da7e 100644 --- a/src/openvic-simulation/politics/NationalValue.hpp +++ b/src/openvic-simulation/politics/NationalValue.hpp @@ -10,14 +10,12 @@ namespace OpenVic { friend struct NationalValueManager; private: - const ModifierValue modifiers; + const ModifierValue PROPERTY(modifiers); NationalValue(std::string_view new_identifier, ModifierValue&& new_modifiers); public: NationalValue(NationalValue&&) = default; - - ModifierValue const& get_modifiers() const; }; struct NationalValueManager { diff --git a/src/openvic-simulation/pop/Culture.cpp b/src/openvic-simulation/pop/Culture.cpp index 376e2a3..bc17290 100644 --- a/src/openvic-simulation/pop/Culture.cpp +++ b/src/openvic-simulation/pop/Culture.cpp @@ -13,36 +13,12 @@ CultureGroup::CultureGroup( ) : HasIdentifier { new_identifier }, leader { new_leader }, unit_graphical_culture_type { new_unit_graphical_culture_type }, is_overseas { new_is_overseas } {} -std::string_view CultureGroup::get_leader() const { - return leader; -} - -GraphicalCultureType const& CultureGroup::get_unit_graphical_culture_type() const { - return unit_graphical_culture_type; -} - -bool CultureGroup::get_is_overseas() const { - return is_overseas; -} - Culture::Culture( std::string_view new_identifier, colour_t new_colour, CultureGroup const& new_group, std::vector<std::string>&& new_first_names, std::vector<std::string>&& new_last_names ) : HasIdentifierAndColour { new_identifier, new_colour, false, false }, group { new_group }, first_names { std::move(new_first_names) }, last_names { std::move(new_last_names) } {} -CultureGroup const& Culture::get_group() const { - return group; -} - -std::vector<std::string> const& Culture::get_first_names() const { - return first_names; -} - -std::vector<std::string> const& Culture::get_last_names() const { - return last_names; -} - CultureManager::CultureManager() : graphical_culture_types { "graphical culture types" }, culture_groups { "culture groups" }, cultures { "cultures" } {} diff --git a/src/openvic-simulation/pop/Culture.hpp b/src/openvic-simulation/pop/Culture.hpp index 2abe77d..ff5f7c5 100644 --- a/src/openvic-simulation/pop/Culture.hpp +++ b/src/openvic-simulation/pop/Culture.hpp @@ -20,9 +20,9 @@ namespace OpenVic { friend struct CultureManager; private: - const std::string leader; - GraphicalCultureType const& unit_graphical_culture_type; - const bool is_overseas; + const std::string PROPERTY(leader); + GraphicalCultureType const& PROPERTY(unit_graphical_culture_type); + const bool PROPERTY(is_overseas); // TODO - union tag @@ -33,18 +33,15 @@ namespace OpenVic { public: CultureGroup(CultureGroup&&) = default; - - std::string_view get_leader() const; - GraphicalCultureType const& get_unit_graphical_culture_type() const; - bool get_is_overseas() const; }; struct Culture : HasIdentifierAndColour { friend struct CultureManager; private: - CultureGroup const& group; - const std::vector<std::string> first_names, last_names; + CultureGroup const& PROPERTY(group); + const std::vector<std::string> PROPERTY(first_names); + const std::vector<std::string> PROPERTY(last_names); // TODO - radicalism, primary tag @@ -55,10 +52,6 @@ namespace OpenVic { public: Culture(Culture&&) = default; - - CultureGroup const& get_group() const; - std::vector<std::string> const& get_first_names() const; - std::vector<std::string> const& get_last_names() const; }; struct CultureManager { diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp index 0b61096..31ab6d5 100644 --- a/src/openvic-simulation/pop/Pop.cpp +++ b/src/openvic-simulation/pop/Pop.cpp @@ -15,34 +15,6 @@ Pop::Pop( assert(size > 0); } -PopType const& Pop::get_type() const { - return type; -} - -Culture const& Pop::get_culture() const { - return culture; -} - -Religion const& Pop::get_religion() const { - return religion; -} - -Pop::pop_size_t Pop::get_size() const { - return size; -} - -Pop::pop_size_t Pop::get_num_promoted() const { - return num_promoted; -} - -Pop::pop_size_t Pop::get_num_demoted() const { - return num_demoted; -} - -Pop::pop_size_t Pop::get_num_migrated() const { - return num_migrated; -} - Pop::pop_size_t Pop::get_pop_daily_change() const { return Pop::get_num_promoted() - (Pop::get_num_demoted() + Pop::get_num_migrated()); } @@ -62,54 +34,6 @@ PopType::PopType( assert(merge_max_size >= 0); } -PopType::sprite_t PopType::get_sprite() const { - return sprite; -} - -Good::good_map_t const& PopType::get_life_needs() const { - return life_needs; -} - -Good::good_map_t const& PopType::get_everyday_needs() const { - return everyday_needs; -} - -Good::good_map_t const& PopType::get_luxury_needs() const { - return luxury_needs; -} - -PopType::rebel_units_t const& PopType::get_rebel_units() const { - return rebel_units; -} - -PopType::strata_t PopType::get_strata() const { - return strata; -} - -Pop::pop_size_t PopType::get_max_size() const { - return max_size; -} - -Pop::pop_size_t PopType::get_merge_max_size() const { - return merge_max_size; -} - -bool PopType::get_state_capital_only() const { - return state_capital_only; -} - -bool PopType::get_demote_migrant() const { - return demote_migrant; -} - -bool PopType::get_is_artisan() const { - return is_artisan; -} - -bool PopType::get_is_slave() const { - return is_slave; -} - PopManager::PopManager() : pop_types { "pop types" } {} bool PopManager::add_pop_type( diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp index f7f20fe..ff4ff5f 100644 --- a/src/openvic-simulation/pop/Pop.hpp +++ b/src/openvic-simulation/pop/Pop.hpp @@ -19,10 +19,13 @@ namespace OpenVic { using pop_size_t = int64_t; private: - PopType const& type; - Culture const& culture; - Religion const& religion; - pop_size_t size, num_promoted, num_demoted, num_migrated; + PopType const& PROPERTY(type); + Culture const& PROPERTY(culture); + Religion const& PROPERTY(religion); + pop_size_t PROPERTY(size); + pop_size_t PROPERTY(num_promoted); + pop_size_t PROPERTY(num_demoted); + pop_size_t PROPERTY(num_migrated); Pop(PopType const& new_type, Culture const& new_culture, Religion const& new_religion, pop_size_t new_size); @@ -32,13 +35,6 @@ namespace OpenVic { Pop& operator=(Pop const&) = delete; Pop& operator=(Pop&&) = delete; - PopType const& get_type() const; - Culture const& get_culture() const; - Religion const& get_religion() const; - pop_size_t get_size() const; - pop_size_t get_num_promoted() const; - pop_size_t get_num_demoted() const; - pop_size_t get_num_migrated() const; pop_size_t get_pop_daily_change() const; }; @@ -52,12 +48,18 @@ namespace OpenVic { using rebel_units_t = fixed_point_map_t<Unit const*>; private: - const enum class strata_t { POOR, MIDDLE, RICH } strata; - const sprite_t sprite; - const Good::good_map_t life_needs, everyday_needs, luxury_needs; - const rebel_units_t rebel_units; - const Pop::pop_size_t max_size, merge_max_size; - const bool state_capital_only, demote_migrant, is_artisan, is_slave; + const enum class strata_t { POOR, MIDDLE, RICH } PROPERTY(strata); + const sprite_t PROPERTY(sprite); + const Good::good_map_t PROPERTY(life_needs); + const Good::good_map_t PROPERTY(everyday_needs); + const Good::good_map_t PROPERTY(luxury_needs); + const rebel_units_t PROPERTY(rebel_units); + const Pop::pop_size_t PROPERTY(max_size); + const Pop::pop_size_t PROPERTY(merge_max_size); + const bool PROPERTY(state_capital_only); + const bool PROPERTY(demote_migrant); + const bool PROPERTY(is_artisan); + const bool PROPERTY(is_slave); // TODO - country and province migration targets, promote_to targets, ideologies and issues @@ -70,19 +72,6 @@ namespace OpenVic { public: PopType(PopType&&) = default; - - strata_t get_strata() const; - sprite_t get_sprite() const; - Good::good_map_t const& get_life_needs() const; - Good::good_map_t const& get_everyday_needs() const; - Good::good_map_t const& get_luxury_needs() const; - rebel_units_t const& get_rebel_units() const; - Pop::pop_size_t get_max_size() const; - Pop::pop_size_t get_merge_max_size() const; - bool get_state_capital_only() const; - bool get_demote_migrant() const; - bool get_is_artisan() const; - bool get_is_slave() const; }; struct Province; diff --git a/src/openvic-simulation/pop/Religion.cpp b/src/openvic-simulation/pop/Religion.cpp index f52ed3e..644618d 100644 --- a/src/openvic-simulation/pop/Religion.cpp +++ b/src/openvic-simulation/pop/Religion.cpp @@ -14,18 +14,6 @@ Religion::Religion( assert(icon > 0); } -ReligionGroup const& Religion::get_group() const { - return group; -} - -Religion::icon_t Religion::get_icon() const { - return icon; -} - -bool Religion::get_pagan() const { - return pagan; -} - ReligionManager::ReligionManager() : religion_groups { "religion groups" }, religions { "religions" } {} bool ReligionManager::add_religion_group(std::string_view identifier) { diff --git a/src/openvic-simulation/pop/Religion.hpp b/src/openvic-simulation/pop/Religion.hpp index 4cc8403..6f34eee 100644 --- a/src/openvic-simulation/pop/Religion.hpp +++ b/src/openvic-simulation/pop/Religion.hpp @@ -23,9 +23,9 @@ namespace OpenVic { using icon_t = uint8_t; private: - ReligionGroup const& group; - const icon_t icon; - const bool pagan; + ReligionGroup const& PROPERTY(group); + const icon_t PROPERTY(icon); + const bool PROPERTY(pagan); Religion( std::string_view new_identifier, colour_t new_colour, ReligionGroup const& new_group, icon_t new_icon, @@ -34,10 +34,6 @@ namespace OpenVic { public: Religion(Religion&&) = default; - - ReligionGroup const& get_group() const; - icon_t get_icon() const; - bool get_pagan() const; }; struct ReligionManager { diff --git a/src/openvic-simulation/testing/Requirement.cpp b/src/openvic-simulation/testing/Requirement.cpp index 99a29de..e7d03e5 100644 --- a/src/openvic-simulation/testing/Requirement.cpp +++ b/src/openvic-simulation/testing/Requirement.cpp @@ -2,49 +2,7 @@ using namespace OpenVic; -// Getters -std::string Requirement::get_id() { - return id; -} -std::string Requirement::get_text() { - return text; -} -std::string Requirement::get_acceptance_criteria() { - return acceptance_criteria; -} -bool Requirement::get_pass() { - return pass; -} -bool Requirement::get_tested() { - return tested; -} -std::string Requirement::get_target_value() { - return target_value; -} -std::string Requirement::get_actual_value() { - return actual_value; -} - -// Setters -void Requirement::set_id(std::string in_id) { - id = in_id; -} -void Requirement::set_text(std::string in_text) { - text = in_text; -} -void Requirement::set_acceptance_criteria(std::string in_acceptance_criteria) { - acceptance_criteria = in_acceptance_criteria; -} void Requirement::set_pass(bool in_pass) { pass = in_pass; set_tested(true); // Ever setting a pass condition implies it has been tested } -void Requirement::set_tested(bool in_tested) { - tested = in_tested; -} -void Requirement::set_target_value(std::string in_target_value) { - target_value = in_target_value; -} -void Requirement::set_actual_value(std::string in_actual_value) { - actual_value = in_actual_value; -} diff --git a/src/openvic-simulation/testing/Requirement.hpp b/src/openvic-simulation/testing/Requirement.hpp index 20dad3d..e91fa79 100644 --- a/src/openvic-simulation/testing/Requirement.hpp +++ b/src/openvic-simulation/testing/Requirement.hpp @@ -1,44 +1,31 @@ #pragma once #include <string> +#include "openvic-simulation/utility/Getters.hpp" namespace OpenVic { class Requirement { // Loaded during construction - std::string id; - std::string text; - std::string acceptance_criteria; - bool pass = false; // Explicitly false to begin - bool tested = false; + std::string PROPERTY_RW(id); + std::string PROPERTY_RW(text); + std::string PROPERTY_RW(acceptance_criteria); + bool PROPERTY(pass); + bool PROPERTY_RW(tested); // Initialised and used during script execution - std::string target_value; - std::string actual_value; + std::string PROPERTY_RW(target_value); + std::string PROPERTY_RW(actual_value); public: Requirement(std::string in_id, std::string in_text, std::string in_acceptance_criteria) { id = in_id; text = in_text; acceptance_criteria = in_acceptance_criteria; + pass = false; // Explicitly false to begin + tested = false; } - // Getters - std::string get_id(); - std::string get_text(); - std::string get_acceptance_criteria(); - bool get_pass(); - bool get_tested(); - std::string get_target_value(); - std::string get_actual_value(); - - // Setters - void set_id(std::string in_id); - void set_text(std::string in_text); - void set_acceptance_criteria(std::string in_acceptance_criteria); void set_pass(bool in_pass); - void set_tested(bool in_tested); - void set_target_value(std::string in_target_value); - void set_actual_value(std::string in_actual_value); }; } diff --git a/src/openvic-simulation/testing/TestScript.cpp b/src/openvic-simulation/testing/TestScript.cpp index a238fb5..ab0bfb9 100644 --- a/src/openvic-simulation/testing/TestScript.cpp +++ b/src/openvic-simulation/testing/TestScript.cpp @@ -44,12 +44,6 @@ std::vector<Requirement*> TestScript::get_untested_requirements() { } return untested_requirements; } -GameManager* TestScript::get_game_manager() { - return game_manager; -} -std::string TestScript::get_script_name() { - return script_name; -} // Setters void TestScript::set_requirements(std::vector<Requirement*> in_requirements) { @@ -58,12 +52,6 @@ void TestScript::set_requirements(std::vector<Requirement*> in_requirements) { void TestScript::add_requirement(Requirement* req) { requirements.push_back(req); } -void TestScript::set_game_manager(GameManager* in_game_manager) { - game_manager = in_game_manager; -} -void TestScript::set_script_name(std::string in_script_name) { - script_name = in_script_name; -} // Methods void TestScript::pass_or_fail_req_with_actual_and_target_values( diff --git a/src/openvic-simulation/testing/TestScript.hpp b/src/openvic-simulation/testing/TestScript.hpp index bfc2e95..b41246e 100644 --- a/src/openvic-simulation/testing/TestScript.hpp +++ b/src/openvic-simulation/testing/TestScript.hpp @@ -9,8 +9,8 @@ namespace OpenVic { class TestScript { std::vector<Requirement*> requirements = std::vector<Requirement*>(); - GameManager* game_manager; - std::string script_name; + GameManager* PROPERTY_RW(game_manager); + std::string PROPERTY_RW(script_name); public: // expects an overriden method that performs arbitrary code execution @@ -26,14 +26,10 @@ namespace OpenVic { std::vector<Requirement*> get_passed_requirements(); std::vector<Requirement*> get_failed_requirements(); std::vector<Requirement*> get_untested_requirements(); - GameManager* get_game_manager(); - std::string get_script_name(); // Setters void set_requirements(std::vector<Requirement*> in_requirements); void add_requirement(Requirement* req); - void set_game_manager(GameManager* in_game_manager); - void set_script_name(std::string in_script_name); // Methods void pass_or_fail_req_with_actual_and_target_values( diff --git a/src/openvic-simulation/utility/Getters.hpp b/src/openvic-simulation/utility/Getters.hpp index 566766f..99c895c 100644 --- a/src/openvic-simulation/utility/Getters.hpp +++ b/src/openvic-simulation/utility/Getters.hpp @@ -100,7 +100,7 @@ ACCESS: // TODO: Special logic to decide argument type and control assignment. #define PROPERTY_RW(NAME) PROPERTY_RW_ACCESS(NAME, private) -#define PROPERTY_RW_CUSTOM_NAME(NAME, GETTER_NAME, SETTER_NAME) +#define PROPERTY_RW_CUSTOM_NAME(NAME, GETTER_NAME, SETTER_NAME) PROPERTY_RW_FULL(NAME, GETTER_NAME, SETTER_NAME, private) #define PROPERTY_RW_ACCESS(NAME, ACCESS) PROPERTY_RW_FULL(NAME, get_##NAME, set_##NAME, ACCESS) #define PROPERTY_RW_FULL(NAME, GETTER_NAME, SETTER_NAME, ACCESS) \ PROPERTY_FULL(NAME, GETTER_NAME, ACCESS) \ |