2023-04-30 02:39:31 +02:00
|
|
|
/*
|
2023-04-30 15:13:07 +02:00
|
|
|
* Info.h, part of VCMI engine
|
2023-04-30 02:39:31 +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
|
|
|
|
|
2024-02-11 23:09:01 +02:00
|
|
|
#include "../json/JsonNode.h"
|
2023-06-02 20:47:37 +02:00
|
|
|
#include "../mapObjectConstructors/IObjectInfo.h"
|
2023-04-30 02:39:31 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2024-06-01 17:28:17 +02:00
|
|
|
namespace vstd
|
|
|
|
{
|
|
|
|
class RNG;
|
|
|
|
}
|
|
|
|
|
2023-10-20 23:44:57 +02:00
|
|
|
class MetaString;
|
2024-01-09 19:08:22 +02:00
|
|
|
class IGameCallback;
|
2023-04-30 02:39:31 +02:00
|
|
|
|
2023-04-30 15:13:07 +02:00
|
|
|
namespace Rewardable
|
|
|
|
{
|
|
|
|
struct Limiter;
|
|
|
|
using LimitersList = std::vector<std::shared_ptr<Rewardable::Limiter>>;
|
|
|
|
struct Reward;
|
|
|
|
struct Configuration;
|
2023-10-20 23:44:57 +02:00
|
|
|
struct Variables;
|
|
|
|
struct VisitInfo;
|
2023-04-30 15:13:07 +02:00
|
|
|
struct ResetInfo;
|
|
|
|
enum class EEventType;
|
|
|
|
|
|
|
|
class DLL_LINKAGE Info : public IObjectInfo
|
2023-04-30 02:39:31 +02:00
|
|
|
{
|
|
|
|
JsonNode parameters;
|
2023-07-19 21:25:52 +02:00
|
|
|
std::string objectTextID;
|
2023-04-30 02:39:31 +02:00
|
|
|
|
2023-10-20 23:44:57 +02:00
|
|
|
void replaceTextPlaceholders(MetaString & target, const Variables & variables) const;
|
|
|
|
void replaceTextPlaceholders(MetaString & target, const Variables & variables, const VisitInfo & info) const;
|
|
|
|
|
2024-06-01 17:28:17 +02:00
|
|
|
void configureVariables(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb, const JsonNode & source) const;
|
|
|
|
void configureRewards(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb, const JsonNode & source, Rewardable::EEventType mode, const std::string & textPrefix) const;
|
2023-04-30 02:39:31 +02:00
|
|
|
|
2024-06-01 17:28:17 +02:00
|
|
|
void configureLimiter(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb, Rewardable::Limiter & limiter, const JsonNode & source) const;
|
|
|
|
Rewardable::LimitersList configureSublimiters(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb, const JsonNode & source) const;
|
2023-04-30 02:39:31 +02:00
|
|
|
|
2024-06-01 17:28:17 +02:00
|
|
|
void configureReward(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb, Rewardable::Reward & info, const JsonNode & source) const;
|
|
|
|
void configureResetInfo(Rewardable::Configuration & object, vstd::RNG & rng, Rewardable::ResetInfo & info, const JsonNode & source) const;
|
2023-04-30 02:39:31 +02:00
|
|
|
public:
|
|
|
|
const JsonNode & getParameters() const;
|
|
|
|
|
|
|
|
bool givesResources() const override;
|
|
|
|
|
|
|
|
bool givesExperience() const override;
|
|
|
|
bool givesMana() const override;
|
|
|
|
bool givesMovement() const override;
|
|
|
|
|
|
|
|
bool givesPrimarySkills() const override;
|
|
|
|
bool givesSecondarySkills() const override;
|
|
|
|
|
|
|
|
bool givesArtifacts() const override;
|
|
|
|
bool givesCreatures() const override;
|
|
|
|
bool givesSpells() const override;
|
|
|
|
|
|
|
|
bool givesBonuses() const override;
|
|
|
|
|
2024-09-21 13:36:28 +02:00
|
|
|
bool hasGuards() const override;
|
|
|
|
|
2024-06-01 17:28:17 +02:00
|
|
|
void configureObject(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb) const;
|
2023-04-30 02:39:31 +02:00
|
|
|
|
2023-07-19 21:25:52 +02:00
|
|
|
void init(const JsonNode & objectConfig, const std::string & objectTextID);
|
2023-04-30 02:39:31 +02:00
|
|
|
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler &h)
|
2023-04-30 02:39:31 +02:00
|
|
|
{
|
|
|
|
h & parameters;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-04-30 15:13:07 +02:00
|
|
|
}
|
|
|
|
|
2023-04-30 02:39:31 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|