aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/openvic-simulation/country/CountryInstance.cpp17
-rw-r--r--src/openvic-simulation/country/CountryInstance.hpp10
-rw-r--r--src/openvic-simulation/types/Sliders.hpp44
3 files changed, 68 insertions, 3 deletions
diff --git a/src/openvic-simulation/country/CountryInstance.cpp b/src/openvic-simulation/country/CountryInstance.cpp
index 4ecb902..d3a0f2a 100644
--- a/src/openvic-simulation/country/CountryInstance.cpp
+++ b/src/openvic-simulation/country/CountryInstance.cpp
@@ -10,6 +10,8 @@
#include "openvic-simulation/politics/Ideology.hpp"
#include "openvic-simulation/research/Invention.hpp"
#include "openvic-simulation/research/Technology.hpp"
+#include "openvic-simulation/types/Sliders.hpp"
+#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
using namespace OpenVic;
@@ -56,6 +58,11 @@ CountryInstance::CountryInstance(
/* Budget */
cash_stockpile { 0 },
+ poor_tax_rate_slider {50},
+ middle_tax_rate_slider { 50},
+ rich_tax_rate_slider {50},
+
+ // TODO:
/* Technology */
technology_unlock_levels { &technology_keys },
@@ -280,6 +287,10 @@ bool CountryInstance::add_reform(Reform const& new_reform) {
}
}
+bool CountryInstance::set_value_for_slider(SliderManager& slider, int const* new_value) {
+
+}
+
template<UnitType::branch_t Branch>
bool CountryInstance::add_unit_instance_group(UnitInstanceGroup<Branch>& group) {
if (get_unit_instance_groups<Branch>().emplace(static_cast<UnitInstanceGroupBranched<Branch>*>(&group)).second) {
@@ -974,8 +985,8 @@ void CountryInstance::update_modifier_sum(Date today, StaticModifierCache const&
modifier_sum.add_modifier(static_modifier_cache.get_infamy(), country_source, infamy);
modifier_sum.add_modifier(static_modifier_cache.get_literacy(), country_source, national_literacy);
modifier_sum.add_modifier(static_modifier_cache.get_plurality(), country_source, plurality);
- // TODO - difficulty modifiers, war, peace, debt_default_to, bad_debter, generalised_debt_default,
- // total_occupation, total_blockaded, in_bankrupcy
+ // TODO - difficulty modifiers, war, peace, debt_default_to, bad_debtor, generalised_debt_default,
+ // total_occupation, total_blockaded, in_bankruptcy
// TODO - handle triggered modifiers
@@ -1198,7 +1209,7 @@ void CountryInstanceManager::update_rankings(Date today, DefineManager const& de
}
// Sort the great powers list by total rank, as pre-existing great powers may have changed rank order and new great
- // powers will have beeen added to the end of the list regardless of rank.
+ // powers will have been added to the end of the list regardless of rank.
std::sort(great_powers.begin(), great_powers.end(), [](CountryInstance const* a, CountryInstance const* b) -> bool {
return a->get_total_rank() < b->get_total_rank();
});
diff --git a/src/openvic-simulation/country/CountryInstance.hpp b/src/openvic-simulation/country/CountryInstance.hpp
index 6e01649..67a2981 100644
--- a/src/openvic-simulation/country/CountryInstance.hpp
+++ b/src/openvic-simulation/country/CountryInstance.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include <utility>
#include <vector>
#include <plf_colony.h>
@@ -12,8 +13,11 @@
#include "openvic-simulation/types/Date.hpp"
#include "openvic-simulation/types/IdentifierRegistry.hpp"
#include "openvic-simulation/types/IndexedMap.hpp"
+#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
+#include "openvic-simulation/types/Sliders.hpp"
#include "openvic-simulation/utility/Getters.hpp"
+
namespace OpenVic {
struct CountryInstanceManager;
struct CountryDefinition;
@@ -98,6 +102,10 @@ namespace OpenVic {
/* Budget */
fixed_point_t PROPERTY(cash_stockpile);
+ slider_value_t PROPERTY(poor_tax_rate_slider);
+ slider_value_t PROPERTY(middle_tax_rate_slider);
+ slider_value_t PROPERTY(rich_tax_rate_slider);
+
// TODO - cash stockpile change over last 30 days
/* Technology */
@@ -227,6 +235,8 @@ namespace OpenVic {
bool set_ruling_party(CountryParty const& new_ruling_party);
bool add_reform(Reform const& new_reform);
+ bool set_value_for_slider(SliderManager& slider_manager, int const* new_value);
+
template<UnitType::branch_t Branch>
bool add_unit_instance_group(UnitInstanceGroup<Branch>& group);
template<UnitType::branch_t Branch>
diff --git a/src/openvic-simulation/types/Sliders.hpp b/src/openvic-simulation/types/Sliders.hpp
new file mode 100644
index 0000000..50a01a3
--- /dev/null
+++ b/src/openvic-simulation/types/Sliders.hpp
@@ -0,0 +1,44 @@
+#pragma once
+
+#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
+#include "openvic-simulation/utility/Getters.hpp"
+
+namespace OpenVic {
+ // TODO: make struct for tariff slider, unlike other sliders, you can have negative values
+ struct slider_value_t {
+ friend struct SliderManager;
+ private:
+ int PROPERTY(min);
+ int PROPERTY(max);
+ int PROPERTY(value);
+
+ public:
+ constexpr slider_value_t(int value, int min = 0, int max = 100) {
+ // You *can* actually have min > max in Victoria 2
+ // Such a situation will result in only being able to be move between the max and min value.
+ // This logic replicates this "feature"
+ if (value > max) {
+ value = min;
+ }
+ if (value < min) {
+ value = max;
+ }
+ }
+ };
+
+class SliderManager {
+ public:
+ void set_slider_value(slider_value_t& slider, int new_value) {
+ if (new_value <= slider.max && new_value >= slider.min) {
+ slider.value = new_value;
+ }
+ else if (new_value > slider.max) {
+ slider.value = slider.min;
+ }
+ else {
+ slider.value = slider.max;
+ }
+ }
+ };
+}
+