mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-16 10:19:47 +02:00
8a5ac73438
Converted CGLighthouse class into FlaggableMapObject Bonus provided by Lighthouse/Flaggable is now defined in config and is accessible to mods.
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
/*
|
|
* 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"
|
|
|
|
#include "../json/JsonBonus.h"
|
|
#include "../texts/CGeneralTextHandler.h"
|
|
#include "../VCMI_Lib.h"
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
void FlaggableInstanceConstructor::initTypeData(const JsonNode & config)
|
|
{
|
|
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"]);
|
|
}
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
VCMI_LIB_NAMESPACE_END
|