1
0
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:
SoundSSGood
2025-05-20 16:29:14 +02:00
parent b6f1eac19b
commit 6752ab3a75
20 changed files with 136 additions and 78 deletions

View File

@@ -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),