Planeshift
playergroup.h
Go to the documentation of this file.
1 /*
2  * playergroup.h by Anders Reggestad <andersr@pvv.org>
3  *
4  * Copyright (C) 2004 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
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  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 #ifndef __PLAYERGROUP_H__
20 #define __PLAYERGROUP_H__
21 
22 #include <csutil/ref.h>
23 #include <csutil/refarr.h>
24 #include <csutil/refcount.h>
25 #include <csutil/array.h>
26 
27 
28 class gemActor;
29 class GroupManager;
30 class Client;
31 class MsgEntry;
32 
36 class PlayerGroup : public csRefCount
37 {
38 private:
40  GroupManager* manager;
41 
43  gemActor* leader;
44  int id;
45  static int next_id;
46 
47  // TODO: Client should use csRefArray but then the client have to
48  // be ref counted.
49  csArray<gemActor*> members;
50  csArray<PlayerGroup*> DuelGroups;
51 
52 public:
53  PlayerGroup(GroupManager* mgr, gemActor* leader);
54  ~PlayerGroup();
55 
57  int GetGroupID()
58  {
59  return id;
60  }
61 
63  void Add(gemActor* new_member);
64 
66  void Remove(gemActor* member);
67 
69  void SetLeader(gemActor* new_leader);
70 
76  bool AddDuelGroup(PlayerGroup* OtherGroup);
77 
82  void RemoveDuelGroup(PlayerGroup* OtherGroup);
83 
88  void NotifyDuelYield(PlayerGroup* OtherGroup);
89 
91  void DuelYield();
92 
99  bool IsInDuel();
100 
106  bool IsInDuelWith(PlayerGroup* OtherGroup);
107 
109  void Broadcast(MsgEntry* me);
110  void ListMembers(gemActor* client);
111  bool IsLeader(gemActor* client);
112  gemActor* GetLeader();
113  void Disband();
114  bool IsEmpty();
115  void BroadcastMemberList();
116  size_t GetMemberCount()
117  {
118  return members.GetSize();
119  }
120  gemActor* GetMember(size_t which)
121  {
122  return members[which];
123  }
124  bool HasMember(gemActor* member, bool IncludePets = false);
125 
127  {
128  return id == other.id;
129  }
130 
131  int operator<(PlayerGroup &other)
132  {
133  return id < other.id;
134  }
135 
136 };
137 
138 #endif
bool HasMember(gemActor *member, bool IncludePets=false)
int operator<(PlayerGroup &other)
Definition: playergroup.h:131
int GetGroupID()
Return the ID of this group.
Definition: playergroup.h:57
gemActor * GetLeader()
PlayerGroup(GroupManager *mgr, gemActor *leader)
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
gemActor * GetMember(size_t which)
Definition: playergroup.h:120
void Add(gemActor *new_member)
Add a new client to the existing group.
Main PlayerGroup Manager that holds all the groups.
Definition: groupmanager.h:56
void Broadcast(MsgEntry *me)
Send a message to all members in this group.
bool IsLeader(gemActor *client)
void SetLeader(gemActor *new_leader)
Change the leader of this group.
Any semi-autonomous object, either a player or an NPC.
Definition: gem.h:1170
int operator==(PlayerGroup &other)
Definition: playergroup.h:126
void RemoveDuelGroup(PlayerGroup *OtherGroup)
Remove a group from the list of those in duel with this.
void BroadcastMemberList()
void DuelYield()
Yield to all groups in duel with this.
An existing group.
Definition: playergroup.h:36
size_t GetMemberCount()
Definition: playergroup.h:116
This class collects data of a netclient.
Definition: client.h:95
bool IsInDuelWith(PlayerGroup *OtherGroup)
Check if we are in duel with another group.
void NotifyDuelYield(PlayerGroup *OtherGroup)
Notify the group of the yielding of another group.
bool IsEmpty()
bool IsInDuel()
Checks if the group is in duel with any other group.
void Disband()
void ListMembers(gemActor *client)
bool AddDuelGroup(PlayerGroup *OtherGroup)
Add a new group to the list of those in duel with this.
void Remove(gemActor *member)
Remove a client from this group.