コード例 #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
ファイル: Club.cs プロジェクト: Etchavious/MapleServer2
    public void AssignNewLeader(Player oldLeader)
    {
        if (Members.Count <= 2)
        {
            Disband();
            return;
        }

        Player player = Members.OrderBy(x => x.JoinTimestamp)
                        .First(x => x.Player != oldLeader).Player;

        LeaderAccountId   = player.AccountId;
        LeaderCharacterId = player.CharacterId;
        LeaderName        = player.Name;
        BroadcastPacketClub(ClubPacket.AssignNewLeader(oldLeader, this));
        DatabaseManager.Clubs.Update(this);
    }