1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-14 10:12:59 +02:00

Difficulty-cheats

Added the difficulty-dependent resource-cheats from the original game.
This commit is contained in:
Xilmi 2024-09-01 01:33:31 +02:00
parent 0c488145b9
commit df5d143822

View File

@ -234,6 +234,52 @@ ResourceSet NewTurnProcessor::generatePlayerIncome(PlayerColor playerID, bool ne
for (auto obj : state.getOwnedObjects())
incomeHandicapped += obj->asOwnable()->dailyIncome();
if (!state.isHuman())
{
// Initialize bonuses for different resources
std::array<int, GameResID::COUNT> weeklyBonuses = {};
// Calculate weekly bonuses based on difficulty
if (gameHandler->gameState()->getStartInfo()->difficulty == 0)
{
weeklyBonuses[EGameResID::GOLD] = static_cast<int>(std::round(incomeHandicapped[EGameResID::GOLD] * (0.75 - 1) * 7));
}
else if (gameHandler->gameState()->getStartInfo()->difficulty == 3)
{
weeklyBonuses[EGameResID::GOLD] = static_cast<int>(std::round(incomeHandicapped[EGameResID::GOLD] * 0.25 * 7));
weeklyBonuses[EGameResID::WOOD] = static_cast<int>(std::round(incomeHandicapped[EGameResID::WOOD] * 0.39 * 7));
weeklyBonuses[EGameResID::ORE] = static_cast<int>(std::round(incomeHandicapped[EGameResID::ORE] * 0.39 * 7));
weeklyBonuses[EGameResID::MERCURY] = static_cast<int>(std::round(incomeHandicapped[EGameResID::MERCURY] * 0.14 * 7));
weeklyBonuses[EGameResID::CRYSTAL] = static_cast<int>(std::round(incomeHandicapped[EGameResID::CRYSTAL] * 0.14 * 7));
weeklyBonuses[EGameResID::SULFUR] = static_cast<int>(std::round(incomeHandicapped[EGameResID::SULFUR] * 0.14 * 7));
weeklyBonuses[EGameResID::GEMS] = static_cast<int>(std::round(incomeHandicapped[EGameResID::GEMS] * 0.14 * 7));
}
else if (gameHandler->gameState()->getStartInfo()->difficulty == 4)
{
weeklyBonuses[EGameResID::GOLD] = static_cast<int>(std::round(incomeHandicapped[EGameResID::GOLD] * 0.5 * 7));
weeklyBonuses[EGameResID::WOOD] = static_cast<int>(std::round(incomeHandicapped[EGameResID::WOOD] * 0.53 * 7));
weeklyBonuses[EGameResID::ORE] = static_cast<int>(std::round(incomeHandicapped[EGameResID::ORE] * 0.53 * 7));
weeklyBonuses[EGameResID::MERCURY] = static_cast<int>(std::round(incomeHandicapped[EGameResID::MERCURY] * 0.28 * 7));
weeklyBonuses[EGameResID::CRYSTAL] = static_cast<int>(std::round(incomeHandicapped[EGameResID::CRYSTAL] * 0.28 * 7));
weeklyBonuses[EGameResID::SULFUR] = static_cast<int>(std::round(incomeHandicapped[EGameResID::SULFUR] * 0.28 * 7));
weeklyBonuses[EGameResID::GEMS] = static_cast<int>(std::round(incomeHandicapped[EGameResID::GEMS] * 0.28 * 7));
}
// Distribute weekly bonuses over 7 days, depending on the current day of the week
for (int i = 0; i < GameResID::COUNT; ++i)
{
int dailyBonus = weeklyBonuses[i] / 7;
int remainderBonus = weeklyBonuses[i] % 7;
// Apply the daily bonus for each day, and distribute the remainder accordingly
incomeHandicapped[static_cast<GameResID>(i)] += dailyBonus;
if (gameHandler->gameState()->getDate(Date::DAY_OF_WEEK) - 1 < remainderBonus)
{
incomeHandicapped[static_cast<GameResID>(i)] += 1;
}
}
}
return incomeHandicapped;
}