Explorar o código

Fixes #1096 - do not propose banned skills on levelup

Remove possibility to get banned skill on levelup as "obligatory skill"
if all other such skills have been learned before.

May happen under some conditions, e.g. if hero quickly learns other
magic schools - in witch hut/university, leading to case where banned
skill is the only obligatory skill that can be offered on levelup
Ivan Savenko %!s(int64=3) %!d(string=hai) anos
pai
achega
e06db2365d
Modificáronse 1 ficheiros con 5 adicións e 3 borrados
  1. 5 3
      lib/mapObjects/CGHeroInstance.cpp

+ 5 - 3
lib/mapObjects/CGHeroInstance.cpp

@@ -1117,7 +1117,9 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelUpProposedSecondarySkills()
 	std::vector<SecondarySkill> obligatorySkills; //hero is offered magic school or wisdom if possible
 	if (!skillsInfo.wisdomCounter)
 	{
-		if (cb->isAllowed(2, SecondarySkill::WISDOM) && !getSecSkillLevel(SecondarySkill::WISDOM))
+		if (cb->isAllowed(2, SecondarySkill::WISDOM) &&
+				!getSecSkillLevel(SecondarySkill::WISDOM) &&
+				type->heroClass->secSkillProbability[SecondarySkill::WISDOM] > 0)
 			obligatorySkills.push_back(SecondarySkill::WISDOM);
 	}
 	if (!skillsInfo.magicSchoolCounter)
@@ -1131,7 +1133,7 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelUpProposedSecondarySkills()
 
 		for (auto skill : ss)
 		{
-			if (cb->isAllowed(2, skill) && !getSecSkillLevel(skill)) //only schools hero doesn't know yet
+			if (cb->isAllowed(2, skill) && !getSecSkillLevel(skill) && type->heroClass->secSkillProbability[skill] > 0) //only schools hero doesn't know yet
 			{
 				obligatorySkills.push_back(skill);
 				break; //only one
@@ -1143,7 +1145,7 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelUpProposedSecondarySkills()
 	//picking sec. skills for choice
 	std::set<SecondarySkill> basicAndAdv, expert, none;
 	for(int i = 0; i < VLC->skillh->size(); i++)
-		if (cb->isAllowed(2,i))
+		if (cb->isAllowed(2,i) && type->heroClass->secSkillProbability[i] > 0)
 			none.insert(SecondarySkill(i));
 
 	for(auto & elem : secSkills)