Skip to content

Commit

Permalink
Fluctuate colony colors and default to vanilla colors if able. (#565)
Browse files Browse the repository at this point in the history
* Fluctuate colony colors and default to vanilla colors if able.

* fix test

* Add overlooked tests

* mrhrm.
  • Loading branch information
Zemurin authored Jul 24, 2024
1 parent aab5fac commit 2a4c0df
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -191,6 +192,7 @@ add_executable(
${TEST_SOURCES}
${TEST_SUB_SOURCES}
${TEST_SUB_SUB_SOURCES}
${TEST_SUB_SUB_SUB_SOURCES}
${GTEST_SOURCES}
)

Expand Down
19 changes: 15 additions & 4 deletions EU4ToVic3/Source/V3World/PoliticalManager/Country/Country.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <gmock/gmock-matchers.h>
using testing::UnorderedElementsAre;

namespace
{
EU4::EU4LocalizationLoader prepLoader()
{
std::stringstream input;
Expand All @@ -25,6 +27,7 @@ EU4::EU4LocalizationLoader prepLoader()

return locs;
}
} // namespace

TEST(EU4World_LocalizationLoaderTests, localizationsReturnsLocMapForKey)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <gmock/gmock-matchers.h>
using testing::UnorderedElementsAre;

namespace
{
V3::LocalizationLoader prepLoader()
{
std::stringstream input;
Expand All @@ -25,6 +27,7 @@ V3::LocalizationLoader prepLoader()

return locs;
}
} // namespace

TEST(V3World_LocalizationLoaderTests, localizationsReturnsLocMapForKey)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
Expand Down

0 comments on commit 2a4c0df

Please sign in to comment.