aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/economy
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-11-22 17:16:34 +0100
committer zaaarf <zaaarf@proton.me>2023-11-22 17:16:34 +0100
commit1683859e333f98fb63f1c72d926bb366a3b89f0b (patch)
treee11dde918a7f1f228d3383ba8f9287385e43b4f5 /src/openvic-simulation/economy
parent5c6caf6fbb7c606f4ebe0c397cc15c97d776f13d (diff)
chore: use PROPERTY and its variants when possible
Diffstat (limited to 'src/openvic-simulation/economy')
-rw-r--r--src/openvic-simulation/economy/BuildingInstance.cpp6
-rw-r--r--src/openvic-simulation/economy/BuildingInstance.hpp4
-rw-r--r--src/openvic-simulation/economy/Good.cpp32
-rw-r--r--src/openvic-simulation/economy/Good.hpp23
-rw-r--r--src/openvic-simulation/economy/ProductionType.cpp70
-rw-r--r--src/openvic-simulation/economy/ProductionType.hpp54
6 files changed, 27 insertions, 162 deletions
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 {