summaryrefslogtreecommitdiff
path: root/src/server/game/DungeonFinding/LFG.cpp
blob: 2277a0784058df0a5815a61c69a57c0aab36b394 (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
 * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by the
 * Free Software Foundation; either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program 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 Affero General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include "LFG.h"
#include "Language.h"
#include "ObjectMgr.h"

namespace lfg
{

    std::string ConcatenateDungeons(LfgDungeonSet const& dungeons)
    {
        std::string dungeonstr = "";
        if (!dungeons.empty())
        {
            std::ostringstream o;
            LfgDungeonSet::const_iterator it = dungeons.begin();
            o << (*it);
            for (++it; it != dungeons.end(); ++it)
                o << ", " << uint32(*it);
            dungeonstr = o.str();
        }
        return dungeonstr;
    }

    std::string GetRolesString(uint8 roles)
    {
        std::string rolesstr = "";

        if (roles & PLAYER_ROLE_TANK)
            rolesstr.append(sObjectMgr->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_TANK));

        if (roles & PLAYER_ROLE_HEALER)
        {
            if (!rolesstr.empty())
                rolesstr.append(", ");
            rolesstr.append(sObjectMgr->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_HEALER));
        }

        if (roles & PLAYER_ROLE_DAMAGE)
        {
            if (!rolesstr.empty())
                rolesstr.append(", ");
            rolesstr.append(sObjectMgr->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_DAMAGE));
        }

        if (roles & PLAYER_ROLE_LEADER)
        {
            if (!rolesstr.empty())
                rolesstr.append(", ");
            rolesstr.append(sObjectMgr->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_LEADER));
        }

        if (rolesstr.empty())
            rolesstr.append(sObjectMgr->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_NONE));

        return rolesstr;
    }

    std::string GetStateString(LfgState state)
    {
        int32 entry = LANG_LFG_ERROR;
        switch (state)
        {
            case LFG_STATE_NONE:
                entry = LANG_LFG_STATE_NONE;
                break;
            case LFG_STATE_ROLECHECK:
                entry = LANG_LFG_STATE_ROLECHECK;
                break;
            case LFG_STATE_QUEUED:
                entry = LANG_LFG_STATE_QUEUED;
                break;
            case LFG_STATE_PROPOSAL:
                entry = LANG_LFG_STATE_PROPOSAL;
                break;
            case LFG_STATE_DUNGEON:
                entry = LANG_LFG_STATE_DUNGEON;
                break;
            case LFG_STATE_BOOT:
                entry = LANG_LFG_STATE_BOOT;
                break;
            case LFG_STATE_FINISHED_DUNGEON:
                entry = LANG_LFG_STATE_FINISHED_DUNGEON;
                break;
            case LFG_STATE_RAIDBROWSER:
                entry = LANG_LFG_STATE_RAIDBROWSER;
                break;
        }

        return std::string(sObjectMgr->GetAcoreStringForDBCLocale(entry));
    }

} // namespace lfg