blob: e789c89d5768c548f28ae1f4e9ad93684ce18eb3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/*
* The Mana Server
* Copyright (C) 2004-2010 The Mana World Development Team
*
* This file is part of The Mana Server.
*
* The Mana Server is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* The Mana Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with The Mana Server. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SKILLMANAGER_H
#define SKILLMANAGER_H
#include "utils/string.h"
#include "utils/xml.h"
class SkillManager
{
public:
SkillManager(const std::string & skillFile):
mSkillFile(skillFile),
mDefaultSkillId(0)
{}
~SkillManager()
{ clear(); }
/**
* Loads skill reference file.
*/
void initialize();
/**
* Reloads skill reference file.
*/
void reload();
/**
* Gets the skill Id from a set and a skill string.
*/
unsigned int getId(const std::string& set, const std::string &name) const;
const std::string getSkillName(unsigned int id) const;
const std::string getSetName(unsigned int id) const;
unsigned int getDefaultSkillId() const
{ return mDefaultSkillId; }
private:
struct SkillInfo {
SkillInfo():
id(0)
{}
unsigned int id;
std::string setName;
std::string skillName;
};
/*
* Clears up the skill maps.
*/
void clear();
void readSkillNode(xmlNodePtr skillNode, const std::string& setName);
void printDebugSkillTable();
// The skill file (skills.xml)
std::string mSkillFile;
// The skill map
typedef std::map<unsigned int, SkillInfo*> SkillsInfo;
SkillsInfo mSkillsInfo;
// A map used to get skills per name.
utils::NameMap<SkillInfo*> mNamedSkillsInfo;
// The default skill id
unsigned int mDefaultSkillId;
};
extern SkillManager *skillManager;
#endif // SKILLMANAGER_H
|