1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Unified income handling, added IOwnableObject interface

This commit is contained in:
Ivan Savenko
2024-08-24 20:42:19 +00:00
parent 189cb1c762
commit 0fd9dbf240
20 changed files with 116 additions and 47 deletions

View File

@@ -255,20 +255,18 @@ si64 Statistic::getTotalExperience(const PlayerState * ps)
// get total gold income
int Statistic::getIncome(const CGameState * gs, const PlayerState * ps)
{
int percentIncome = gs->getStartInfo()->getIthPlayersSettings(ps->color).handicap.percentIncome;
int totalIncome = 0;
//Heroes can produce gold as well - skill, specialty or arts
for(const auto & h : ps->heroes)
totalIncome += h->valOfBonuses(Selector::typeSubtype(BonusType::GENERATE_RESOURCE, BonusSubtypeID(GameResID(GameResID::GOLD)))) * percentIncome / 100;
totalIncome += h->dailyIncome()[EGameResID::GOLD];
//Add town income of all towns
for(const auto & t : ps->towns)
totalIncome += t->dailyIncome()[EGameResID::GOLD];
for(const CGMine * mine : getMines(gs, ps))
if(mine->producedResource == EGameResID::GOLD)
totalIncome += mine->getProducedQuantity();
totalIncome += mine->dailyIncome()[EGameResID::GOLD];
return totalIncome;
}