Пример #1
0
 public void AcceptInvite(Player player)
 {
     AddMember(player, out ClubMember member);
     BroadcastPacketClub(ClubPacket.ConfirmInvite(this, member));
     player.Session.Send(ClubPacket.Join(player.Name, this));
     player.Session.Send(ClubPacket.UpdateClub(this));
     BroadcastPacketClub(ClubPacket.UpdatePlayer(member, this));
 }
Пример #2
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));
            }
        }