瀏覽代碼

Give banned spells only by SPELL bonus

AlexVinS 10 年之前
父節點
當前提交
dc8b05fbd8
共有 1 個文件被更改,包括 18 次插入6 次删除
  1. 18 6
      lib/spells/CSpellHandler.cpp

+ 18 - 6
lib/spells/CSpellHandler.cpp

@@ -132,30 +132,42 @@ bool CSpell::isCastableBy(const IBonusBearer * caster, bool hasSpellBook, const
 	if(!hasSpellBook)
 		return false;
 
+	const bool isAllowed = IObjectInterface::cb->isAllowed(0, id);
+
 	const bool inSpellBook = vstd::contains(spellBook, id);
-	const bool isBonus = caster->hasBonusOfType(Bonus::SPELL, id);
+	const bool specificBonus = caster->hasBonusOfType(Bonus::SPELL, id);
 
-	bool inTome = false;
+	bool schoolBonus = false;
 
 	forEachSchool([&](const SpellSchoolInfo & cnf, bool & stop)
 	{
 		if(caster->hasBonusOfType(cnf.knoledgeBonus))
 		{
-			inTome = stop = true;
+			schoolBonus = stop = true;
 		}
 	});
 
+	const bool levelBonus = caster->hasBonusOfType(Bonus::SPELLS_OF_LEVEL, level);
+
     if (isSpecialSpell())
     {
         if (inSpellBook)
         {//hero has this spell in spellbook
-            logGlobal->errorStream() << "Special spell in spellbook "<<name;
+            logGlobal->errorStream() << "Special spell " << name << "in spellbook.";
+        }
+        return specificBonus;
+    }
+    else if(!isAllowed)
+    {
+        if (inSpellBook)
+        {//hero has this spell in spellbook
+            logGlobal->errorStream() << "Banned spell " << name << " in spellbook.";
         }
-        return isBonus;
+        return specificBonus;
     }
     else
     {
-       return inSpellBook || inTome || isBonus || caster->hasBonusOfType(Bonus::SPELLS_OF_LEVEL, level);
+       return inSpellBook || schoolBonus || specificBonus || levelBonus;
     }
 }