1/**
2 * The Forgotten Server - a free and open-source MMORPG server emulator
3 * Copyright (C) 2019 Mark Samman <mark.samman@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#ifndef FS_GUILD_H_C00F0A1D732E4BA88FF62ACBE74D76BC
21#define FS_GUILD_H_C00F0A1D732E4BA88FF62ACBE74D76BC
22
23class Player;
24
25struct GuildRank {
26 uint32_t id;
27 std::string name;
28 uint8_t level;
29
30 GuildRank(uint32_t id, std::string name, uint8_t level) :
31 id(id), name(std::move(name)), level(level) {}
32};
33
34using GuildRank_ptr = std::shared_ptr<GuildRank>;
35
36class Guild
37{
38 public:
39 Guild(uint32_t id, std::string name) : name(std::move(name)), id(id) {}
40
41 void addMember(Player* player);
42 void removeMember(Player* player);
43
44 uint32_t getId() const {
45 return id;
46 }
47 const std::string& getName() const {
48 return name;
49 }
50 const std::list<Player*>& getMembersOnline() const {
51 return membersOnline;
52 }
53 uint32_t getMemberCount() const {
54 return memberCount;
55 }
56 void setMemberCount(uint32_t count) {
57 memberCount = count;
58 }
59
60 const std::vector<GuildRank_ptr>& getRanks() const {
61 return ranks;
62 }
63 GuildRank_ptr getRankById(uint32_t rankId);
64 GuildRank_ptr getRankByName(const std::string& name) const;
65 GuildRank_ptr getRankByLevel(uint8_t level) const;
66 void addRank(uint32_t rankId, const std::string& rankName, uint8_t level);
67
68 const std::string& getMotd() const {
69 return motd;
70 }
71 void setMotd(const std::string& motd) {
72 this->motd = motd;
73 }
74
75 private:
76 std::list<Player*> membersOnline;
77 std::vector<GuildRank_ptr> ranks;
78 std::string name;
79 std::string motd;
80 uint32_t id;
81 uint32_t memberCount = 0;
82};
83
84#endif
85