mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-08 00:39:47 +02:00
- Handle new configurable banks
- Handle "all" object banned option
This commit is contained in:
parent
54e47c20b0
commit
ec603f46ae
@ -49,7 +49,10 @@ public:
|
|||||||
|
|
||||||
virtual bool givesBonuses() const { return false; }
|
virtual bool givesBonuses() const { return false; }
|
||||||
|
|
||||||
|
virtual bool hasGuards() const { return false; }
|
||||||
|
|
||||||
virtual ~IObjectInfo() = default;
|
virtual ~IObjectInfo() = default;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
VCMI_LIB_NAMESPACE_END
|
||||||
|
@ -525,6 +525,11 @@ bool Rewardable::Info::givesBonuses() const
|
|||||||
return testForKey(parameters, "bonuses");
|
return testForKey(parameters, "bonuses");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Rewardable::Info::hasGuards() const
|
||||||
|
{
|
||||||
|
return testForKey(parameters, "guards");
|
||||||
|
}
|
||||||
|
|
||||||
const JsonNode & Rewardable::Info::getParameters() const
|
const JsonNode & Rewardable::Info::getParameters() const
|
||||||
{
|
{
|
||||||
return parameters;
|
return parameters;
|
||||||
|
@ -68,6 +68,8 @@ public:
|
|||||||
|
|
||||||
bool givesBonuses() const override;
|
bool givesBonuses() const override;
|
||||||
|
|
||||||
|
bool hasGuards() const override;
|
||||||
|
|
||||||
void configureObject(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb) const;
|
void configureObject(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb) const;
|
||||||
|
|
||||||
void init(const JsonNode & objectConfig, const std::string & objectTextID);
|
void init(const JsonNode & objectConfig, const std::string & objectTextID);
|
||||||
|
@ -1138,38 +1138,41 @@ void TreasurePlacer::ObjectPool::patchWithZoneConfig(const Zone & zone, Treasure
|
|||||||
auto bannedObjectCategories = zone.getBannedObjectCategories();
|
auto bannedObjectCategories = zone.getBannedObjectCategories();
|
||||||
auto categoriesSet = std::unordered_set<ObjectConfig::EObjectCategory>(bannedObjectCategories.begin(), bannedObjectCategories.end());
|
auto categoriesSet = std::unordered_set<ObjectConfig::EObjectCategory>(bannedObjectCategories.begin(), bannedObjectCategories.end());
|
||||||
|
|
||||||
vstd::erase_if(possibleObjects, [this, &categoriesSet](const ObjectInfo & oi) -> bool
|
if (categoriesSet.count(ObjectConfig::EObjectCategory::ALL))
|
||||||
{
|
{
|
||||||
auto category = getObjectCategory(oi.getCompoundID());
|
possibleObjects.clear();
|
||||||
if (categoriesSet.count(category))
|
}
|
||||||
{
|
else
|
||||||
logGlobal->info("Removing object %s from possible objects", oi.templates.front()->stringID);
|
{
|
||||||
/* FIXME:
|
vstd::erase_if(possibleObjects, [this, &categoriesSet](const ObjectInfo & oi) -> bool
|
||||||
Removing object normal from possible objects
|
|
||||||
Removing object base from possible objects
|
|
||||||
Removing object default from possible objects
|
|
||||||
*/
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
auto bannedObjects = zone.getBannedObjects();
|
|
||||||
auto bannedObjectsSet = std::set<CompoundMapObjectID>(bannedObjects.begin(), bannedObjects.end());
|
|
||||||
vstd::erase_if(possibleObjects, [&bannedObjectsSet](const ObjectInfo & object)
|
|
||||||
{
|
|
||||||
for (const auto & templ : object.templates)
|
|
||||||
{
|
{
|
||||||
CompoundMapObjectID key = object.getCompoundID();
|
auto category = getObjectCategory(oi.getCompoundID());
|
||||||
if (bannedObjectsSet.count(key))
|
if (categoriesSet.count(category))
|
||||||
{
|
{
|
||||||
// FIXME: Stopped working, nothing is banned
|
logGlobal->info("Removing object %s from possible objects", oi.templates.front()->stringID);
|
||||||
logGlobal->info("Banning object %s from possible objects", templ->stringID);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
return false;
|
||||||
return false;
|
});
|
||||||
});
|
|
||||||
|
auto bannedObjects = zone.getBannedObjects();
|
||||||
|
auto bannedObjectsSet = std::set<CompoundMapObjectID>(bannedObjects.begin(), bannedObjects.end());
|
||||||
|
vstd::erase_if(possibleObjects, [&bannedObjectsSet](const ObjectInfo & object)
|
||||||
|
{
|
||||||
|
for (const auto & templ : object.templates)
|
||||||
|
{
|
||||||
|
CompoundMapObjectID key = object.getCompoundID();
|
||||||
|
if (bannedObjectsSet.count(key))
|
||||||
|
{
|
||||||
|
// FIXME: Stopped working, nothing is banned
|
||||||
|
logGlobal->info("Banning object %s from possible objects", templ->stringID);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
auto configuredObjects = zone.getConfiguredObjects();
|
auto configuredObjects = zone.getConfiguredObjects();
|
||||||
|
|
||||||
@ -1219,16 +1222,20 @@ ObjectConfig::EObjectCategory TreasurePlacer::ObjectPool::getObjectCategory(Comp
|
|||||||
|
|
||||||
if (name == "configurable")
|
if (name == "configurable")
|
||||||
{
|
{
|
||||||
// TODO: Access Rewardable::Info by ID
|
|
||||||
|
|
||||||
auto handler = VLC->objtypeh->getHandlerFor(id.primaryID, id.secondaryID);
|
auto handler = VLC->objtypeh->getHandlerFor(id.primaryID, id.secondaryID);
|
||||||
if (!handler)
|
if (!handler)
|
||||||
{
|
{
|
||||||
return ObjectConfig::EObjectCategory::NONE;
|
return ObjectConfig::EObjectCategory::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto temp = handler->getTemplates().front();
|
auto temp = handler->getTemplates().front();
|
||||||
auto info = handler->getObjectInfo(temp);
|
auto info = handler->getObjectInfo(temp);
|
||||||
if (info->givesResources())
|
|
||||||
|
if (info->hasGuards())
|
||||||
|
{
|
||||||
|
return ObjectConfig::EObjectCategory::CREATURE_BANK;
|
||||||
|
}
|
||||||
|
else if (info->givesResources())
|
||||||
{
|
{
|
||||||
return ObjectConfig::EObjectCategory::RESOURCE;
|
return ObjectConfig::EObjectCategory::RESOURCE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user