Skip to content

Commit

Permalink
Filter monuments (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zemurin authored Nov 13, 2024
1 parent d6ac70d commit 8c47c08
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion EU4ToVic3/Source/V3World/ClayManager/State/SubState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ bool V3::SubState::isBuildingValid(const Building& building,
return false;
}
// Economy builder will ignore all monuments, canals, and power block statues.
if (building.isUnique() || building.isStatue())
if (building.isUnique() || building.isStatue() || building.isMonumental())
{
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions EU4ToVic3/Source/V3World/EconomyManager/Building/Building.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ void V3::Building::registerKeys(const std::map<std::string, int>& costTiers)
if (const auto costTier = commonItems::getString(theStream); costTiers.contains(costTier))
{
constructionCost = costTiers.at(costTier);
if (costTier == "construction_cost_monument")
{
monumental = true;
}
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions EU4ToVic3/Source/V3World/EconomyManager/Building/Building.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Building: commonItems::parser
[[nodiscard]] const auto& isCappedByGov() const { return governmentCapped; }
[[nodiscard]] const auto& isUnique() const { return unique; }
[[nodiscard]] const auto& isStatue() const { return statue; }
[[nodiscard]] const auto& isMonumental() const { return monumental; }

[[nodiscard]] const auto& getLevel() const { return level; }
[[nodiscard]] const auto& getShareholders() const { return shareholders; }
Expand All @@ -46,6 +47,7 @@ class Building: commonItems::parser
bool governmentCapped = false; // barracks, ports, other caps done at the building not building group level by techs/laws/traits.
bool unique = false; // Monument or Canal.
bool statue = false; // Power Block
bool monumental = false; // Misc monumental stuff eg. skyscrapers

// Specific to instance of building in SubState e.g. The port in New York
std::set<std::string> PMs; // Only Production Methods that are different from default
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
construction_cost_medium = 300
construction_cost_low = 150
construction_cost_very_low = 50
construction_cost_monument = 2500

max_autoexpand_queue_weeks = 26
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,19 @@ TEST(V3World_BuildingTests, UnkownConstructionCostIsCaught)
EXPECT_EQ(50, building.getConstructionCost());

std::cout.rdbuf(cout_buffer);
}
}

TEST(V3World_BuildingTests, MonumentsAreRecognized)
{
V3::BuildingScriptValuesLoader buildingScriptValuesLoader;
buildingScriptValuesLoader.loadBuildingScriptValues(modFS);
const auto& costTiers = buildingScriptValuesLoader.getBuildingCostConstants();

std::stringstream input;
input << "\trequired_construction = construction_cost_monument\n";

V3::Building building;
building.loadBuilding(input, costTiers);

EXPECT_TRUE(building.isMonumental());
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ TEST(V3World_BuildingScriptValuesLoaderTests, CostTiersCanBeLoaded)
EXPECT_TRUE(buildingScriptValuesLoader.getBuildingCostConstants().empty());
buildingScriptValuesLoader.loadBuildingScriptValues(modFS);
const auto costTiers = buildingScriptValuesLoader.getBuildingCostConstants();
EXPECT_EQ(3, costTiers.size());
EXPECT_EQ(4, costTiers.size());

EXPECT_THAT(costTiers,
testing::UnorderedElementsAre(std::pair("construction_cost_very_low", 50),
std::pair("construction_cost_low", 150),
std::pair("construction_cost_medium", 300)));
std::pair("construction_cost_medium", 300),
std::pair("construction_cost_monument", 2500)));
}

0 comments on commit 8c47c08

Please sign in to comment.