Planeshift
|
00001 /* 00002 * playergroup.h by Anders Reggestad <[email protected]> 00003 * 00004 * Copyright (C) 2004 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 */ 00019 #ifndef __PLAYERGROUP_H__ 00020 #define __PLAYERGROUP_H__ 00021 00022 #include <csutil/ref.h> 00023 #include <csutil/refarr.h> 00024 #include <csutil/refcount.h> 00025 #include <csutil/array.h> 00026 00027 00028 class gemActor; 00029 class GroupManager; 00030 class Client; 00031 class MsgEntry; 00032 00036 class PlayerGroup : public csRefCount 00037 { 00038 private: 00040 GroupManager* manager; 00041 00043 gemActor* leader; 00044 int id; 00045 static int next_id; 00046 00047 // TODO: Client should use csRefArray but then the client have to 00048 // be ref counted. 00049 csArray<gemActor*> members; 00050 csArray<PlayerGroup*> DuelGroups; 00051 00052 public: 00053 PlayerGroup(GroupManager* mgr, gemActor* leader); 00054 ~PlayerGroup(); 00055 00057 int GetGroupID() 00058 { 00059 return id; 00060 } 00061 00063 void Add(gemActor* new_member); 00064 00066 void Remove(gemActor* member); 00067 00069 void SetLeader(gemActor* new_leader); 00070 00076 bool AddDuelGroup(PlayerGroup* OtherGroup); 00077 00082 void RemoveDuelGroup(PlayerGroup* OtherGroup); 00083 00088 void NotifyDuelYield(PlayerGroup* OtherGroup); 00089 00091 void DuelYield(); 00092 00099 bool IsInDuel(); 00100 00106 bool IsInDuelWith(PlayerGroup* OtherGroup); 00107 00109 void Broadcast(MsgEntry* me); 00110 void ListMembers(gemActor* client); 00111 bool IsLeader(gemActor* client); 00112 gemActor* GetLeader(); 00113 void Disband(); 00114 bool IsEmpty(); 00115 void BroadcastMemberList(); 00116 size_t GetMemberCount() 00117 { 00118 return members.GetSize(); 00119 } 00120 gemActor* GetMember(size_t which) 00121 { 00122 return members[which]; 00123 } 00124 bool HasMember(gemActor* member, bool IncludePets = false); 00125 00126 int operator==(PlayerGroup &other) 00127 { 00128 return id == other.id; 00129 } 00130 00131 int operator<(PlayerGroup &other) 00132 { 00133 return id < other.id; 00134 } 00135 00136 }; 00137 00138 #endif