From 2a4c0df108a3f601ccc766c86223194087b4bda6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivo=20Elezovi=C4=87?= Date: Wed, 24 Jul 2024 14:55:18 +0200 Subject: [PATCH] Fluctuate colony colors and default to vanilla colors if able. (#565) * Fluctuate colony colors and default to vanilla colors if able. * fix test * Add overlooked tests * mrhrm. --- CMakeLists.txt | 2 ++ .../PoliticalManager/Country/Country.cpp | 19 +++++++++++++++---- .../EU4LocalizationTests.cpp | 3 +++ .../LocalizationLoaderTests.cpp | 3 +++ .../CountryTests/CountryTests.cpp | 4 ++-- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 048df245c..2c5d74fa4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,6 +182,7 @@ add_custom_command(TARGET EU4ToVic3Converter POST_BUILD WORKING_DIRECTORY ${CONV file(GLOB TEST_SOURCES "EU4ToVic3Tests/*.cpp") file(GLOB TEST_SUB_SOURCES "EU4ToVic3Tests/*/*.cpp") file(GLOB TEST_SUB_SUB_SOURCES "EU4ToVic3Tests/*/*/*.cpp") +file(GLOB TEST_SUB_SUB_SUB_SOURCES "EU4ToVic3Tests/*/*/*/*.cpp") set(GTEST_SOURCES ${GTEST_SOURCES} "commonItems/external/googletest/googletest/src/gtest_main.cc") set(GTEST_SOURCES ${GTEST_SOURCES} "commonItems/external/googletest/googletest/src/gtest-all.cc") set(GTEST_SOURCES ${GTEST_SOURCES} "commonItems/external/googletest/googlemock/src/gmock-all.cc") @@ -191,6 +192,7 @@ add_executable( ${TEST_SOURCES} ${TEST_SUB_SOURCES} ${TEST_SUB_SUB_SOURCES} + ${TEST_SUB_SUB_SUB_SOURCES} ${GTEST_SOURCES} ) diff --git a/EU4ToVic3/Source/V3World/PoliticalManager/Country/Country.cpp b/EU4ToVic3/Source/V3World/PoliticalManager/Country/Country.cpp index e4fbaaea6..800b56eec 100644 --- a/EU4ToVic3/Source/V3World/PoliticalManager/Country/Country.cpp +++ b/EU4ToVic3/Source/V3World/PoliticalManager/Country/Country.cpp @@ -283,14 +283,25 @@ void V3::Country::convertFromEU4Country(const ClayManager& clayManager, const bool vn) { // color - using eu4 colors so people don't lose their shit over red venice and orange england. - if (sourceCountry->getNationalColors().getMapColor()) + // Strike that. Red Venice FTW. + + if (vanillaData && vanillaData->color) + { + processedData.color = vanillaData->color; + } + else if (sourceCountry->getNationalColors().getMapColor()) { processedData.color = sourceCountry->getNationalColors().getMapColor(); } - else + // If nothing... well... Game will assign something. + + // Maybe we're a colonial nation? In that case our colors will be within 1-2 of the overlord. We neeed to fluctuate. + if (!sourceCountry->getOverLord().empty() && sourceCountry->isColony()) { - if (vanillaData) - processedData.color = vanillaData->color; + if (processedData.color) + { + (*processedData.color).RandomlyFluctuate(30); + } } // eu4 locs diff --git a/EU4ToVic3Tests/EU4WorldTests/LoaderTests/LocalizationLoaderTests/EU4LocalizationTests.cpp b/EU4ToVic3Tests/EU4WorldTests/LoaderTests/LocalizationLoaderTests/EU4LocalizationTests.cpp index b9466c1aa..6ec570a0a 100644 --- a/EU4ToVic3Tests/EU4WorldTests/LoaderTests/LocalizationLoaderTests/EU4LocalizationTests.cpp +++ b/EU4ToVic3Tests/EU4WorldTests/LoaderTests/LocalizationLoaderTests/EU4LocalizationTests.cpp @@ -4,6 +4,8 @@ #include using testing::UnorderedElementsAre; +namespace +{ EU4::EU4LocalizationLoader prepLoader() { std::stringstream input; @@ -25,6 +27,7 @@ EU4::EU4LocalizationLoader prepLoader() return locs; } +} // namespace TEST(EU4World_LocalizationLoaderTests, localizationsReturnsLocMapForKey) { diff --git a/EU4ToVic3Tests/V3WorldTests/LoaderTests/LocLoaderTests/LocalizationLoaderTests.cpp b/EU4ToVic3Tests/V3WorldTests/LoaderTests/LocLoaderTests/LocalizationLoaderTests.cpp index 907243413..4201714a6 100644 --- a/EU4ToVic3Tests/V3WorldTests/LoaderTests/LocLoaderTests/LocalizationLoaderTests.cpp +++ b/EU4ToVic3Tests/V3WorldTests/LoaderTests/LocLoaderTests/LocalizationLoaderTests.cpp @@ -4,6 +4,8 @@ #include using testing::UnorderedElementsAre; +namespace +{ V3::LocalizationLoader prepLoader() { std::stringstream input; @@ -25,6 +27,7 @@ V3::LocalizationLoader prepLoader() return locs; } +} // namespace TEST(V3World_LocalizationLoaderTests, localizationsReturnsLocMapForKey) { diff --git a/EU4ToVic3Tests/V3WorldTests/PoliticalManagerTests/CountryTests/CountryTests.cpp b/EU4ToVic3Tests/V3WorldTests/PoliticalManagerTests/CountryTests/CountryTests.cpp index 380bf2917..679a85fea 100644 --- a/EU4ToVic3Tests/V3WorldTests/PoliticalManagerTests/CountryTests/CountryTests.cpp +++ b/EU4ToVic3Tests/V3WorldTests/PoliticalManagerTests/CountryTests/CountryTests.cpp @@ -92,7 +92,7 @@ TEST(V3World_CountryTests, CountryCanImportColorFromEU4) EXPECT_EQ(commonItems::Color(std::array{1, 2, 3}), country.getProcessedData().color); } -TEST(V3World_CountryTests, CountryWillOverrideVic3colorWithEU4Color) +TEST(V3World_CountryTests, CountryWillOverrideEU4ColorWithVic3Color) { const V3::ClayManager clayManager; @@ -111,7 +111,7 @@ TEST(V3World_CountryTests, CountryWillOverrideVic3colorWithEU4Color) country.convertFromEU4Country(clayManager, culMapper, {}, {}, {}, {}, {}, false); EXPECT_TRUE(country.getProcessedData().color); - EXPECT_EQ(commonItems::Color(std::array{1, 2, 3}), country.getProcessedData().color); + EXPECT_EQ(commonItems::Color(std::array{4, 5, 6}), country.getProcessedData().color); } TEST(V3World_CountryTests, CountryWillNotOverrideVic3colorWithEU4ColorIfNone)