TrinityCore
Loading...
Searching...
No Matches
Trainer.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef Trainer_h__
19#define Trainer_h__
20
21#include "Common.h"
22#include <array>
23#include <vector>
24
25class Creature;
26class ObjectMgr;
27class Player;
28
29namespace Trainer
30{
31 enum class Type : uint32
32 {
33 Class = 0,
34 Mount = 1,
35 Tradeskill = 2,
36 Pet = 3
37 };
38
39 enum class SpellState : uint8
40 {
41 Available = 0,
42 Unavailable = 1,
43 Known = 2
44 };
45
46 enum class FailReason : uint32
47 {
48 Unavailable = 0,
51 };
52
54 {
55 uint32 SpellId = 0;
56 uint32 MoneyCost = 0;
57 uint32 ReqSkillLine = 0;
58 uint32 ReqSkillRank = 0;
59 std::array<uint32, 3> ReqAbility = { };
60 uint8 ReqLevel = 0;
61
62 bool IsCastable() const;
63 };
64
66 {
67 public:
68 Trainer(uint32 trainerId, Type type, uint32 requirement, std::string greeting, std::vector<Spell> spells);
69
70 Spell const* GetSpell(uint32 spellId) const;
71 std::vector<Spell> const& GetSpells() const { return _spells; }
72 void SendSpells(Creature const* npc, Player const* player, LocaleConstant locale) const;
73 bool CanTeachSpell(Player const* player, Spell const* trainerSpell) const;
74 void TeachSpell(Creature const* npc, Player* player, uint32 spellId) const;
75
76 Type GetTrainerType() const { return _type; }
77 uint32 GetTrainerRequirement() const { return _requirement; }
78 bool IsTrainerValidForPlayer(Player const* player) const;
79
80 private:
81 SpellState GetSpellState(Player const* player, Spell const* trainerSpell) const;
82 void SendTeachFailure(Creature const* npc, Player const* player, uint32 spellId, FailReason reason) const;
83 void SendTeachSucceeded(Creature const* npc, Player const* player, uint32 spellId) const;
84 std::string const& GetGreeting(LocaleConstant locale) const;
85
86 friend ObjectMgr;
87 void AddGreetingLocale(LocaleConstant locale, std::string greeting);
88
92 std::vector<Spell> _spells;
93 std::array<std::string, TOTAL_LOCALES> _greeting;
94 };
95}
96
97#endif // Trainer_h__
LocaleConstant
Definition Common.h:48
#define TC_GAME_API
Definition Define.h:114
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
Definition Pet.h:40
uint32 _trainerId
Definition Trainer.h:89
uint32 GetTrainerRequirement() const
Definition Trainer.h:77
std::vector< Spell > _spells
Definition Trainer.h:92
std::vector< Spell > const & GetSpells() const
Definition Trainer.h:71
Type GetTrainerType() const
Definition Trainer.h:76
friend ObjectMgr
Definition Trainer.h:86
std::array< std::string, TOTAL_LOCALES > _greeting
Definition Trainer.h:93
uint32 _requirement
Definition Trainer.h:91
SpellState
Definition Trainer.h:40
FailReason
Definition Trainer.h:47