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_PARTY_H_41D4D7CF417C4CC99FAE94D552255044
21#define FS_PARTY_H_41D4D7CF417C4CC99FAE94D552255044
22
23#include "player.h"
24#include "monsters.h"
25
26class Player;
27class Party;
28
29using PlayerVector = std::vector<Player*>;
30
31class Party
32{
33 public:
34 explicit Party(Player* leader);
35
36 Player* getLeader() const {
37 return leader;
38 }
39 PlayerVector& getMembers() {
40 return memberList;
41 }
42 const PlayerVector& getInvitees() const {
43 return inviteList;
44 }
45 size_t getMemberCount() const {
46 return memberList.size();
47 }
48 size_t getInvitationCount() const {
49 return inviteList.size();
50 }
51
52 void disband();
53 bool invitePlayer(Player& player);
54 bool joinParty(Player& player);
55 void revokeInvitation(Player& player);
56 bool passPartyLeadership(Player* player);
57 bool leaveParty(Player* player);
58
59 bool removeInvite(Player& player, bool removeFromPlayer = true);
60
61 bool isPlayerInvited(const Player* player) const;
62 void updateAllPartyIcons();
63 void broadcastPartyMessage(MessageClasses msgClass, const std::string& msg, bool sendToInvitations = false);
64 bool empty() const {
65 return memberList.empty() && inviteList.empty();
66 }
67 bool canOpenCorpse(uint32_t ownerId) const;
68
69 void shareExperience(uint64_t experience, Creature* source = nullptr);
70 bool setSharedExperience(Player* player, bool sharedExpActive);
71 bool isSharedExperienceActive() const {
72 return sharedExpActive;
73 }
74 bool isSharedExperienceEnabled() const {
75 return sharedExpEnabled;
76 }
77 bool canUseSharedExperience(const Player* player) const;
78 void updateSharedExperience();
79
80 void updatePlayerTicks(Player* player, uint32_t points);
81 void clearPlayerPoints(Player* player);
82
83 private:
84 bool canEnableSharedExperience();
85
86 std::map<uint32_t, int64_t> ticksMap;
87
88 PlayerVector memberList;
89 PlayerVector inviteList;
90
91 Player* leader;
92
93 bool sharedExpActive = false;
94 bool sharedExpEnabled = false;
95};
96
97#endif
98