1 /*
2  *  The ManaPlus Client
3  *  Copyright (C) 2011-2019  The ManaPlus Developers
4  *  Copyright (C) 2019-2021  Andrei Karas
5  *
6  *  This file is part of The ManaPlus Client.
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef NET_TMWA_GUILDMANAGER_H
23 #define NET_TMWA_GUILDMANAGER_H
24 
25 #ifdef TMWA_SUPPORT
26 
27 #include "utils/stringvector.h"
28 
29 #include "localconsts.h"
30 
31 class ChatTab;
32 class Guild;
33 class EmulateGuildTab;
34 
35 class GuildManager final
36 {
37     public:
38         GuildManager();
39 
40         A_DELETE_COPY(GuildManager)
41 
42         ~GuildManager();
43 
44         static void init();
45 
46         void chat(const std::string &msg);
47 
48         static void send(const std::string &msg);
49 
50         static void getNames(StringVect &names);
51 
52         void requestGuildInfo();
53 
54         void updateList();
55 
getEnableGuildBot()56         static bool getEnableGuildBot() A_WARN_UNUSED
57         { return mEnableGuildBot; }
58 
59         static void kick(const std::string &msg);
60 
61         static void invite(const std::string &msg);
62 
63         static void leave();
64 
65         static void notice(const std::string &msg);
66 
67         void createTab(Guild *const guild);
68 
69         static Guild *createGuild() A_WARN_UNUSED;
70 
71         static void clear();
72 
73         void reload();
74 
75         static void inviteResponse(const bool response);
76 
77         bool afterRemove();
78 
79         void slowLogic();
80 
havePower()81         bool havePower() const A_WARN_UNUSED
82         { return mHavePower; }
83 
84         ChatTab *getTab();
85 
86         bool processGuildMessage(const std::string &msg);
87 
88     private:
89         bool process(std::string msg);
90 
91         static bool mEnableGuildBot;
92         bool mGotInfo;
93         bool mGotName;
94         bool mSentInfoRequest;
95         bool mSentNameRequest;
96         bool mHavePower;
97         StringVect mTempList;
98         EmulateGuildTab *mTab;
99         bool mRequest;
100         time_t mRequestTime;
101         bool mGotOnlineInfo;
102 };
103 
104 extern GuildManager *guildManager;
105 
106 #endif  // TMWA_SUPPORT
107 #endif  // NET_TMWA_GUILDMANAGER_H
108