mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
calculate income
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user