Пример #1
0
        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);)
            }
        }
Пример #2
0
    public void Disband()
    {
        BroadcastPacketClub(ClubPacket.Disband(this));
        List <GameSession> memberSessions = GetSessions();

        foreach (GameSession session in memberSessions)
        {
            session.Player.Clubs.Remove(this);
            ClubMember membership = session.Player.ClubMembers.FirstOrDefault(x => x.ClubId == Id);
            session.Player.ClubMembers.Remove(membership);
            DatabaseManager.ClubMembers.Delete(Id, session.Player.CharacterId);
        }
        GameServer.ClubManager.RemoveClub(this);
    }