1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 03:32:36 +00:00

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

107 lines
3.1 KiB
C++
Raw Normal View History

2012-04-11 18:29:36 +02:00
#ifndef GAME_MWMECHANICS_SPELLS_H
#define GAME_MWMECHANICS_SPELLS_H
#include <memory>
#include <map>
2012-04-11 19:40:42 +02:00
#include <string>
#include <vector>
2012-04-11 19:40:42 +02:00
2014-05-12 21:04:02 +02:00
#include "../mwworld/timestamp.hpp"
#include "spelllist.hpp"
2014-05-12 21:04:02 +02:00
2012-04-11 19:40:42 +02:00
namespace ESM
{
2014-05-12 21:04:02 +02:00
struct SpellState;
2012-04-11 19:40:42 +02:00
}
2012-04-11 18:29:36 +02:00
namespace MWMechanics
{
class CreatureStats;
2012-04-11 18:29:36 +02:00
class MagicEffects;
/// \brief Spell list
///
/// This class manages known spells as well as abilities, powers and permanent negative effects like
2014-05-12 21:04:02 +02:00
/// diseases. It also keeps track of used powers (which can only be used every 24h).
2012-04-11 18:29:36 +02:00
class Spells
{
std::shared_ptr<SpellList> mSpellList;
std::vector<const ESM::Spell*> mSpells;
2014-05-12 21:04:02 +02: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 18:29:36 +02:00
std::vector<std::pair<const ESM::Spell*, MWWorld::TimeStamp>> mUsedPowers;
bool hasSpellType(const ESM::Spell::SpellType type) const;
using SpellFilter = bool (*)(const ESM::Spell*);
void purge(const SpellFilter& filter);
void addSpell(const ESM::Spell* spell);
void removeSpell(const ESM::Spell* spell);
void removeAllSpells();
friend class SpellList;
2014-08-20 12:40:38 +02:00
public:
Spells();
2021-03-14 19:32:03 +01:00
Spells(const Spells&);
Spells(Spells&& spells);
2021-03-14 19:32:03 +01:00
~Spells();
static bool hasCorprusEffect(const ESM::Spell *spell);
2012-04-11 18:29:36 +02:00
bool canUsePower (const ESM::Spell* spell) const;
void usePower (const ESM::Spell* spell);
2014-05-12 21:04:02 +02:00
void purgeCommonDisease();
void purgeBlightDisease();
void purgeCorprusDisease();
void purgeCurses();
std::vector<const ESM::Spell*>::const_iterator begin() const;
2012-04-11 18:29:36 +02:00
std::vector<const ESM::Spell*>::const_iterator end() const;
2012-04-11 18:29:36 +02:00
bool hasSpell(std::string_view spell) const;
bool hasSpell(const ESM::Spell* spell) const;
void add(std::string_view spell);
///< Adding a spell that is already listed in *this is a no-op.
void add (const ESM::Spell* spell);
///< Adding a spell that is already listed in *this is a no-op.
2012-04-11 18:29:36 +02:00
void remove(std::string_view 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 18:29:36 +02:00
void clear(bool modifyBase = false);
2012-04-11 18:29:36 +02:00
///< Remove all spells of al types.
void setSelectedSpell (const std::string& spellId);
///< This function does not verify, if the spell is available.
2022-08-27 13:07:59 +02:00
const std::string& getSelectedSpell() const;
///< May return an empty string.
2012-11-09 18:16:29 +01:00
bool hasCommonDisease() const;
bool hasBlightDisease() const;
void readState (const ESM::SpellState& state, CreatureStats* creatureStats);
2014-05-12 21:04:02 +02:00
void writeState (ESM::SpellState& state) const;
bool setSpells(const std::string& id);
void addAllToInstance(const std::vector<std::string>& spells);
2012-04-11 18:29:36 +02:00
};
}
#endif