mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-29 23:07:48 +02:00
HAS_CHARGES_LIMITER
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "ArtifactUtils.h"
|
||||
#include "CArtifactFittingSet.h"
|
||||
|
||||
#include "../../bonuses/Limiters.h"
|
||||
#include "../../texts/CGeneralTextHandler.h"
|
||||
#include "../../GameLibrary.h"
|
||||
|
||||
@@ -292,6 +293,21 @@ bool CChargedArtifact::getRemoveOnDepletion() const
|
||||
return removeOnDepletion;
|
||||
}
|
||||
|
||||
std::optional<uint16_t> CChargedArtifact::getChargeCost(const SpellID & id) const
|
||||
{
|
||||
auto art = static_cast<const CArtifact*>(this);
|
||||
|
||||
for(const auto & bonus : art->instanceBonuses)
|
||||
{
|
||||
if(bonus->type == BonusType::SPELL && bonus->subtype.as<SpellID>() == id)
|
||||
{
|
||||
if(const auto chargesLimiter = std::static_pointer_cast<const HasChargesLimiter>(bonus->limiter))
|
||||
return chargesLimiter->chargeCost;
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
CArtifact::CArtifact()
|
||||
: CBonusSystemNode(BonusNodeType::ARTIFACT),
|
||||
iconIndex(ArtifactID::NONE),
|
||||
|
||||
Reference in New Issue
Block a user