TrinityCore
LFG.cpp
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#include "LFG.h"
19#include "Language.h"
20#include "ObjectMgr.h"
21#include <sstream>
22
23namespace lfg
24{
25
26std::string ConcatenateDungeons(LfgDungeonSet const& dungeons)
27{
28 std::string dungeonstr = "";
29 if (!dungeons.empty())
30 {
31 std::ostringstream o;
32 LfgDungeonSet::const_iterator it = dungeons.begin();
33 o << (*it);
34 for (++it; it != dungeons.end(); ++it)
35 o << ", " << uint32(*it);
36 dungeonstr = o.str();
37 }
38 return dungeonstr;
39}
40
41std::string GetRolesString(uint8 roles)
42{
43 std::string rolesstr = "";
44
45 if (roles & PLAYER_ROLE_TANK)
46 rolesstr.append(sObjectMgr->GetTrinityStringForDBCLocale(LANG_LFG_ROLE_TANK));
47
48 if (roles & PLAYER_ROLE_HEALER)
49 {
50 if (!rolesstr.empty())
51 rolesstr.append(", ");
52 rolesstr.append(sObjectMgr->GetTrinityStringForDBCLocale(LANG_LFG_ROLE_HEALER));
53 }
54
55 if (roles & PLAYER_ROLE_DAMAGE)
56 {
57 if (!rolesstr.empty())
58 rolesstr.append(", ");
59 rolesstr.append(sObjectMgr->GetTrinityStringForDBCLocale(LANG_LFG_ROLE_DAMAGE));
60 }
61
62 if (roles & PLAYER_ROLE_LEADER)
63 {
64 if (!rolesstr.empty())
65 rolesstr.append(", ");
66 rolesstr.append(sObjectMgr->GetTrinityStringForDBCLocale(LANG_LFG_ROLE_LEADER));
67 }
68
69 if (rolesstr.empty())
70 rolesstr.append(sObjectMgr->GetTrinityStringForDBCLocale(LANG_LFG_ROLE_NONE));
71
72 return rolesstr;
73}
74
75std::string GetStateString(LfgState state)
76{
77 int32 entry = LANG_LFG_ERROR;
78 switch (state)
79 {
80 case LFG_STATE_NONE:
81 entry = LANG_LFG_STATE_NONE;
82 break;
85 break;
88 break;
91 break;
94 break;
97 break;
100 break;
101 }
102
103 return std::string(sObjectMgr->GetTrinityStringForDBCLocale(entry));
104}
105
106} // namespace lfg
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ LANG_LFG_ROLE_TANK
Definition: Language.h:1192
@ LANG_LFG_ROLE_LEADER
Definition: Language.h:1195
@ LANG_LFG_STATE_PROPOSAL
Definition: Language.h:1187
@ LANG_LFG_ERROR
Definition: Language.h:1197
@ LANG_LFG_ROLE_HEALER
Definition: Language.h:1193
@ LANG_LFG_STATE_ROLECHECK
Definition: Language.h:1185
@ LANG_LFG_STATE_RAIDBROWSER
Definition: Language.h:1191
@ LANG_LFG_STATE_DUNGEON
Definition: Language.h:1189
@ LANG_LFG_STATE_NONE
Definition: Language.h:1184
@ LANG_LFG_ROLE_NONE
Definition: Language.h:1196
@ LANG_LFG_STATE_FINISHED_DUNGEON
Definition: Language.h:1190
@ LANG_LFG_STATE_QUEUED
Definition: Language.h:1186
@ LANG_LFG_ROLE_DAMAGE
Definition: Language.h:1194
#define sObjectMgr
Definition: ObjectMgr.h:1946
Definition: LFG.cpp:24
std::string GetStateString(LfgState state)
Definition: LFG.cpp:75
std::string GetRolesString(uint8 roles)
Definition: LFG.cpp:41
std::set< uint32 > LfgDungeonSet
Definition: LFG.h:132
std::string ConcatenateDungeons(LfgDungeonSet const &dungeons)
Definition: LFG.cpp:26
@ PLAYER_ROLE_DAMAGE
Definition: LFG.h:43
@ PLAYER_ROLE_TANK
Definition: LFG.h:41
@ PLAYER_ROLE_LEADER
Definition: LFG.h:40
@ PLAYER_ROLE_HEALER
Definition: LFG.h:42
LfgState
Definition: LFG.h:74
@ LFG_STATE_RAIDBROWSER
Definition: LFG.h:82
@ LFG_STATE_ROLECHECK
Definition: LFG.h:76
@ LFG_STATE_FINISHED_DUNGEON
Definition: LFG.h:81
@ LFG_STATE_DUNGEON
Definition: LFG.h:80
@ LFG_STATE_PROPOSAL
Definition: LFG.h:78
@ LFG_STATE_NONE
Definition: LFG.h:75
@ LFG_STATE_QUEUED
Definition: LFG.h:77