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 000000000..66e733f24 --- /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 000000000..48713992b --- /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 000000000..33b62b9e4 --- /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 000000000..5a303a177 --- /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 000000000..686b5ec3c --- /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 000000000..b0f16280a --- /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 000000000..a30de0b68 --- /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 000000000..f253c00d8 --- /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 000000000..f822f8629 --- /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 000000000..6d70a00c7 --- /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 afe483866..63963ebd3 100644 --- a/data/configurables/stories/italy_unification.txt +++ b/data/configurables/stories/italy_unification.txt @@ -1,15 +1,13 @@ unification_italy = { - category=unification 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? } } - score=100 + score=102 block_category=unification @@ -111,3 +109,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/countries/hoi4_countries_converter_tests.cpp b/src/hoi4_world/countries/hoi4_countries_converter_tests.cpp index 3a94789af..13b9767f0 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 370ffcab2..8969f0884 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 64a235f28..b45a69613 100644 --- a/src/hoi4_world/countries/hoi4_country.h +++ b/src/hoi4_world/countries/hoi4_country.h @@ -40,9 +40,11 @@ struct Unit struct CountryOptions { + int source_country_number; 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; @@ -76,9 +78,11 @@ 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), + 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)), @@ -109,10 +113,11 @@ class Country { } - + [[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_; } + [[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_; } @@ -149,9 +154,12 @@ 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_; 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 8fbd2368a..a0f4c7682 100644 --- a/src/hoi4_world/countries/hoi4_country_converter.cpp +++ b/src/hoi4_world/countries/hoi4_country_converter.cpp @@ -943,9 +943,12 @@ 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, + .primary_cultures = source_country.GetPrimaryCultures(), .ideology = ideology, .sub_ideology = sub_ideology, .ideology_support = ideology_support, @@ -971,5 +974,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 142540a0e..330172223 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()); @@ -476,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 7588f5c43..d2fe17e0a 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,7 +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(), culture_match, culture_match_regex)) + { + return country.GetPrimaryCultures().contains(culture_match[1]); } return false; @@ -43,9 +51,9 @@ std::vector> MakeCombinations(const std::map