From b569442814e3801053bb6e58312e2ed4eb0c5f9c Mon Sep 17 00:00:00 2001 From: Idhrendur Date: Fri, 10 May 2024 16:13:03 -0700 Subject: [PATCH 1/6] Store the source country number. --- src/hoi4_world/countries/hoi4_country.h | 5 +- .../countries/hoi4_country_converter.cpp | 7 ++- .../hoi4_country_converter_tests.cpp | 58 +++++++++++++++++++ 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/hoi4_world/countries/hoi4_country.h b/src/hoi4_world/countries/hoi4_country.h index 64a235f2..4892ba28 100644 --- a/src/hoi4_world/countries/hoi4_country.h +++ b/src/hoi4_world/countries/hoi4_country.h @@ -40,6 +40,7 @@ struct Unit struct CountryOptions { + int source_country_number; std::string tag; commonItems::Color color; std::optional capital_state; @@ -76,6 +77,7 @@ class Country { public: explicit Country(CountryOptions country_options): + source_country_number_(country_options.source_country_number), tag_(std::move(country_options.tag)), color_(country_options.color), capital_state_(country_options.capital_state), @@ -109,7 +111,7 @@ class Country { } - + [[nodiscard]] const int GetSourceCountryNumber() const { return source_country_number_; } [[nodiscard]] const std::string& GetTag() const { return tag_; } [[nodiscard]] const commonItems::Color& GetColor() const { return color_; } [[nodiscard]] const std::optional& GetCapitalState() const { return capital_state_; } @@ -149,6 +151,7 @@ class Country friend void PrintTo(const Country& country, std::ostream* os); private: + int source_country_number_; std::string tag_; commonItems::Color color_; std::optional capital_state_; diff --git a/src/hoi4_world/countries/hoi4_country_converter.cpp b/src/hoi4_world/countries/hoi4_country_converter.cpp index 8fbd2368..ae57a25e 100644 --- a/src/hoi4_world/countries/hoi4_country_converter.cpp +++ b/src/hoi4_world/countries/hoi4_country_converter.cpp @@ -943,7 +943,9 @@ std::optional hoi4::ConvertCountry(const vic3::World& source_worl ideology_support.at("neutrality")); } - return Country({.tag = *tag, + return Country({ + .source_country_number = source_country.GetNumber(), + .tag = *tag, .color = source_country.GetColor(), .capital_state = capital_state, .ideology = ideology, @@ -971,5 +973,6 @@ std::optional hoi4::ConvertCountry(const vic3::World& source_worl .units = units, .stability = ConvertStability(source_world, source_country), .convoys = numConvoys, - .task_forces = task_forces}); + .task_forces = task_forces, + }); } diff --git a/src/hoi4_world/countries/hoi4_country_converter_tests.cpp b/src/hoi4_world/countries/hoi4_country_converter_tests.cpp index 142540a0..18346937 100644 --- a/src/hoi4_world/countries/hoi4_country_converter_tests.cpp +++ b/src/hoi4_world/countries/hoi4_country_converter_tests.cpp @@ -12,6 +12,64 @@ namespace hoi4 { +TEST(Hoi4worldCountriesCountryConverter, SourceCountryNumberIsFromSourceCountry) +{ + const vic3::World source_world = vic3::World(vic3::WorldOptions()); + const mappers::CountryMapper country_mapper({{1, "T00"}, {2, "T01"}}); + const vic3::Country source_country_one({.number = 1, .color = commonItems::Color{std::array{1, 2, 3}}}); + const vic3::Country source_country_two({.number = 2, .color = commonItems::Color{std::array{2, 4, 6}}}); + std::map dummy_characters; + std::map dummy_culture_queues; + mappers::TemplateMap templates; + + const auto country_one = ConvertCountry(source_world, + source_country_one, + commonItems::LocalizationDatabase{{}, {}}, + country_mapper, + {}, + mappers::IdeologyMapper({}, {}), + mappers::UnitMapper(templates), + {}, + {}, + {}, + {}, + {}, + {}, + mappers::CultureGraphicsMapper{{}}, + mappers::LeaderTypeMapper({}), + mappers::CharacterTraitMapper({}, {}, {}, {}), + {0, {}}, + {}, + dummy_characters, + dummy_culture_queues); + const auto country_two = ConvertCountry(source_world, + source_country_two, + commonItems::LocalizationDatabase{{}, {}}, + country_mapper, + {}, + mappers::IdeologyMapper({}, {}), + mappers::UnitMapper(templates), + {}, + {}, + {}, + {}, + {}, + {}, + mappers::CultureGraphicsMapper{{}}, + mappers::LeaderTypeMapper({}), + mappers::CharacterTraitMapper({}, {}, {}, {}), + {0, {}}, + {}, + dummy_characters, + dummy_culture_queues); + + ASSERT_TRUE(country_one.has_value()); + EXPECT_EQ(country_one->GetSourceCountryNumber(), 1); + ASSERT_TRUE(country_two.has_value()); + EXPECT_EQ(country_two->GetSourceCountryNumber(), 2); +} + + TEST(Hoi4worldCountriesCountryConverter, TagIsFromSourceCountry) { const vic3::World source_world = vic3::World(vic3::WorldOptions()); From e3ed04db4f5da07463b13a7dc0eef9babc8e7476 Mon Sep 17 00:00:00 2001 From: Idhrendur Date: Fri, 10 May 2024 16:23:46 -0700 Subject: [PATCH 2/6] Carry primary cultures across --- src/hoi4_world/countries/hoi4_country.h | 4 +++ .../countries/hoi4_country_converter.cpp | 1 + .../hoi4_country_converter_tests.cpp | 35 +++++++++++++++++++ src/hoi4_world/roles/stories_creator.cpp | 8 +++++ 4 files changed, 48 insertions(+) diff --git a/src/hoi4_world/countries/hoi4_country.h b/src/hoi4_world/countries/hoi4_country.h index 4892ba28..03e3ee5c 100644 --- a/src/hoi4_world/countries/hoi4_country.h +++ b/src/hoi4_world/countries/hoi4_country.h @@ -44,6 +44,7 @@ struct CountryOptions std::string tag; commonItems::Color color; std::optional capital_state; + std::set primary_cultures; std::string ideology = "neutrality"; std::string sub_ideology = "despotism"; std::map ideology_support; @@ -81,6 +82,7 @@ class Country tag_(std::move(country_options.tag)), color_(country_options.color), capital_state_(country_options.capital_state), + primary_cultures_(std::move(country_options.primary_cultures)), ideology_(std::move(country_options.ideology)), sub_ideology_(std::move(country_options.sub_ideology)), ideology_support_(std::move(country_options.ideology_support)), @@ -115,6 +117,7 @@ class Country [[nodiscard]] const std::string& GetTag() const { return tag_; } [[nodiscard]] const commonItems::Color& GetColor() const { return color_; } [[nodiscard]] const std::optional& GetCapitalState() const { return capital_state_; } + [[nodiscard]] const std::set& GetPrimaryCultures() const { return primary_cultures_; } [[nodiscard]] int GetConvoys() const { return convoys_; } [[nodiscard]] const std::string& GetIdeology() const { return ideology_; } [[nodiscard]] const std::string& GetSubIdeology() const { return sub_ideology_; } @@ -155,6 +158,7 @@ class Country std::string tag_; commonItems::Color color_; std::optional capital_state_; + std::set primary_cultures_; std::string ideology_ = "neutrality"; std::string sub_ideology_ = "despotism"; std::map ideology_support_{{"neutrality", 100}}; diff --git a/src/hoi4_world/countries/hoi4_country_converter.cpp b/src/hoi4_world/countries/hoi4_country_converter.cpp index ae57a25e..a0f4c768 100644 --- a/src/hoi4_world/countries/hoi4_country_converter.cpp +++ b/src/hoi4_world/countries/hoi4_country_converter.cpp @@ -948,6 +948,7 @@ std::optional hoi4::ConvertCountry(const vic3::World& source_worl .tag = *tag, .color = source_country.GetColor(), .capital_state = capital_state, + .primary_cultures = source_country.GetPrimaryCultures(), .ideology = ideology, .sub_ideology = sub_ideology, .ideology_support = ideology_support, diff --git a/src/hoi4_world/countries/hoi4_country_converter_tests.cpp b/src/hoi4_world/countries/hoi4_country_converter_tests.cpp index 18346937..33017222 100644 --- a/src/hoi4_world/countries/hoi4_country_converter_tests.cpp +++ b/src/hoi4_world/countries/hoi4_country_converter_tests.cpp @@ -534,6 +534,41 @@ TEST(Hoi4worldCountriesCountryConverter, StatesNotOwnedByCountryCannotBecomeCapi } +TEST(Hoi4worldCountriesCountryConverter, PrimaryCulturesAreCopied) +{ + const vic3::World source_world = vic3::World(vic3::WorldOptions()); + const mappers::CountryMapper country_mapper({{1, "TAG"}}); + const vic3::Country source_country_one({.number = 1, .primary_cultures = {"culture_one", "culture_two"}}); + std::map dummy_characters; + std::map dummy_culture_queues; + mappers::TemplateMap templates; + + const auto country_one = ConvertCountry(source_world, + source_country_one, + commonItems::LocalizationDatabase{{}, {}}, + country_mapper, + {}, + mappers::IdeologyMapper({}, {}), + mappers::UnitMapper(templates), + {}, + {}, + {}, + {}, + {}, + {}, + mappers::CultureGraphicsMapper{{}}, + mappers::LeaderTypeMapper({}), + mappers::CharacterTraitMapper({}, {}, {}, {}), + {0, {}}, + {}, + dummy_characters, + dummy_culture_queues); + + ASSERT_TRUE(country_one.has_value()); + EXPECT_THAT(country_one->GetPrimaryCultures(), testing::UnorderedElementsAre("culture_one", "culture_two")); +} + + TEST(Hoi4worldCountriesCountryConverter, NonDemocraciesPickSentinelElectionYear) { const mappers::CountryMapper country_mapper({{1, "TAG"}, {2, "TWO"}}); diff --git a/src/hoi4_world/roles/stories_creator.cpp b/src/hoi4_world/roles/stories_creator.cpp index 7588f5c4..42c134ee 100644 --- a/src/hoi4_world/roles/stories_creator.cpp +++ b/src/hoi4_world/roles/stories_creator.cpp @@ -32,6 +32,14 @@ bool IsRoleValidForCountry(const hoi4::Role& role, const std::string& country_ta return country_tag == tag_match[1]; } + // scan for 'has_culture=culture' constructs + const std::regex culture_match_regex(R"([\s\S]*has_culture[\s\S]?=[\s\S]?(.+)[\s\S]*)"); + std::smatch culture_match; + if (std::regex_match(role.GetRequirements(), tag_match, tag_match_regex)) + { + return country_tag == tag_match[1]; + } + return false; } From 67f9b3a3933a02ce77df4fdd750e8917aca7447b Mon Sep 17 00:00:00 2001 From: Idhrendur Date: Fri, 10 May 2024 17:07:43 -0700 Subject: [PATCH 3/6] Add italy unification roles for italian-cultured countries. --- .../common/countries/converter_cosmetic.txt | 4 + .../converter_cosmetic_tags_l_braz_por.yml | 16 ++ .../converter_cosmetic_tags_l_english.yml | 16 ++ .../converter_cosmetic_tags_l_french.yml | 16 ++ .../converter_cosmetic_tags_l_german.yml | 16 ++ .../converter_cosmetic_tags_l_japanese.yml | 16 ++ .../converter_cosmetic_tags_l_polish.yml | 16 ++ .../converter_cosmetic_tags_l_russian.yml | 16 ++ ...converter_cosmetic_tags_l_simp_chinese.yml | 16 ++ .../converter_cosmetic_tags_l_spanish.yml | 16 ++ .../stories/italy_unification.txt | 259 +++++++++++++++++- src/hoi4_world/roles/stories_creator.cpp | 12 +- 12 files changed, 411 insertions(+), 8 deletions(-) create mode 100644 data/blank_mod/common/countries/converter_cosmetic.txt create mode 100644 data/blank_mod/localisation/braz_por/converter_cosmetic_tags_l_braz_por.yml create mode 100644 data/blank_mod/localisation/english/converter_cosmetic_tags_l_english.yml create mode 100644 data/blank_mod/localisation/french/converter_cosmetic_tags_l_french.yml create mode 100644 data/blank_mod/localisation/german/converter_cosmetic_tags_l_german.yml create mode 100644 data/blank_mod/localisation/japanese/converter_cosmetic_tags_l_japanese.yml create mode 100644 data/blank_mod/localisation/polish/converter_cosmetic_tags_l_polish.yml create mode 100644 data/blank_mod/localisation/russian/converter_cosmetic_tags_l_russian.yml create mode 100644 data/blank_mod/localisation/simp_chinese/converter_cosmetic_tags_l_simp_chinese.yml create mode 100644 data/blank_mod/localisation/spanish/converter_cosmetic_tags_l_spanish.yml diff --git a/data/blank_mod/common/countries/converter_cosmetic.txt b/data/blank_mod/common/countries/converter_cosmetic.txt new file mode 100644 index 00000000..66e733f2 --- /dev/null +++ b/data/blank_mod/common/countries/converter_cosmetic.txt @@ -0,0 +1,4 @@ +ITA_UNIFIED = { + color = rgb { 67 127 63 } + color_ui = rgb { 67 127 63 } +} \ No newline at end of file diff --git a/data/blank_mod/localisation/braz_por/converter_cosmetic_tags_l_braz_por.yml b/data/blank_mod/localisation/braz_por/converter_cosmetic_tags_l_braz_por.yml new file mode 100644 index 00000000..48713992 --- /dev/null +++ b/data/blank_mod/localisation/braz_por/converter_cosmetic_tags_l_braz_por.yml @@ -0,0 +1,16 @@ +l_braz_por: + ITA_UNIFIED_fascism: "Itália" + ITA_UNIFIED_fascism_DEF: "a Itália" + ITA_UNIFIED_democratic: "Itália Republicana" + ITA_UNIFIED_democratic_DEF: "a Itália Republicana" + ITA_UNIFIED_neutrality: "Reino da Itália" + ITA_UNIFIED_neutrality_DEF: "o Reino da Itália" + ITA_UNIFIED_communism: "República Popular da Itália" + ITA_UNIFIED_communism_DEF: "a República Popular da Itália" + ITA_UNIFIED_fascism_ADJ: "Italiano" + ITA_UNIFIED_democratic_ADJ: "Italiano" + ITA_UNIFIED_neutrality_ADJ: "Italiano" + ITA_UNIFIED_communism_ADJ: "Italiano" + ITA_UNIFIED: "Itália" + ITA_UNIFIED_DEF: "a Itália" + ITA_UNIFIED_ADJ: "Italiano(a)" \ No newline at end of file diff --git a/data/blank_mod/localisation/english/converter_cosmetic_tags_l_english.yml b/data/blank_mod/localisation/english/converter_cosmetic_tags_l_english.yml new file mode 100644 index 00000000..33b62b9e --- /dev/null +++ b/data/blank_mod/localisation/english/converter_cosmetic_tags_l_english.yml @@ -0,0 +1,16 @@ +l_english: + ITA_UNIFIED_fascism:0 "Italy" + ITA_UNIFIED_fascism_DEF:0 "Italy" + ITA_UNIFIED_democratic:0 "Republican Italy" + ITA_UNIFIED_democratic_DEF:0 "Republican Italy" + ITA_UNIFIED_neutrality:0 "Kingdom of Italy" + ITA_UNIFIED_neutrality_DEF:0 "the Kingdom of Italy" + ITA_UNIFIED_communism:0 "Italian Union" + ITA_UNIFIED_communism_DEF:0 "the Italian Union" + ITA_UNIFIED_fascism_ADJ:0 "Italian" + ITA_UNIFIED_democratic_ADJ:0 "Italian" + ITA_UNIFIED_neutrality_ADJ:0 "Italian" + ITA_UNIFIED_communism_ADJ:0 "Italian" + ITA_UNIFIED:0 "Italy" + ITA_UNIFIED_DEF:0 "Italy" + ITA_UNIFIED_ADJ:0 "Italian" \ No newline at end of file diff --git a/data/blank_mod/localisation/french/converter_cosmetic_tags_l_french.yml b/data/blank_mod/localisation/french/converter_cosmetic_tags_l_french.yml new file mode 100644 index 00000000..5a303a17 --- /dev/null +++ b/data/blank_mod/localisation/french/converter_cosmetic_tags_l_french.yml @@ -0,0 +1,16 @@ +l_french: + ITA_UNIFIED_fascism: "Italie" + ITA_UNIFIED_fascism_DEF: "l'Italie" + ITA_UNIFIED_democratic: "République italienne" + ITA_UNIFIED_democratic_DEF: "la République italienne" + ITA_UNIFIED_neutrality: "Royaume d'Italie" + ITA_UNIFIED_neutrality_DEF: "le Royaume d'Italie" + ITA_UNIFIED_communism: "Union italienne" + ITA_UNIFIED_communism_DEF: "l'Union italienne" + ITA_UNIFIED_fascism_ADJ: "italienne" + ITA_UNIFIED_democratic_ADJ: "italienne" + ITA_UNIFIED_neutrality_ADJ: "italienne" + ITA_UNIFIED_communism_ADJ: "italienne" + ITA_UNIFIED: "Italie" + ITA_UNIFIED_DEF: "l'Italie" + ITA_UNIFIED_ADJ: "italo-" \ No newline at end of file diff --git a/data/blank_mod/localisation/german/converter_cosmetic_tags_l_german.yml b/data/blank_mod/localisation/german/converter_cosmetic_tags_l_german.yml new file mode 100644 index 00000000..686b5ec3 --- /dev/null +++ b/data/blank_mod/localisation/german/converter_cosmetic_tags_l_german.yml @@ -0,0 +1,16 @@ +l_german: + ITA_UNIFIED_fascism: "Italien" + ITA_UNIFIED_fascism_DEF: "Italien" + ITA_UNIFIED_democratic: "Republikanisches Italien" + ITA_UNIFIED_democratic_DEF: "das republikanische Italien" + ITA_UNIFIED_neutrality: "Königreich Italien" + ITA_UNIFIED_neutrality_DEF: "das Königreich Italien" + ITA_UNIFIED_communism: "Volksrepublik Italien" + ITA_UNIFIED_communism_DEF: "die Volksrepublik Italien" + ITA_UNIFIED_fascism_ADJ: "Italienisch" + ITA_UNIFIED_democratic_ADJ: "Italienisch" + ITA_UNIFIED_neutrality_ADJ: "Italienisch" + ITA_UNIFIED_communism_ADJ: "Italienisch" + ITA_UNIFIED: "Italien" + ITA_UNIFIED_DEF: "Italien" + ITA_UNIFIED_ADJ: "Italienisch" \ No newline at end of file diff --git a/data/blank_mod/localisation/japanese/converter_cosmetic_tags_l_japanese.yml b/data/blank_mod/localisation/japanese/converter_cosmetic_tags_l_japanese.yml new file mode 100644 index 00000000..b0f16280 --- /dev/null +++ b/data/blank_mod/localisation/japanese/converter_cosmetic_tags_l_japanese.yml @@ -0,0 +1,16 @@ +l_japanese: + ITA_UNIFIED_fascism: "イタリア" + ITA_UNIFIED_fascism_DEF: "イタリア" + ITA_UNIFIED_democratic: "共和制イタリア" + ITA_UNIFIED_democratic_DEF: "共和制イタリア" + ITA_UNIFIED_neutrality: "イタリア王国" + ITA_UNIFIED_neutrality_DEF: "イタリア王国" + ITA_UNIFIED_communism: "イタリア連邦" + ITA_UNIFIED_communism_DEF: "イタリア連邦" + ITA_UNIFIED_fascism_ADJ: "イタリア" + ITA_UNIFIED_democratic_ADJ: "イタリア" + ITA_UNIFIED_neutrality_ADJ: "イタリア" + ITA_UNIFIED_communism_ADJ: "イタリア" + ITA_UNIFIED: "イタリア" + ITA_UNIFIED_DEF: "イタリア" + ITA_UNIFIED_ADJ: "イタリア" \ No newline at end of file diff --git a/data/blank_mod/localisation/polish/converter_cosmetic_tags_l_polish.yml b/data/blank_mod/localisation/polish/converter_cosmetic_tags_l_polish.yml new file mode 100644 index 00000000..a30de0b6 --- /dev/null +++ b/data/blank_mod/localisation/polish/converter_cosmetic_tags_l_polish.yml @@ -0,0 +1,16 @@ +l_polish: + ITA_UNIFIED_fascism: "Państwo Włoskie" + ITA_UNIFIED_fascism_DEF: "Włochy" + ITA_UNIFIED_democratic: "Republika Włoska" + ITA_UNIFIED_democratic_DEF: "Republika Włoska" + ITA_UNIFIED_neutrality: "Królestwo Włoch" + ITA_UNIFIED_neutrality_DEF: "Królestwo Włoch" + ITA_UNIFIED_communism: "Włoska Republika Ludowa" + ITA_UNIFIED_communism_DEF: "Włoska Republika Ludowa" + ITA_UNIFIED_fascism_ADJ: "włos." + ITA_UNIFIED_democratic_ADJ: "włos." + ITA_UNIFIED_neutrality_ADJ: "włos." + ITA_UNIFIED_communism_ADJ: "włos." + ITA_UNIFIED: "Włochy" + ITA_UNIFIED_DEF: "Włochy" + ITA_UNIFIED_ADJ: "włos." \ No newline at end of file diff --git a/data/blank_mod/localisation/russian/converter_cosmetic_tags_l_russian.yml b/data/blank_mod/localisation/russian/converter_cosmetic_tags_l_russian.yml new file mode 100644 index 00000000..f253c00d --- /dev/null +++ b/data/blank_mod/localisation/russian/converter_cosmetic_tags_l_russian.yml @@ -0,0 +1,16 @@ +l_russian: + ITA_UNIFIED_fascism: "Италия" + ITA_UNIFIED_fascism_DEF: "Италия" + ITA_UNIFIED_democratic: "Республиканская Италия" + ITA_UNIFIED_democratic_DEF: "Республиканская Италия" + ITA_UNIFIED_neutrality: "Королевство Италия" + ITA_UNIFIED_neutrality_DEF: "Королевство Италия" + ITA_UNIFIED_communism: "Итальянский Союз" + ITA_UNIFIED_communism_DEF: "Итальянский Союз" + ITA_UNIFIED_fascism_ADJ: "Итальянск" + ITA_UNIFIED_democratic_ADJ: "Итальянск" + ITA_UNIFIED_neutrality_ADJ: "Итальянск" + ITA_UNIFIED_communism_ADJ: "Итальянск" + ITA_UNIFIED: "Италия" + ITA_UNIFIED_DEF: "Италия" + ITA_UNIFIED_ADJ: "Итальянск" \ No newline at end of file diff --git a/data/blank_mod/localisation/simp_chinese/converter_cosmetic_tags_l_simp_chinese.yml b/data/blank_mod/localisation/simp_chinese/converter_cosmetic_tags_l_simp_chinese.yml new file mode 100644 index 00000000..f822f862 --- /dev/null +++ b/data/blank_mod/localisation/simp_chinese/converter_cosmetic_tags_l_simp_chinese.yml @@ -0,0 +1,16 @@ +l_simp_chinese: + ITA_UNIFIED_fascism: "意大利" + ITA_UNIFIED_fascism_DEF: "意大利" + ITA_UNIFIED_democratic: "意大利共和国" + ITA_UNIFIED_democratic_DEF: "意大利共和国" + ITA_UNIFIED_neutrality: "意大利王国" + ITA_UNIFIED_neutrality_DEF: "意大利王国" + ITA_UNIFIED_communism: "意大利联盟" + ITA_UNIFIED_communism_DEF: "意大利联盟" + ITA_UNIFIED_fascism_ADJ: "意大利" + ITA_UNIFIED_democratic_ADJ: "意大利" + ITA_UNIFIED_neutrality_ADJ: "意大利" + ITA_UNIFIED_communism_ADJ: "意大利" + ITA_UNIFIED: "意大利" + ITA_UNIFIED_DEF: "意大利" + ITA_UNIFIED_ADJ: "意大利" \ No newline at end of file diff --git a/data/blank_mod/localisation/spanish/converter_cosmetic_tags_l_spanish.yml b/data/blank_mod/localisation/spanish/converter_cosmetic_tags_l_spanish.yml new file mode 100644 index 00000000..6d70a00c --- /dev/null +++ b/data/blank_mod/localisation/spanish/converter_cosmetic_tags_l_spanish.yml @@ -0,0 +1,16 @@ +l_spanish: + ITA_UNIFIED_fascism: "Italia" + ITA_UNIFIED_fascism_DEF: "Italia" + ITA_UNIFIED_democratic: "República de Italia" + ITA_UNIFIED_democratic_DEF: "La República de Italia" + ITA_UNIFIED_neutrality: "Reino de Italia" + ITA_UNIFIED_neutrality_DEF: "El Reino de Italia" + ITA_UNIFIED_communism: "República Popular Italiana" + ITA_UNIFIED_communism_DEF: "La República Popular Italiana" + ITA_UNIFIED_fascism_ADJ: "de Italia" + ITA_UNIFIED_democratic_ADJ: "de la República de Italia" + ITA_UNIFIED_neutrality_ADJ: "del Reino de Italia" + ITA_UNIFIED_communism_ADJ: "de la República Popular Italiana" + ITA_UNIFIED: "Italia" + ITA_UNIFIED_DEF: "Italia" + ITA_UNIFIED_ADJ: "de Italia" \ No newline at end of file diff --git a/data/configurables/stories/italy_unification.txt b/data/configurables/stories/italy_unification.txt index afe48386..19a1bf80 100644 --- a/data/configurables/stories/italy_unification.txt +++ b/data/configurables/stories/italy_unification.txt @@ -1,5 +1,4 @@ unification_italy = { - category=unification requirements={ @@ -9,7 +8,7 @@ unification_italy = { } } - score=100 + score=102 block_category=unification @@ -111,3 +110,259 @@ unification_italy = { } } + + +unification_italy_2 = { + category=unification + + requirements={ + OR = { + has_culture = north_italian + } + } + + score=101 + + block_category=unification + + + focus={ + id = $TAG$_italia_irredenta #start of tree for an italian unifier + icon = GFX_goal_generic_construction + x = $X_POSITION$ + y = 0 + cost = 10 + ai_will_do = { + factor = 5 + } + + + completion_reward = { + add_political_power = 50 + add_war_support = 0.1 + } + } + + repeat_focus={ #creates wargoal and ai strategy vs another country that owns a core or claim of ITA + requirement={ + any_other_country = { + any_owned_state = { + OR = { + is_core_of = ITA + is_claimed_by = ITA + } + } + } + } + focus={ + id = $TAG$_invade_$TARGET_TAG$ + icon = GFX_goal_generic_more_territorial_claims + relative_position_id = $TAG$_italia_irredenta + x = -1 + y = 1 + cost = 10 + prerequisite = { focus = $TAG$_italia_irredenta } + + available = { + $TARGET_TAG$ = { + can_ROOT_get_wargoal_on_THIS = yes + } + } + + ai_will_do = { + factor = 1 + modifier = { #don't try it if we're getting our ass kicked + factor = 0 + surrender_progress > 0.01 + } + modifier = { #don't try it if we can't reach them + factor = 0 + $TARGET_TAG$ = { + NOT = { + OR = { + is_neighbor_of = $TAG$ + $TARGET_TAG$ = { + any_owned_state = { + is_coastal = yes + } + } + } + + } + } + } + } + + bypass = { + has_war_with = $TARGET_TAG$ + } + + will_lead_to_war_with = $TARGET_TAG$ + + select_effect = { #should make AI prepare to invade + add_ai_strategy = { + type = prepare_for_war + id = $TARGET_TAG$ + value = 100 + } + } + + completion_reward = { #wargoal would be more appropriate as take_claimed_state or such, maybe + create_wargoal = { + type = annex_everything + target = $TARGET_TAG$ + } + add_ai_strategy = { + type = conquer + id = $TARGET_TAG$ + value = 200 + } + } + + } + } + + focus={ + id = $TAG$_proclaim_unity + icon = GFX_goal_generic_construction + x = $X_POSITION$ + y = 0 + cost = 10 + prerequisite = { repeat_focus = $TAG$_invade_$TARGET_TAG$ } + ai_will_do = { + factor = 5 + } + + completion_reward = { + set_cosmetic_tag = ITA_UNIFIED + } + } +} + + +unification_italy_3 = { + category=unification + + requirements={ + OR = { + has_culture = south_italian + } + } + + score=100 + + block_category=unification + + + focus={ + id = $TAG$_italia_irredenta #start of tree for an italian unifier + icon = GFX_goal_generic_construction + x = $X_POSITION$ + y = 0 + cost = 10 + ai_will_do = { + factor = 5 + } + + + completion_reward = { + add_political_power = 50 + add_war_support = 0.1 + } + } + + repeat_focus={ #creates wargoal and ai strategy vs another country that owns a core or claim of ITA + requirement={ + any_other_country = { + any_owned_state = { + OR = { + is_core_of = ITA + is_claimed_by = ITA + } + } + } + } + focus={ + id = $TAG$_invade_$TARGET_TAG$ + icon = GFX_goal_generic_more_territorial_claims + relative_position_id = $TAG$_italia_irredenta + x = -1 + y = 1 + cost = 10 + prerequisite = { focus = $TAG$_italia_irredenta } + + available = { + $TARGET_TAG$ = { + can_ROOT_get_wargoal_on_THIS = yes + } + } + + ai_will_do = { + factor = 1 + modifier = { #don't try it if we're getting our ass kicked + factor = 0 + surrender_progress > 0.01 + } + modifier = { #don't try it if we can't reach them + factor = 0 + $TARGET_TAG$ = { + NOT = { + OR = { + is_neighbor_of = $TAG$ + $TARGET_TAG$ = { + any_owned_state = { + is_coastal = yes + } + } + } + + } + } + } + } + + bypass = { + has_war_with = $TARGET_TAG$ + } + + will_lead_to_war_with = $TARGET_TAG$ + + select_effect = { #should make AI prepare to invade + add_ai_strategy = { + type = prepare_for_war + id = $TARGET_TAG$ + value = 100 + } + } + + completion_reward = { #wargoal would be more appropriate as take_claimed_state or such, maybe + create_wargoal = { + type = annex_everything + target = $TARGET_TAG$ + } + add_ai_strategy = { + type = conquer + id = $TARGET_TAG$ + value = 200 + } + } + + } + } + + focus={ + id = $TAG$_proclaim_unity + icon = GFX_goal_generic_construction + x = $X_POSITION$ + y = 0 + cost = 10 + prerequisite = { repeat_focus = $TAG$_invade_$TARGET_TAG$ } + ai_will_do = { + factor = 5 + } + + completion_reward = { + set_cosmetic_tag = ITA_UNIFIED + } + } +} \ No newline at end of file diff --git a/src/hoi4_world/roles/stories_creator.cpp b/src/hoi4_world/roles/stories_creator.cpp index 42c134ee..8f7f3288 100644 --- a/src/hoi4_world/roles/stories_creator.cpp +++ b/src/hoi4_world/roles/stories_creator.cpp @@ -14,7 +14,7 @@ using Tag = std::string; using CombinationName = std::string; -bool IsRoleValidForCountry(const hoi4::Role& role, const std::string& country_tag) +bool IsRoleValidForCountry(const hoi4::Role& role, const std::string_view country_tag, const hoi4::Country& country) { // scan for 'always=yes' constructs const std::regex always_match_regex(R"([\s\S]*always[\s\S]?=[\s\S]?yes[\s\S]*)"); @@ -29,15 +29,15 @@ bool IsRoleValidForCountry(const hoi4::Role& role, const std::string& country_ta std::smatch tag_match; if (std::regex_match(role.GetRequirements(), tag_match, tag_match_regex)) { - return country_tag == tag_match[1]; + return tag_match[1] == std::string(country_tag); } // scan for 'has_culture=culture' constructs const std::regex culture_match_regex(R"([\s\S]*has_culture[\s\S]?=[\s\S]?(.+)[\s\S]*)"); std::smatch culture_match; - if (std::regex_match(role.GetRequirements(), tag_match, tag_match_regex)) + if (std::regex_match(role.GetRequirements(), culture_match, culture_match_regex)) { - return country_tag == tag_match[1]; + return country.GetPrimaryCultures().contains(tag_match[1]); } return false; @@ -51,9 +51,9 @@ std::vector> MakeCombinations(const std::map Date: Fri, 10 May 2024 17:34:13 -0700 Subject: [PATCH 4/6] Fix tests --- .../hoi4_countries_converter_tests.cpp | 4 +++ src/hoi4_world/countries/hoi4_country.cpp | 35 ++++++++++--------- src/hoi4_world/countries/hoi4_country.h | 3 +- .../world/hoi4_world_converter_tests.cpp | 2 ++ 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/hoi4_world/countries/hoi4_countries_converter_tests.cpp b/src/hoi4_world/countries/hoi4_countries_converter_tests.cpp index 3a94789a..13b9767f 100644 --- a/src/hoi4_world/countries/hoi4_countries_converter_tests.cpp +++ b/src/hoi4_world/countries/hoi4_countries_converter_tests.cpp @@ -181,9 +181,11 @@ TEST(Hoi4worldCountriesCountriesConverter, CountriesAreConverted) EXPECT_THAT(countries, testing::ElementsAre(testing::Pair("TAG", Country(CountryOptions{ + .source_country_number = 1, .tag = "TAG", .color = commonItems::Color{std::array{1, 2, 3}}, .capital_state = 10, + .primary_cultures = {"culture_0"}, .ideology = "neutrality", .ideology_support = {{"neutrality", 100}}, .technologies = expected_techs_one, @@ -201,9 +203,11 @@ TEST(Hoi4worldCountriesCountriesConverter, CountriesAreConverted) })), testing::Pair("TWO", Country(CountryOptions{ + .source_country_number = 2, .tag = "TWO", .color = commonItems::Color{std::array{2, 4, 6}}, .capital_state = 20, + .primary_cultures = {"culture_1"}, .ideology = "democratic", .ideology_support = {{"neutrality", 100}}, .technologies = expected_techs_two, diff --git a/src/hoi4_world/countries/hoi4_country.cpp b/src/hoi4_world/countries/hoi4_country.cpp index 370ffcab..8969f088 100644 --- a/src/hoi4_world/countries/hoi4_country.cpp +++ b/src/hoi4_world/countries/hoi4_country.cpp @@ -28,22 +28,25 @@ void Country::RemovePuppets(const std::set& puppet_tags) void PrintTo(const Country& country, std::ostream* os) { - *os << "\nTag = " << country.tag_ << "\n" - << "Capital = " << country.capital_state_.value_or(-1) << "\n" - << "Ideology = " << country.ideology_ << " (" << country.sub_ideology_ << ")\n" - << "Elections = " << country.last_election_ << " (" << country.has_elections_ << ")\n" - << "Economy = " << country.economy_law_ << "\n" - << "Trade = " << country.trade_law_ << "\n" - << "Military = " << country.military_law_ << "\n" - << "Monarch idea = " << country.monarch_idea_id_.value_or(-1) << "\n" - << "Overlord = " << country.overlord_.value_or("none") << "\n" - << "Research slots = " << country.starting_research_slots_ << "\n" - << "Stability = " << country.stability_ << "\n" - << "Convoys = " << country.convoys_ << "\n" - << "Units = " << country.units_.size() << "\n" - << "Task forces = " << country.task_forces_.size() << "\n" - << fmt::format("Ideas = {{ {} }}\n", fmt::join(country.ideas_, " ")) - << fmt::format("Puppets = {{ {} }}\n", fmt::join(country.puppets_, " ")) + *os << "\n" + << "Source Country Number = " << country.source_country_number_ << "\n" + << "Tag = " << country.tag_ << "\n" + << "Capital = " << country.capital_state_.value_or(-1) << "\n" + << fmt::format("Primary Cultures = {{ {} }}\n", fmt::join(country.primary_cultures_, " ")) + << "Ideology = " << country.ideology_ << " (" << country.sub_ideology_ << ")\n" + << "Elections = " << country.last_election_ << " (" << country.has_elections_ << ")\n" + << "Economy = " << country.economy_law_ << "\n" + << "Trade = " << country.trade_law_ << "\n" + << "Military = " << country.military_law_ << "\n" + << "Monarch idea = " << country.monarch_idea_id_.value_or(-1) << "\n" + << "Overlord = " << country.overlord_.value_or("none") << "\n" + << "Research slots = " << country.starting_research_slots_ << "\n" + << "Stability = " << country.stability_ << "\n" + << "Convoys = " << country.convoys_ << "\n" + << "Units = " << country.units_.size() << "\n" + << "Task forces = " << country.task_forces_.size() << "\n" + << fmt::format("Ideas = {{ {} }}\n", fmt::join(country.ideas_, " ")) + << fmt::format("Puppets = {{ {} }}\n", fmt::join(country.puppets_, " ")) << "NB: Techs, equipment variants, color, graphics block, name list, and wars not printed.\n" << "If you are testing one of these, add them to the debug printer in hoi4_country.cpp.\n"; } diff --git a/src/hoi4_world/countries/hoi4_country.h b/src/hoi4_world/countries/hoi4_country.h index 03e3ee5c..b45a6961 100644 --- a/src/hoi4_world/countries/hoi4_country.h +++ b/src/hoi4_world/countries/hoi4_country.h @@ -113,7 +113,7 @@ class Country { } - [[nodiscard]] const int GetSourceCountryNumber() const { return source_country_number_; } + [[nodiscard]] int GetSourceCountryNumber() const { return source_country_number_; } [[nodiscard]] const std::string& GetTag() const { return tag_; } [[nodiscard]] const commonItems::Color& GetColor() const { return color_; } [[nodiscard]] const std::optional& GetCapitalState() const { return capital_state_; } @@ -154,6 +154,7 @@ class Country friend void PrintTo(const Country& country, std::ostream* os); private: + // if making changes here also update PrintTo() int source_country_number_; std::string tag_; commonItems::Color color_; diff --git a/src/hoi4_world/world/hoi4_world_converter_tests.cpp b/src/hoi4_world/world/hoi4_world_converter_tests.cpp index c9dcec48..944f5b8b 100644 --- a/src/hoi4_world/world/hoi4_world_converter_tests.cpp +++ b/src/hoi4_world/world/hoi4_world_converter_tests.cpp @@ -126,6 +126,7 @@ TEST(Hoi4worldWorldHoi4worldconverter, CountriesAreConverted) EXPECT_THAT(world.GetCountries(), testing::ElementsAre(testing::Pair("TAG", Country(CountryOptions{ + .source_country_number = 1, .tag = "TAG", .color = commonItems::Color{std::array{1, 2, 3}}, .ideology_support = {{"neutrality", 100}}, @@ -139,6 +140,7 @@ TEST(Hoi4worldWorldHoi4worldconverter, CountriesAreConverted) })), testing::Pair("TWO", Country(CountryOptions{ + .source_country_number = 3, .tag = "TWO", .color = commonItems::Color{std::array{2, 4, 6}}, .ideology_support = {{"neutrality", 100}}, From 4309ab0dd5df9c0ae71e61b0424631a6da0cf315 Mon Sep 17 00:00:00 2001 From: Idhrendur Date: Fri, 10 May 2024 17:57:15 -0700 Subject: [PATCH 5/6] Simplify role definition --- data/configurables/stories/italy_unification.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/data/configurables/stories/italy_unification.txt b/data/configurables/stories/italy_unification.txt index 19a1bf80..63963ebd 100644 --- a/data/configurables/stories/italy_unification.txt +++ b/data/configurables/stories/italy_unification.txt @@ -4,7 +4,6 @@ unification_italy = { requirements={ OR = { tag=ITA - #has_idea = culture_all_italian #not sure if this would work with how the culture ideas in the converter are set up? } } From d9c848bc149850ead6ea1739e7f30506a7e8c999 Mon Sep 17 00:00:00 2001 From: Idhrendur Date: Fri, 10 May 2024 17:57:27 -0700 Subject: [PATCH 6/6] Fix culture match. --- src/hoi4_world/roles/stories_creator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hoi4_world/roles/stories_creator.cpp b/src/hoi4_world/roles/stories_creator.cpp index 8f7f3288..d2fe17e0 100644 --- a/src/hoi4_world/roles/stories_creator.cpp +++ b/src/hoi4_world/roles/stories_creator.cpp @@ -37,7 +37,7 @@ bool IsRoleValidForCountry(const hoi4::Role& role, const std::string_view countr std::smatch culture_match; if (std::regex_match(role.GetRequirements(), culture_match, culture_match_regex)) { - return country.GetPrimaryCultures().contains(tag_match[1]); + return country.GetPrimaryCultures().contains(culture_match[1]); } return false;