1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00
vcmi/lib/mapObjectConstructors/ShrineInstanceConstructor.cpp
2023-06-20 19:37:27 +03:00

43 lines
1.1 KiB
C++

/*
* ShrineInstanceConstructor.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 "ShrineInstanceConstructor.h"
#include "../mapObjects/MiscObjects.h"
#include "../JsonRandom.h"
#include "../IGameCallback.h"
VCMI_LIB_NAMESPACE_BEGIN
void ShrineInstanceConstructor::initTypeData(const JsonNode & config)
{
parameters = config;
}
void ShrineInstanceConstructor::randomizeObject(CGShrine * shrine, CRandomGenerator & rng) const
{
auto visitTextParameter = parameters["visitText"];
if (visitTextParameter.isNumber())
shrine->visitText.appendLocalString(EMetaText::ADVOB_TXT, static_cast<ui32>(visitTextParameter.Float()));
else
shrine->visitText.appendRawString(visitTextParameter.String());
if(shrine->spell == SpellID::NONE) // shrine has no predefined spell
{
std::vector<SpellID> possibilities;
shrine->cb->getAllowedSpells(possibilities);
shrine->spell =JsonRandom::loadSpell(parameters["spell"], rng, possibilities);
}
}
VCMI_LIB_NAMESPACE_END