1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

CGrowingArtifactInstance

This commit is contained in:
SoundSSGood 2023-06-22 00:17:59 +03:00
parent f8023ad283
commit 58fc2efd41
3 changed files with 10 additions and 30 deletions

View File

@ -269,30 +269,6 @@ void CArtifact::serializeJson(JsonSerializeFormat & handler)
}
void CGrowingArtifact::levelUpArtifact (CArtifactInstance * art)
{
auto b = std::make_shared<Bonus>();
b->type = BonusType::LEVEL_COUNTER;
b->val = 1;
b->duration = BonusDuration::COMMANDER_KILLED;
art->accumulateBonus(b);
for(const auto & bonus : bonusesPerLevel)
{
if (art->valOfBonuses(BonusType::LEVEL_COUNTER) % bonus.first == 0) //every n levels
{
art->accumulateBonus(std::make_shared<Bonus>(bonus.second));
}
}
for(const auto & bonus : thresholdBonuses)
{
if (art->valOfBonuses(BonusType::LEVEL_COUNTER) == bonus.first) //every n levels
{
art->addNewBonus(std::make_shared<Bonus>(bonus.second));
}
}
}
CArtHandler::~CArtHandler() = default;
std::vector<JsonNode> CArtHandler::loadLegacyData()

View File

@ -89,8 +89,6 @@ public:
std::string nodeName() const override;
void addNewBonus(const std::shared_ptr<Bonus>& b) override;
virtual void levelUpArtifact (CArtifactInstance * art){};
virtual bool canBeDisassembled() const;
virtual bool canBePutAt(const CArtifactSet * artSet, ArtifactPosition slot = ArtifactPosition::FIRST_AVAILABLE,
bool assumeDestRemoved = false) const;
@ -127,8 +125,6 @@ public:
std::vector <std::pair <ui16, Bonus> > bonusesPerLevel; //bonus given each n levels
std::vector <std::pair <ui16, Bonus> > thresholdBonuses; //after certain level they will be added once
void levelUpArtifact(CArtifactInstance * art) override;
template <typename Handler> void serialize(Handler &h, const int version)
{
h & static_cast<CArtifact&>(*this);
@ -166,8 +162,16 @@ public:
SpellID getScrollSpellID() const;
};
class DLL_LINKAGE CGrowingArtifactInstance
{
protected:
CGrowingArtifactInstance() = default;
public:
void growingUp();
};
class DLL_LINKAGE CArtifactInstance
: public CBonusSystemNode, public CCombinedArtifactInstance, public CScrollArtifactInstance
: public CBonusSystemNode, public CCombinedArtifactInstance, public CScrollArtifactInstance, public CGrowingArtifactInstance
{
protected:
void init();

View File

@ -2223,7 +2223,7 @@ void BattleResultAccepted::applyGs(CGameState * gs) const
{
for (auto art : h->commander->artifactsWorn) //increment bonuses for commander artifacts
{
art.second.artifact->artType->levelUpArtifact (art.second.artifact);
art.second.artifact->growingUp();
}
}
}