1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 05:49:56 +00:00
openmw-tes3mp/apps/openmw/mwmechanics/spells.hpp

94 lines
2.6 KiB
C++
Raw Normal View History

2012-04-11 16:29:36 +00:00
#ifndef GAME_MWMECHANICS_SPELLS_H
#define GAME_MWMECHANICS_SPELLS_H
#include <map>
2012-04-11 17:40:42 +00:00
#include <string>
2014-02-23 19:11:05 +00:00
#include <components/misc/stringops.hpp>
#include "../mwworld/ptr.hpp"
2014-05-12 19:04:02 +00:00
#include "../mwworld/timestamp.hpp"
#include "magiceffects.hpp"
2014-05-12 19:04:02 +00:00
2012-04-11 17:40:42 +00:00
namespace ESM
{
struct Spell;
2014-05-12 19:04:02 +00:00
struct SpellState;
2012-04-11 17:40:42 +00:00
}
2012-04-11 16:29:36 +00:00
namespace MWMechanics
{
class MagicEffects;
/// \brief Spell list
///
/// This class manages known spells as well as abilities, powers and permanent negative effects like
2014-05-12 19:04:02 +00:00
/// diseases. It also keeps track of used powers (which can only be used every 24h).
2012-04-11 16:29:36 +00:00
class Spells
{
public:
2014-05-12 19:04:02 +00:00
typedef std::map<std::string, std::map<const int, float> > TContainer; // ID, <effect index, normalised random magnitude>
2012-04-11 16:29:36 +00:00
typedef TContainer::const_iterator TIterator;
private:
TContainer mSpells;
2014-05-12 19:04:02 +00:00
// Note: this is the spell that's about to be cast, *not* the spell selected in the GUI (which may be different)
std::string mSelectedSpell;
2012-04-11 16:29:36 +00:00
2014-05-12 19:04:02 +00:00
std::map<std::string, MWWorld::TimeStamp> mUsedPowers;
2012-04-11 16:29:36 +00:00
public:
2014-05-12 19:04:02 +00:00
bool canUsePower (const std::string& power) const;
void usePower (const std::string& power);
void purgeCommonDisease();
void purgeBlightDisease();
void purgeCorprusDisease();
void purgeCurses();
2012-04-11 17:40:42 +00:00
TIterator begin() const;
2012-04-11 16:29:36 +00:00
2012-04-11 17:40:42 +00:00
TIterator end() const;
2012-04-11 16:29:36 +00:00
bool hasSpell(const std::string& spell) { return mSpells.find(Misc::StringUtils::lowerCase(spell)) != mSpells.end(); }
2012-04-11 17:40:42 +00:00
void add (const std::string& spell);
///< Adding a spell that is already listed in *this is a no-op.
2012-04-11 16:29:36 +00:00
2012-04-11 17:40:42 +00:00
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).
2012-04-11 16:29:36 +00:00
MagicEffects getMagicEffects() const;
2012-04-11 16:29:36 +00:00
///< Return sum of magic effects resulting from abilities, blights, deseases and curses.
void clear();
///< 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.
2012-11-09 17:16:29 +00:00
bool hasCommonDisease() const;
bool hasBlightDisease() const;
void visitEffectSources (MWMechanics::EffectSourceVisitor& visitor) const;
2014-05-12 19:04:02 +00:00
void readState (const ESM::SpellState& state);
void writeState (ESM::SpellState& state) const;
2012-04-11 16:29:36 +00:00
};
}
#endif