aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Pools/QuestPools.h
blob: 6b5cef07ae3af7def76d23477ef43d4915271c3c (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
/*
 * This file is part of the TrinityCore 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 General Public License as published by the
 * Free Software Foundation; either version 2 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 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/>.
 */

#ifndef TRINITY_QUESTPOOLS_H
#define TRINITY_QUESTPOOLS_H

#include "Define.h"
#include <unordered_map>
#include <unordered_set>
#include <vector>

struct QuestPool
{
    using Member = std::vector<uint32>;
    using Members = std::vector<Member>;

    uint32 poolId;
    uint32 numActive;
    Members members;
    std::unordered_set<uint32> activeQuests;
};

class TC_GAME_API QuestPoolMgr
{
    private:
        QuestPoolMgr();
        ~QuestPoolMgr();

    public:
        QuestPoolMgr(QuestPoolMgr const&) = delete;
        QuestPoolMgr(QuestPoolMgr&&) = delete;
        QuestPoolMgr& operator=(QuestPoolMgr const&) = delete;
        QuestPoolMgr& operator=(QuestPoolMgr&&) = delete;

        static QuestPoolMgr* instance();

        void LoadFromDB();
        void ChangeDailyQuests() { Regenerate(_dailyPools); }
        void ChangeWeeklyQuests() { Regenerate(_weeklyPools); }
        void ChangeMonthlyQuests() { Regenerate(_monthlyPools); }

        QuestPool const* FindQuestPool(uint32 poolId) const;
        bool IsQuestPooled(uint32 questId) const { return _poolLookup.find(questId) != _poolLookup.end(); }
        bool IsQuestActive(uint32 questId) const;

    private:
        void Regenerate(std::vector<QuestPool>& pools);
        std::vector<QuestPool> _dailyPools;
        std::vector<QuestPool> _weeklyPools;
        std::vector<QuestPool> _monthlyPools;
        std::unordered_map<uint32, QuestPool*> _poolLookup; // questId -> pool
};

#define sQuestPoolMgr QuestPoolMgr::instance()

#endif