bool Heroes::ActionSpellCast(const Spell & spell) { std::string error; if(! CanMove()) { Dialog::Message("", _("Your hero is too tired to cast this spell today. Try again tomorrow."), Font::BIG, Dialog::OK); return false; } else if(spell == Spell::NONE || spell.isCombat() || ! CanCastSpell(spell, &error)) { if(error.size()) Dialog::Message("Error", error, Font::BIG, Dialog::OK); return false; } bool apply = false; switch(spell()) { case Spell::VIEWMINES: apply = ActionSpellViewMines(*this); break; case Spell::VIEWRESOURCES: apply = ActionSpellViewResources(*this); break; case Spell::VIEWARTIFACTS: apply = ActionSpellViewArtifacts(*this); break; case Spell::VIEWTOWNS: apply = ActionSpellViewTowns(*this); break; case Spell::VIEWHEROES: apply = ActionSpellViewHeroes(*this); break; case Spell::VIEWALL: apply = ActionSpellViewAll(*this); break; case Spell::IDENTIFYHERO: apply = ActionSpellIdentifyHero(*this); break; case Spell::SUMMONBOAT: apply = ActionSpellSummonBoat(*this); break; case Spell::DIMENSIONDOOR: apply = ActionSpellDimensionDoor(*this); break; case Spell::TOWNGATE: apply = isShipMaster() ? false : ActionSpellTownGate(*this); break; case Spell::TOWNPORTAL: apply = isShipMaster() ? false : ActionSpellTownPortal(*this); break; case Spell::VISIONS: apply = ActionSpellVisions(*this); break; case Spell::HAUNT: apply = ActionSpellSetGuardian(*this, spell, Monster::GHOST); break; case Spell::SETEGUARDIAN: apply = ActionSpellSetGuardian(*this, spell, Monster::EARTH_ELEMENT); break; case Spell::SETAGUARDIAN: apply = ActionSpellSetGuardian(*this, spell, Monster::AIR_ELEMENT); break; case Spell::SETFGUARDIAN: apply = ActionSpellSetGuardian(*this, spell, Monster::FIRE_ELEMENT); break; case Spell::SETWGUARDIAN: apply = ActionSpellSetGuardian(*this, spell, Monster::WATER_ELEMENT); break; default: break; } if(apply) { DEBUG(DBG_GAME, DBG_INFO, GetName() << " cast spell: " << spell.GetName()); SpellCasted(spell); return true; } return false; }