2024-10-25 18:48:10 +02:00
|
|
|
/*
|
|
|
|
* FlaggableInstanceConstructor.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "StdInc.h"
|
|
|
|
#include "FlaggableInstanceConstructor.h"
|
|
|
|
|
2024-11-03 16:47:13 +02:00
|
|
|
#include "../CConfigHandler.h"
|
|
|
|
#include "../VCMI_Lib.h"
|
2024-10-25 18:48:10 +02:00
|
|
|
#include "../json/JsonBonus.h"
|
2024-11-03 16:47:13 +02:00
|
|
|
#include "../json/JsonUtils.h"
|
2024-10-25 18:48:10 +02:00
|
|
|
#include "../texts/CGeneralTextHandler.h"
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
void FlaggableInstanceConstructor::initTypeData(const JsonNode & config)
|
|
|
|
{
|
2024-11-03 16:47:13 +02:00
|
|
|
if (settings["mods"]["validation"].String() != "off")
|
|
|
|
JsonUtils::validate(config, "vcmi:flaggable", getJsonKey());
|
|
|
|
|
2024-10-25 18:48:10 +02:00
|
|
|
for (const auto & bonusJson : config["bonuses"].Struct())
|
|
|
|
providedBonuses.push_back(JsonUtils::parseBonus(bonusJson.second));
|
|
|
|
|
|
|
|
if (!config["message"].isNull())
|
|
|
|
{
|
|
|
|
std::string message = config["message"].String();
|
|
|
|
if (!message.empty() && message.at(0) == '@')
|
|
|
|
{
|
|
|
|
visitMessageTextID = message.substr(1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
visitMessageTextID = TextIdentifier(getBaseTextID(), "onVisit").get();
|
|
|
|
VLC->generaltexth->registerString( config.getModScope(), visitMessageTextID, config["message"]);
|
|
|
|
}
|
|
|
|
}
|
2024-10-25 21:01:00 +02:00
|
|
|
|
|
|
|
dailyIncome = ResourceSet(config["dailyIncome"]);
|
2024-10-25 18:48:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FlaggableInstanceConstructor::initializeObject(FlaggableMapObject * flaggable) const
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string & FlaggableInstanceConstructor::getVisitMessageTextID() const
|
|
|
|
{
|
|
|
|
return visitMessageTextID;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::vector<std::shared_ptr<Bonus>> & FlaggableInstanceConstructor::getProvidedBonuses() const
|
|
|
|
{
|
|
|
|
return providedBonuses;
|
|
|
|
}
|
|
|
|
|
2024-10-25 21:01:00 +02:00
|
|
|
const ResourceSet & FlaggableInstanceConstructor::getDailyIncome() const
|
|
|
|
{
|
|
|
|
return dailyIncome;
|
|
|
|
}
|
|
|
|
|
2024-10-25 18:48:10 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|