예제 #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
        private static void HandleJoin(GameSession session, PacketReader packet)
        {
            Party party = GameServer.PartyManager.GetPartyById(session.Player.PartyId);

            if (party == null)
            {
                return;
            }

            long clubId = packet.ReadLong();

            Club club = GameServer.ClubManager.GetClubById(clubId);

            if (club == null)
            {
                return;
            }

            if (club.Leader.CharacterId == session.Player.CharacterId)
            {
                party.BroadcastPacketParty(ClubPacket.UpdatePlayerClubList(session.Player, club));
            }
            else
            {
                int response = packet.ReadInt(); // 0 = accept, 76 (0x4C) = reject

                if (response == 0)
                {
                    party.BroadcastPacketParty(ClubPacket.ConfirmCreate(club.Id));
                    club.Leader.Session.Send(ClubPacket.Join(session.Player, club));
                    club.Leader.Session.Send(ClubPacket.Establish(club));
                    // TODO add member to club (club.AddMember(session.Player);)
                }
                else
                {
                    // TODO update to proper rejection packet
                    party.Leader.Session.Send(ChatPacket.Send(party.Leader, session.Player.Name + " declined the invitation.", ChatType.NoticeAlert2));
                }
            }
        }
예제 #3
0
        private static void HandleInviteResponse(GameSession session, PacketReader packet)
        {
            long   clubId     = packet.ReadLong();
            string clubName   = packet.ReadUnicodeString();
            string clubLeader = packet.ReadUnicodeString();
            string invitee    = packet.ReadUnicodeString(); //playerName. TODO: verify player name
            byte   response   = packet.ReadByte();          // 1 = accept

            Club club = GameServer.ClubManager.GetClubById(clubId);

            if (club == null)
            {
                return;
            }

            Player other = GameServer.Storage.GetPlayerByName(invitee);

            if (other == null)
            {
                return;
            }

            if (response == 1)
            {
                club.Leader.Session.Send(ClubPacket.LeaderInviteResponse(club, invitee, response));
                club.BroadcastPacketClub(ClubPacket.ConfirmInvite(club, other.Session.Player));
                other.Session.Send(ClubPacket.InviteResponse(club, session.Player));
                other.Session.Send(ClubPacket.Join(session.Player, club));
                other.Session.Send(ClubPacket.UpdateClub(club));
                club.BroadcastPacketClub(ClubPacket.UpdatePlayerClubList(session.Player, club));
                // TODO add member to club (club.AddMember(other);)
            }
            else
            {
                club.Leader.Session.Send(ClubPacket.LeaderInviteResponse(club, invitee, response));
                other.Session.Send(ClubPacket.InviteResponse(club, session.Player));
            }
        }