[9111] Implement ConditionType CONDITION_LEVEL for PlayerCondition

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-01-05 01:58:40 +01:00
parent 644cdf70d3
commit effe02fb25
3 changed files with 26 additions and 2 deletions

View file

@ -7257,6 +7257,15 @@ bool PlayerCondition::Meets(Player const * player) const
if ((!value1 || (player->getRaceMask() & value1)) && (!value2 || (player->getClassMask() & value2)))
return true;
return false;
case CONDITION_LEVEL:
{
switch(value2)
{
case 0: return player->getLevel() == value1;
case 1: return player->getLevel() >= value1;
case 2: return player->getLevel() <= value1;
}
}
default:
return false;
}
@ -7431,6 +7440,20 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val
}
break;
}
case CONDITION_LEVEL:
{
if (!value1 || value1 > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
{
sLog.outErrorDb("Level condition has invalid level %u, skipped", value1);
return false;
}
if (value2 > 2)
{
sLog.outErrorDb("Level condition has invalid argument %u (must be 0..2), skipped", value2);
return false;
}
}
case CONDITION_NONE:
break;
}