1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Rewardable objects may now define guards. Converted Crypt to rewardable.

This commit is contained in:
Ivan Savenko
2024-08-30 14:21:44 +00:00
parent a9c4683da6
commit 785036836c
12 changed files with 209 additions and 105 deletions

View File

@@ -62,17 +62,20 @@ Rewardable::Configuration CRewardableConstructor::generateConfiguration(IGameCal
void CRewardableConstructor::configureObject(CGObjectInstance * object, vstd::RNG & rng) const
{
if(auto * rewardableObject = dynamic_cast<CRewardableObject*>(object))
{
rewardableObject->configuration = generateConfiguration(object->cb, rng, object->ID);
auto * rewardableObject = dynamic_cast<CRewardableObject*>(object);
if (rewardableObject->configuration.info.empty())
{
if (objectInfo.getParameters()["rewards"].isNull())
logMod->error("Object %s has invalid configuration! No defined rewards found!", getJsonKey());
else
logMod->error("Object %s has invalid configuration! Make sure that defined appear chances are continuous!", getJsonKey());
}
if (!rewardableObject)
throw std::runtime_error("Object " + std::to_string(object->getObjGroupIndex()) + ", " + std::to_string(object->getObjTypeIndex()) + " is not a rewardable object!" );
rewardableObject->configuration = generateConfiguration(object->cb, rng, object->ID);
rewardableObject->initializeGuards();
if (rewardableObject->configuration.info.empty())
{
if (objectInfo.getParameters()["rewards"].isNull())
logMod->error("Object %s has invalid configuration! No defined rewards found!", getJsonKey());
else
logMod->error("Object %s has invalid configuration! Make sure that defined appear chances are continuous!", getJsonKey());
}
}