1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

calculate income

This commit is contained in:
Laserlicht
2024-07-25 02:51:00 +02:00
parent 63b8ac1a58
commit bfd1e8a7c8
8 changed files with 33 additions and 19 deletions

View File

@@ -1618,7 +1618,7 @@ struct statsHLP
}
// get total gold income
static int getIncome(const PlayerState * ps)
static int getIncome(const PlayerState * ps, int percentIncome)
{
int totalIncome = 0;
const CGObjectInstance * heroOrTown = nullptr;
@@ -1626,7 +1626,7 @@ struct statsHLP
//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))));
totalIncome += h->valOfBonuses(Selector::typeSubtype(BonusType::GENERATE_RESOURCE, BonusSubtypeID(GameResID(GameResID::GOLD)))) * percentIncome / 100;
if(!heroOrTown)
heroOrTown = h;
@@ -1661,7 +1661,7 @@ struct statsHLP
assert(mine);
if (mine->producedResource == EGameResID::GOLD)
totalIncome += mine->producedQuantity;
totalIncome += mine->getProducedQuantity();
}
}
@@ -1751,7 +1751,7 @@ void CGameState::obtainPlayersStats(SThievesGuildInfo & tgi, int level)
}
if(level >= 5) //income
{
FILL_FIELD(income, statsHLP::getIncome(&g->second))
FILL_FIELD(income, statsHLP::getIncome(&g->second, scenarioOps->getIthPlayersSettings(g->second.color).handicap.percentIncome))
}
if(level >= 2) //best hero's stats
{