1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 21:42:13 +00:00
OpenMW/apps/openmw/mwmechanics/spells.cpp

78 lines
1.8 KiB
C++
Raw Normal View History

2012-04-11 16:29:36 +00:00
#include "spells.hpp"
#include <components/esm_store/store.hpp>
2012-04-11 17:40:42 +00:00
#include <components/esm/loadspel.hpp>
2012-04-11 16:29:36 +00:00
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
2012-04-11 16:29:36 +00:00
#include "magiceffects.hpp"
namespace MWMechanics
{
void Spells::addSpell (const ESM::Spell *spell, MagicEffects& effects) const
{
2012-09-17 07:37:50 +00:00
effects.add (spell->mEffects);
2012-04-11 16:29:36 +00:00
}
2012-04-11 17:40:42 +00:00
Spells::TIterator Spells::begin() const
2012-04-11 16:29:36 +00:00
{
2012-04-11 17:40:42 +00:00
return mSpells.begin();
2012-04-11 16:29:36 +00:00
}
2012-04-11 17:40:42 +00:00
Spells::TIterator Spells::end() const
2012-04-11 16:29:36 +00:00
{
2012-04-11 17:40:42 +00:00
return mSpells.end();
2012-04-11 16:29:36 +00:00
}
2012-04-11 17:40:42 +00:00
void Spells::add (const std::string& spellId)
2012-04-11 16:29:36 +00:00
{
if (std::find (mSpells.begin(), mSpells.end(), spellId)==mSpells.end())
2012-04-11 17:40:42 +00:00
mSpells.push_back (spellId);
2012-04-11 16:29:36 +00:00
}
2012-04-11 17:40:42 +00:00
void Spells::remove (const std::string& spellId)
2012-04-11 16:29:36 +00:00
{
2012-04-11 17:40:42 +00:00
TContainer::iterator iter = std::find (mSpells.begin(), mSpells.end(), spellId);
2012-04-11 16:29:36 +00:00
2012-04-11 17:40:42 +00:00
if (iter!=mSpells.end())
mSpells.erase (iter);
if (spellId==mSelectedSpell)
mSelectedSpell.clear();
2012-04-11 16:29:36 +00:00
}
MagicEffects Spells::getMagicEffects() const
2012-04-11 16:29:36 +00:00
{
MagicEffects effects;
2012-04-11 17:40:42 +00:00
for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter)
{
const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter);
2012-04-11 17:40:42 +00:00
2012-09-17 07:37:50 +00:00
if (spell->mData.mType==ESM::Spell::ST_Ability || spell->mData.mType==ESM::Spell::ST_Blight ||
spell->mData.mType==ESM::Spell::ST_Disease || spell->mData.mType==ESM::Spell::ST_Curse)
2012-04-11 17:40:42 +00:00
addSpell (spell, effects);
}
2012-04-11 16:29:36 +00:00
return effects;
}
void Spells::clear()
{
2012-04-11 17:40:42 +00:00
mSpells.clear();
2012-04-11 16:29:36 +00:00
}
void Spells::setSelectedSpell (const std::string& spellId)
{
mSelectedSpell = spellId;
}
const std::string Spells::getSelectedSpell() const
{
return mSelectedSpell;
}
2012-04-11 16:29:36 +00:00
}