1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +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

@ -23,6 +23,7 @@
#include "../gameState/CGameState.h"
#include "../mapping/CMap.h"
#include "../CPlayerState.h"
#include "../StartInfo.h"
#include "../serializer/JsonSerializeFormat.h"
#include "../mapObjectConstructors/AObjectTypeHandler.h"
#include "../mapObjectConstructors/CObjectClassesHandler.h"
@ -103,7 +104,7 @@ void CGMine::newTurn(vstd::RNG & rand) const
if (tempOwner == PlayerColor::NEUTRAL)
return;
cb->giveResource(tempOwner, producedResource, producedQuantity);
cb->giveResource(tempOwner, producedResource, getProducedQuantity());
}
void CGMine::initObj(vstd::RNG & rand)
@ -177,7 +178,7 @@ void CGMine::flagMine(const PlayerColor & player) const
iw.type = EInfoWindowMode::AUTO;
iw.text.appendTextID(TextIdentifier("core.mineevnt", producedResource.getNum()).get()); //not use subID, abandoned mines uses default mine texts
iw.player = player;
iw.components.emplace_back(ComponentType::RESOURCE_PER_DAY, producedResource, producedQuantity);
iw.components.emplace_back(ComponentType::RESOURCE_PER_DAY, producedResource, getProducedQuantity());
cb->showInfoDialog(&iw);
}
@ -195,6 +196,12 @@ ui32 CGMine::defaultResProduction() const
}
}
ui32 CGMine::getProducedQuantity() const
{
auto * playerSettings = cb->getPlayerSettings(getOwner());
return producedQuantity * playerSettings->handicap.percentIncome / 100;
}
void CGMine::battleFinished(const CGHeroInstance *hero, const BattleResult &result) const
{
if(result.winner == 0) //attacker won