1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Parsing for CREATURE_TYPE_LIMITER

This commit is contained in:
DjWarmonger 2013-01-18 11:49:15 +00:00
parent ce15eb37c2
commit 97db289d3c
3 changed files with 18 additions and 2 deletions

View File

@ -1369,6 +1369,11 @@ CCreatureTypeLimiter::CCreatureTypeLimiter()
includeUpgrades = false;
}
void CCreatureTypeLimiter::setCreature (TCreature id)
{
creature = VLC->creh->creatures[id];
}
HasAnotherBonusLimiter::HasAnotherBonusLimiter( TBonusType bonus )
: type(bonus), subtype(0), isSubtypeRelevant(false)
{

View File

@ -785,6 +785,7 @@ public:
CCreatureTypeLimiter();
CCreatureTypeLimiter(const CCreature &Creature, ui8 IncludeUpgrades = true);
void setCreature (TCreature id);
int limit(const BonusLimitationContext &context) const OVERRIDE;

View File

@ -1053,8 +1053,18 @@ Bonus * JsonUtils::parseBonus (const JsonNode &ability)
shared_ptr<ILimiter> l;
if (limiter["type"].String() == "CREATURE_TYPE_LIMITER")
{
//continue;
//l = make_shared<CCreatureTypeLimiter>(); //TODO: How the hell resolve pointer to creature?
shared_ptr<CCreatureTypeLimiter> l2 = make_shared<CCreatureTypeLimiter>(); //TODO: How the hell resolve pointer to creature?
const JsonVector vec = limiter["parameters"].Vector();
VLC->modh->identifiers.requestIdentifier(std::string("creature.") + vec[0].String(), [=](si32 creature)
{
l2->setCreature (creature);
});
if (vec.size() > 1)
{
l2->includeUpgrades = vec[1].Bool();
}
else
l2->includeUpgrades = false;
}
if (limiter["type"].String() == "HAS_ANOTHER_BONUS_LIMITER")
{