moved selected spell from NpcStats to Spells

actorid
Marc Zinnschlag 13 years ago
parent 26a529111c
commit 52c7ee3b6a

@ -12,7 +12,8 @@ namespace MWMechanics
/// ///
/// For non-NPC-specific stats, see the CreatureStats struct. /// For non-NPC-specific stats, see the CreatureStats struct.
/// ///
/// \note For technical reasons the spell list is also handled by CreatureStats. /// \note For technical reasons the spell list and the currently selected spell is also handled by
/// CreatureStats, even though they are actually NPC stats.
struct NpcStats struct NpcStats
{ {
@ -28,8 +29,6 @@ namespace MWMechanics
bool mSneak; bool mSneak;
bool mCombat; bool mCombat;
std::string mSelectedSpell; // can be an empty string (no spell selected)
NpcStats() : mForceRun (false), mForceSneak (false), mRun (false), mSneak (false), NpcStats() : mForceRun (false), mForceSneak (false), mRun (false), mSneak (false),
mCombat (false) {} mCombat (false) {}
}; };

@ -43,6 +43,9 @@ namespace MWMechanics
if (iter!=mSpells.end()) if (iter!=mSpells.end())
mSpells.erase (iter); mSpells.erase (iter);
if (spellId==mSelectedSpell)
mSelectedSpell.clear();
} }
MagicEffects Spells::getMagicEffects (const MWWorld::Environment& environment) const MagicEffects Spells::getMagicEffects (const MWWorld::Environment& environment) const
@ -65,4 +68,14 @@ namespace MWMechanics
{ {
mSpells.clear(); mSpells.clear();
} }
void Spells::setSelectedSpell (const std::string& spellId)
{
mSelectedSpell = spellId;
}
const std::string Spells::getSelectedSpell() const
{
return mSelectedSpell;
}
} }

@ -32,6 +32,7 @@ namespace MWMechanics
private: private:
std::vector<std::string> mSpells; std::vector<std::string> mSpells;
std::string mSelectedSpell;
void addSpell (const ESM::Spell *, MagicEffects& effects) const; void addSpell (const ESM::Spell *, MagicEffects& effects) const;
@ -42,15 +43,23 @@ namespace MWMechanics
TIterator end() const; TIterator end() const;
void add (const std::string& spell); void add (const std::string& spell);
/// \note Adding a spell that is already listed in *this is a no-op. ///< Adding a spell that is already listed in *this is a no-op.
void remove (const std::string& spell); void remove (const std::string& spell);
///< If the spell to be removed is the selected spell, the selected spell will be changed to
/// no spell (empty string).
MagicEffects getMagicEffects (const MWWorld::Environment& environment) const; MagicEffects getMagicEffects (const MWWorld::Environment& environment) const;
///< Return sum of magic effects resulting from abilities, blights, deseases and curses. ///< Return sum of magic effects resulting from abilities, blights, deseases and curses.
void clear(); void clear();
///< Remove all spells of al types. ///< Remove all spells of al types.
void setSelectedSpell (const std::string& spellId);
///< This function does not verify, if the spell is available.
const std::string getSelectedSpell() const;
///< May return an empty string.
}; };
} }

Loading…
Cancel
Save