2023-06-06 17:34:04 +02:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2023-06-07 23:42:47 +02:00
|
|
|
void ShrineInstanceConstructor::randomizeObject(CGShrine * shrine, CRandomGenerator & rng) const
|
2023-06-06 17:34:04 +02:00
|
|
|
{
|
|
|
|
auto visitTextParameter = parameters["visitText"];
|
|
|
|
|
|
|
|
if (visitTextParameter.isNumber())
|
2023-06-18 11:18:25 +02:00
|
|
|
shrine->visitText.appendLocalString(EMetaText::ADVOB_TXT, static_cast<ui32>(visitTextParameter.Float()));
|
2023-06-06 17:34:04 +02:00
|
|
|
else
|
2023-06-18 11:18:25 +02:00
|
|
|
shrine->visitText.appendRawString(visitTextParameter.String());
|
2023-06-06 17:34:04 +02:00
|
|
|
|
|
|
|
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
|