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

small refactor secskill limit check.

This commit is contained in:
alexvins
2012-12-18 11:24:13 +00:00
parent 94c55e2632
commit 66d9edf76e
4 changed files with 14 additions and 9 deletions

View File

@@ -259,14 +259,14 @@ void CGameHandler::levelUpHero(int ID)
hlu.skills.push_back(s);
basicAndAdv.erase(s);
}
else if(none.size() && hero->secSkills.size() < GameConstants::SKILL_PER_HERO)
else if(none.size() && hero->canLearnSkill())
{
hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(none)); //give new skill
none.erase(hlu.skills.back());
}
//second offered skill
if(none.size() && hero->secSkills.size() < GameConstants::SKILL_PER_HERO) //hero have free skill slot
if(none.size() && hero->canLearnSkill()) //hero have free skill slot
{
hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(none)); //new skill
}
@@ -3005,7 +3005,7 @@ bool CGameHandler::buySecSkill( const IMarket *m, const CGHeroInstance *h, int s
if (h->getSecSkillLevel(static_cast<CGHeroInstance::SecondarySkill>(skill)))
COMPLAIN_RET("Hero already know this skill");
if (h->secSkills.size() >= GameConstants::SKILL_PER_HERO)//can't learn more skills
if (!h->canLearnSkill())
COMPLAIN_RET("Hero can't learn any more skills");
if (h->type->heroClass->secSkillProbability[skill]==0)//can't learn this skill (like necromancy for most of non-necros)