private static void HandleLeave(GameSession session, PacketReader packet) { long clubId = packet.ReadLong(); Club club = GameServer.ClubManager.GetClubById(clubId); if (club == null) { return; } if (session.Player.CharacterId == club.Leader.CharacterId) { if (club.Members.Count < 2) { // TODO fix disbanding club.BroadcastPacketClub(ClubPacket.Disband(club)); club.BroadcastPacketClub(ClubPacket.UpdatePlayerClubList(session.Player, club)); } else { // TODO fix reassigning leader session.Send(ClubPacket.LeaveClub(club)); club.BroadcastPacketClub(ClubPacket.LeaveNotice(club, session.Player)); club.BroadcastPacketClub(ClubPacket.AssignNewLeader(session.Player, club)); } } else { session.Send(ClubPacket.LeaveClub(club)); club.BroadcastPacketClub(ClubPacket.LeaveNotice(club, session.Player)); // TODO remove member from club (club.RemoveMember(session.Player);) } }
public void RemoveMember(Player player) { player.Session.Send(ClubPacket.LeaveClub(this)); player.Clubs.Remove(this); BroadcastPacketClub(ClubPacket.LeaveNotice(this, player)); ClubMember member = player.ClubMembers.First(x => x.ClubId == Id); Members.Remove(member); player.ClubMembers.Remove(member); DatabaseManager.ClubMembers.Delete(Id, player.CharacterId); DatabaseManager.Clubs.Update(this); }