aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/country/CountryInstance.hpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-09-10 00:04:30 +0200
committer GitHub <noreply@github.com>2024-09-10 00:04:30 +0200
commit7a9206e3869fbb659d296b854c90f5c81755a5ca (patch)
tree1e00781e634cbb7ea6f31343f6751f7755bd53ef /src/openvic-simulation/country/CountryInstance.hpp
parent79dbf71dd23623059ea9eabd87956f93604be1ed (diff)
parentd67cd2d08fe2859809e35b93f5a8358c48a3705e (diff)
Merge pull request #195 from OpenVicProject/ranking
Ranking System
Diffstat (limited to 'src/openvic-simulation/country/CountryInstance.hpp')
-rw-r--r--src/openvic-simulation/country/CountryInstance.hpp103
1 files changed, 88 insertions, 15 deletions
diff --git a/src/openvic-simulation/country/CountryInstance.hpp b/src/openvic-simulation/country/CountryInstance.hpp
index f4baf2d..c43f0cd 100644
--- a/src/openvic-simulation/country/CountryInstance.hpp
+++ b/src/openvic-simulation/country/CountryInstance.hpp
@@ -13,6 +13,7 @@
#include "openvic-simulation/utility/Getters.hpp"
namespace OpenVic {
+ struct CountryInstanceManager;
struct CountryDefinition;
struct ProvinceInstance;
struct State;
@@ -28,12 +29,30 @@ namespace OpenVic {
struct Religion;
struct CountryHistoryEntry;
struct MapInstance;
+ struct DefineManager;
/* Representation of a country's mutable attributes, with a CountryDefinition that is unique at any single time
* but can be swapped with other CountryInstance's CountryDefinition when switching tags. */
struct CountryInstance {
friend struct CountryInstanceManager;
+ /*
+ Westernisation Progress vs Status for Uncivilised Countries:
+ 15 - primitive
+ 16 - uncivilised
+ 50 - uncivilised
+ 51 - partially westernised
+ */
+
+ enum struct country_status_t : uint8_t {
+ COUNTRY_STATUS_GREAT_POWER,
+ COUNTRY_STATUS_SECONDARY_POWER,
+ COUNTRY_STATUS_CIVILISED,
+ COUNTRY_STATUS_PARTIALLY_CIVILISED,
+ COUNTRY_STATUS_UNCIVILISED,
+ COUNTRY_STATUS_PRIMITIVE
+ };
+
private:
/* Main attributes */
// We can always assume country_definition is not null, as it is initialised from a reference and only ever changed
@@ -42,16 +61,24 @@ namespace OpenVic {
colour_t PROPERTY(colour); // Cached to avoid searching government overrides for every province
ProvinceInstance const* PROPERTY(capital);
string_set_t PROPERTY(country_flags);
-
- bool PROPERTY(civilised);
bool PROPERTY_CUSTOM_PREFIX(releasable_vassal, is);
+ country_status_t PROPERTY(country_status);
+ Date PROPERTY(lose_great_power_date);
+ fixed_point_t PROPERTY(total_score);
+ size_t PROPERTY(total_rank);
+
ordered_set<ProvinceInstance*> PROPERTY(owned_provinces);
ordered_set<ProvinceInstance*> PROPERTY(controlled_provinces);
ordered_set<ProvinceInstance*> PROPERTY(core_provinces);
ordered_set<State*> PROPERTY(states);
/* Production */
+ fixed_point_t PROPERTY(industrial_power);
+ std::vector<std::pair<State const*, fixed_point_t>> PROPERTY(industrial_power_from_states);
+ std::vector<std::pair<CountryInstance const*, fixed_point_t>> PROPERTY(industrial_power_from_investments);
+ size_t PROPERTY(industrial_rank);
+ fixed_point_map_t<CountryInstance const*> PROPERTY(foreign_investments);
// TODO - total amount of each good produced
/* Budget */
@@ -102,31 +129,41 @@ namespace OpenVic {
// TODO - total amount of each good exported and imported
/* Diplomacy */
- size_t PROPERTY(total_rank);
fixed_point_t PROPERTY(prestige);
size_t PROPERTY(prestige_rank);
- fixed_point_t PROPERTY(industrial_power);
- size_t PROPERTY(industrial_rank);
- fixed_point_t PROPERTY(military_power);
- size_t PROPERTY(military_rank);
fixed_point_t PROPERTY(diplomatic_points);
// TODO - colonial power, current wars
/* Military */
+ fixed_point_t PROPERTY(military_power);
+ fixed_point_t PROPERTY(military_power_from_land);
+ fixed_point_t PROPERTY(military_power_from_sea);
+ fixed_point_t PROPERTY(military_power_from_leaders);
+ size_t PROPERTY(military_rank);
plf::colony<General> PROPERTY(generals);
plf::colony<Admiral> PROPERTY(admirals);
ordered_set<ArmyInstance*> PROPERTY(armies);
ordered_set<NavyInstance*> PROPERTY(navies);
size_t PROPERTY(regiment_count);
- size_t PROPERTY(mobilisation_regiment_potential);
+ size_t PROPERTY(max_supported_regiment_count);
+ size_t PROPERTY(mobilisation_potential_regiment_count);
+ size_t PROPERTY(mobilisation_max_regiment_count);
+ fixed_point_t PROPERTY(mobilisation_impact);
+ fixed_point_t PROPERTY(supply_consumption);
size_t PROPERTY(ship_count);
fixed_point_t PROPERTY(total_consumed_ship_supply);
fixed_point_t PROPERTY(max_ship_supply);
fixed_point_t PROPERTY(leadership_points);
fixed_point_t PROPERTY(war_exhaustion);
+ bool PROPERTY_CUSTOM_PREFIX(mobilised, is);
+ bool PROPERTY_CUSTOM_PREFIX(disarmed, is);
+ IndexedMap<RegimentType, bool> PROPERTY(unlocked_regiment_types);
+ RegimentType::allowed_cultures_t PROPERTY(allowed_regiment_cultures);
+ IndexedMap<ShipType, bool> PROPERTY(unlocked_ship_types);
UNIT_BRANCHED_GETTER(get_unit_instance_groups, armies, navies);
UNIT_BRANCHED_GETTER(get_leaders, generals, admirals);
+ UNIT_BRANCHED_GETTER(get_unlocked_unit_types, unlocked_regiment_types, unlocked_ship_types);
CountryInstance(
CountryDefinition const* new_country_definition,
@@ -134,12 +171,20 @@ namespace OpenVic {
decltype(inventions)::keys_t const& invention_keys,
decltype(upper_house)::keys_t const& ideology_keys,
decltype(government_flag_overrides)::keys_t const& government_type_keys,
- decltype(pop_type_distribution)::keys_t const& pop_type_keys
+ decltype(pop_type_distribution)::keys_t const& pop_type_keys,
+ decltype(unlocked_regiment_types)::keys_t const& unlocked_regiment_types_keys,
+ decltype(unlocked_ship_types)::keys_t const& unlocked_ship_types_keys
);
public:
std::string_view get_identifier() const;
+ bool exists() const;
+ bool is_civilised() const;
+ bool can_colonise() const;
+ bool is_great_power() const;
+ bool is_secondary_power() const;
+
bool set_country_flag(std::string_view flag, bool warn);
bool clear_country_flag(std::string_view flag, bool warn);
bool add_owned_province(ProvinceInstance& new_province);
@@ -168,21 +213,37 @@ namespace OpenVic {
template<UnitType::branch_t Branch>
bool remove_leader(LeaderBranched<Branch> const* leader);
- bool apply_history_to_country(CountryHistoryEntry const* entry, MapInstance& map_instance);
+ template<UnitType::branch_t Branch>
+ void unlock_unit_type(UnitTypeBranched<Branch> const& unit_type);
+
+ bool is_primary_culture(Culture const& culture) const;
+ // This only checks the accepted cultures list, ignoring the primary culture.
+ bool is_accepted_culture(Culture const& culture) const;
+ bool is_primary_or_accepted_culture(Culture const& culture) const;
+
+ // Sets the investment of each country in the map (rather than adding to them), leaving the rest unchanged.
+ void apply_foreign_investments(
+ fixed_point_map_t<CountryDefinition const*> const& investments,
+ CountryInstanceManager const& country_instance_manager
+ );
+
+ bool apply_history_to_country(
+ CountryHistoryEntry const& entry, MapInstance& map_instance, CountryInstanceManager const& country_instance_manager
+ );
private:
- void _update_production();
+ void _update_production(DefineManager const& define_manager);
void _update_budget();
void _update_technology();
void _update_politics();
void _update_population();
void _update_trade();
void _update_diplomacy();
- void _update_military();
+ void _update_military(DefineManager const& define_manager, UnitTypeManager const& unit_type_manager);
public:
- void update_gamestate();
+ void update_gamestate(DefineManager const& define_manager, UnitTypeManager const& unit_type_manager);
void tick();
};
@@ -194,6 +255,16 @@ namespace OpenVic {
private:
IdentifierRegistry<CountryInstance> IDENTIFIER_REGISTRY(country_instance);
+ std::vector<CountryInstance*> PROPERTY(great_powers);
+ std::vector<CountryInstance*> PROPERTY(secondary_powers);
+
+ std::vector<CountryInstance*> PROPERTY(total_ranking);
+ std::vector<CountryInstance*> PROPERTY(prestige_ranking);
+ std::vector<CountryInstance*> PROPERTY(industrial_power_ranking);
+ std::vector<CountryInstance*> PROPERTY(military_power_ranking);
+
+ void update_rankings(Date today, DefineManager const& define_manager);
+
public:
CountryInstance& get_country_instance_from_definition(CountryDefinition const& country);
CountryInstance const& get_country_instance_from_definition(CountryDefinition const& country) const;
@@ -204,7 +275,9 @@ namespace OpenVic {
decltype(CountryInstance::inventions)::keys_t const& invention_keys,
decltype(CountryInstance::upper_house)::keys_t const& ideology_keys,
decltype(CountryInstance::government_flag_overrides)::keys_t const& government_type_keys,
- decltype(CountryInstance::pop_type_distribution)::keys_t const& pop_type_keys
+ decltype(CountryInstance::pop_type_distribution)::keys_t const& pop_type_keys,
+ decltype(CountryInstance::unlocked_regiment_types)::keys_t const& unlocked_regiment_types_keys,
+ decltype(CountryInstance::unlocked_ship_types)::keys_t const& unlocked_ship_types_keys
);
bool apply_history_to_countries(
@@ -212,7 +285,7 @@ namespace OpenVic {
MapInstance& map_instance
);
- void update_gamestate();
+ void update_gamestate(Date today, DefineManager const& define_manager, UnitTypeManager const& unit_type_manager);
void tick();
};
}