2023-04-30 13:31:20 +02:00
|
|
|
/*
|
2023-04-30 15:52:48 +02:00
|
|
|
* Updaters.h, part of VCMI engine
|
2023-04-30 13:31:20 +02:00
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2023-05-01 19:29:53 +02:00
|
|
|
#include "Bonus.h"
|
2024-05-07 21:17:05 +02:00
|
|
|
#include "../serializer/Serializeable.h"
|
2023-04-30 13:31:20 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
// observers for updating bonuses based on certain events (e.g. hero gaining level)
|
|
|
|
|
2024-05-07 21:17:05 +02:00
|
|
|
class DLL_LINKAGE IUpdater : public Serializeable
|
2023-04-30 13:31:20 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~IUpdater() = default;
|
|
|
|
|
|
|
|
virtual std::shared_ptr<Bonus> createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context) const;
|
|
|
|
virtual std::string toString() const;
|
|
|
|
virtual JsonNode toJsonNode() const;
|
|
|
|
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h)
|
2023-04-30 13:31:20 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE GrowsWithLevelUpdater : public IUpdater
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int valPer20 = 0;
|
|
|
|
int stepSize = 1;
|
|
|
|
|
|
|
|
GrowsWithLevelUpdater() = default;
|
|
|
|
GrowsWithLevelUpdater(int valPer20, int stepSize = 1);
|
|
|
|
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h)
|
2023-04-30 13:31:20 +02:00
|
|
|
{
|
|
|
|
h & static_cast<IUpdater &>(*this);
|
|
|
|
h & valPer20;
|
|
|
|
h & stepSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<Bonus> createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context) const override;
|
2024-02-13 16:21:30 +02:00
|
|
|
std::string toString() const override;
|
2024-02-10 21:22:08 +02:00
|
|
|
JsonNode toJsonNode() const override;
|
2023-04-30 13:31:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE TimesHeroLevelUpdater : public IUpdater
|
|
|
|
{
|
|
|
|
public:
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h)
|
2023-04-30 13:31:20 +02:00
|
|
|
{
|
|
|
|
h & static_cast<IUpdater &>(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<Bonus> createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context) const override;
|
2024-02-13 16:21:30 +02:00
|
|
|
std::string toString() const override;
|
2024-02-10 21:22:08 +02:00
|
|
|
JsonNode toJsonNode() const override;
|
2023-04-30 13:31:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE TimesStackLevelUpdater : public IUpdater
|
|
|
|
{
|
|
|
|
public:
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h)
|
2023-04-30 13:31:20 +02:00
|
|
|
{
|
|
|
|
h & static_cast<IUpdater &>(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<Bonus> createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context) const override;
|
2024-02-13 16:21:30 +02:00
|
|
|
std::string toString() const override;
|
2024-02-10 21:22:08 +02:00
|
|
|
JsonNode toJsonNode() const override;
|
2023-04-30 13:31:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE ArmyMovementUpdater : public IUpdater
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
si32 base;
|
|
|
|
si32 divider;
|
|
|
|
si32 multiplier;
|
|
|
|
si32 max;
|
|
|
|
ArmyMovementUpdater();
|
|
|
|
ArmyMovementUpdater(int base, int divider, int multiplier, int max);
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h)
|
2023-04-30 13:31:20 +02:00
|
|
|
{
|
|
|
|
h & static_cast<IUpdater &>(*this);
|
|
|
|
h & base;
|
|
|
|
h & divider;
|
|
|
|
h & multiplier;
|
|
|
|
h & max;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<Bonus> createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context) const override;
|
2024-02-13 16:21:30 +02:00
|
|
|
std::string toString() const override;
|
2024-02-10 21:22:08 +02:00
|
|
|
JsonNode toJsonNode() const override;
|
2023-04-30 13:31:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE OwnerUpdater : public IUpdater
|
|
|
|
{
|
|
|
|
public:
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler& h)
|
2023-04-30 13:31:20 +02:00
|
|
|
{
|
|
|
|
h & static_cast<IUpdater &>(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<Bonus> createUpdatedBonus(const std::shared_ptr<Bonus>& b, const CBonusSystemNode& context) const override;
|
2024-02-13 16:21:30 +02:00
|
|
|
std::string toString() const override;
|
2024-02-10 21:22:08 +02:00
|
|
|
JsonNode toJsonNode() const override;
|
2023-04-30 13:31:20 +02:00
|
|
|
};
|
|
|
|
|
2024-05-07 21:17:05 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|