ManaPlus
spellmanager.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2009 The Mana World Development Team
4  * Copyright (C) 2011-2019 The ManaPlus Developers
5  * Copyright (C) 2009-2021 Andrei Karas
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef SPELLMANAGER_H
24 #define SPELLMANAGER_H
25 
26 #include "utils/vector.h"
27 
28 #include <string>
29 #include <map>
30 
31 #include "localconsts.h"
32 
33 class Being;
34 class TextCommand;
35 
37 {
38  public:
39  SpellManager();
40 
42 
43  ~SpellManager();
44 
45  TextCommand *getSpell(const int spellId) const A_WARN_UNUSED;
46 
47  const TextCommand* getSpellByItem(const int itemId)
48  const A_WARN_UNUSED;
49 
50  bool addSpell(TextCommand *const spell);
51 
53 
54  const STD_VECTOR<TextCommand*> &getAll() const A_CONST A_WARN_UNUSED;
55 
56  void useItem(const int itemId) const;
57 
58  void invoke(const int spellId) const;
59 
60  void load();
61 
62  void save() const;
63 
64  std::string autoComplete(const std::string &partName)
65  const A_WARN_UNUSED;
66 
67  void swap(const int id1, const int id2);
68 
69  static void invokeCommand(const std::string &command,
70  const Being *const target);
71 
72  private:
73  void fillSpells();
74 
75  static void invokeSpell(const TextCommand *const spell,
76  const Being *const target);
77 
78  static void invokeSpell(const TextCommand *const spell);
79 
80  static std::string parseCommand(std::string command,
81  const Being *const target)
83 
84  std::map<unsigned int, TextCommand*> mSpells;
85  STD_VECTOR<TextCommand*> mSpellsVector;
86 };
87 
89 
90 #endif // SPELLMANAGER_H
Definition: being.h:96
std::vector< TextCommand * > mSpellsVector
Definition: spellmanager.h:85
const std::vector< TextCommand * > & getAll() const A_CONST
TextCommand * createNewSpell() const
static void invokeCommand(const std::string &command, const Being *const target)
const TextCommand * getSpellByItem(const int itemId) const
std::map< unsigned int, TextCommand * > mSpells
Definition: spellmanager.h:84
void swap(const int id1, const int id2)
static void invokeSpell(const TextCommand *const spell, const Being *const target)
bool addSpell(TextCommand *const spell)
void fillSpells()
void invoke(const int spellId) const
std::string autoComplete(const std::string &partName) const
TextCommand * getSpell(const int spellId) const
static std::string parseCommand(std::string command, const Being *const target)
void save() const
void useItem(const int itemId) const
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
SpellManager * spellManager