From 2d100b00cd7b4311cf9a8fa638aada4263c0ee7d Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:06:54 +0200 Subject: [PATCH 1/2] check spellbook --- client/battle/BattleWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/battle/BattleWindow.cpp b/client/battle/BattleWindow.cpp index 15216c811..d8bb527b5 100644 --- a/client/battle/BattleWindow.cpp +++ b/client/battle/BattleWindow.cpp @@ -218,7 +218,7 @@ void BattleWindow::showStickyQuickSpellWindow() Settings showStickyQuickSpellWindow = settings.write["battle"]["enableQuickSpellPanel"]; showStickyQuickSpellWindow->Bool() = true; - if(GH.screenDimensions().x >= 1050) + if(GH.screenDimensions().x >= 1050 && owner.getBattle()->battleGetMyHero()->hasSpellbook()) { quickSpellWindow->enable(); quickSpellWindow->isEnabled = true; @@ -838,7 +838,7 @@ void BattleWindow::blockUI(bool on) ESpellCastProblem spellcastingProblem = owner.getBattle()->battleCanCastSpell(hero, spells::Mode::HERO); //if magic is blocked, we leave button active, so the message can be displayed after button click - canCastSpells = spellcastingProblem == ESpellCastProblem::OK || spellcastingProblem == ESpellCastProblem::MAGIC_IS_BLOCKED; + canCastSpells = (spellcastingProblem == ESpellCastProblem::OK || spellcastingProblem == ESpellCastProblem::MAGIC_IS_BLOCKED) && hero->hasSpellbook(); } bool canWait = owner.stacksController->getActiveStack() ? !owner.stacksController->getActiveStack()->waitedThisTurn : false; From e46f5f705bddf717b0bfd6fad40a63572c86d5fa Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Fri, 26 Jul 2024 20:34:47 +0200 Subject: [PATCH 2/2] better approach --- client/battle/BattleWindow.cpp | 2 +- lib/battle/CBattleInfoCallback.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/client/battle/BattleWindow.cpp b/client/battle/BattleWindow.cpp index d8bb527b5..9bc8806cd 100644 --- a/client/battle/BattleWindow.cpp +++ b/client/battle/BattleWindow.cpp @@ -838,7 +838,7 @@ void BattleWindow::blockUI(bool on) ESpellCastProblem spellcastingProblem = owner.getBattle()->battleCanCastSpell(hero, spells::Mode::HERO); //if magic is blocked, we leave button active, so the message can be displayed after button click - canCastSpells = (spellcastingProblem == ESpellCastProblem::OK || spellcastingProblem == ESpellCastProblem::MAGIC_IS_BLOCKED) && hero->hasSpellbook(); + canCastSpells = spellcastingProblem == ESpellCastProblem::OK || spellcastingProblem == ESpellCastProblem::MAGIC_IS_BLOCKED; } bool canWait = owner.stacksController->getActiveStack() ? !owner.stacksController->getActiveStack()->waitedThisTurn : false; diff --git a/lib/battle/CBattleInfoCallback.cpp b/lib/battle/CBattleInfoCallback.cpp index be1e6cc1d..0ad1a62e5 100644 --- a/lib/battle/CBattleInfoCallback.cpp +++ b/lib/battle/CBattleInfoCallback.cpp @@ -128,6 +128,8 @@ ESpellCastProblem CBattleInfoCallback::battleCanCastSpell(const spells::Caster * return ESpellCastProblem::NO_HERO_TO_CAST_SPELL; if(hero->hasBonusOfType(BonusType::BLOCK_ALL_MAGIC)) return ESpellCastProblem::MAGIC_IS_BLOCKED; + if(!hero->hasSpellbook()) + return ESpellCastProblem::NO_SPELLBOOK; } break; default: