public static void JoinArena(Entities.GameClient Player)
        {
            if (Player.Battle != null)
            {
                return;
            }
            if (Player.DynamicMap != null)
            {
                return;
            }
            if (Player.ArenaMatch != null)
            {
                return;
            }

            if (PlayerQueue.Contains(Player))
            {
                Player.Arena.Status = Enums.ArenaStatus.NotSignedUp;
                using (var wait = Player.Arena.Build())
                    Player.Send(wait);

                Player.Arena.Status = Enums.ArenaStatus.WaitingForOpponent;
                using (var wait = Player.Arena.Build())
                    Player.Send(wait);
            }
            else
            {
                Player.Arena.Status = Enums.ArenaStatus.WaitingForOpponent;
                using (var wait = Player.Arena.Build())
                    Player.Send(wait);
            }
            if (MatchQueue.Count > 0)
            {
                using (var matches = new Packets.ArenaBattleInfoPacket(MatchQueue.ToDictionary().Values.ToArray()))
                {
                    matches.Page = 1;
                    matches.SetSize();
                    Player.Send(matches);
                }
            }
            PlayerQueue.Add(Player);
            uint DelayedID = 0;

            DelayedID = ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() =>
            {
                if (HandleMatchUp(Player, FindMatchUp(Player)))
                {
                    ProjectX_V3_Lib.Threading.DelayedTask.Remove(DelayedID);
                }
            }, 10000, 0);
        }
Exemple #2
0
        /*
         * MemoryStream strm = new MemoryStream();
         * BinaryWriter wtr = new BinaryWriter(strm);
         * wtr.Write((ushort)0); 0
         * wtr.Write((ushort)2206); 2
         * wtr.Write((uint)page); 4
         * wtr.Write((uint)0x6); 8
         * wtr.Write((uint)Matches.Count); 12
         * wtr.Write((uint)PlayersInWaiting.Count); 16
         * wtr.Write((uint)0); 20
         * page--;
         * wtr.Write((uint)(Matches.Count - page)); 24
         * QualifierMatch[] GroupsList = Matches.ToArray();
         * for (int count = page; count < page + 6; count++)
         * {
         * if (count >= Matches.Count)
         *  break;
         *
         * QualifierMatch entry = GroupsList[count];
         *
         * wtr.Write((uint)entry.Player1.UID);
         * wtr.Write((uint)entry.Player1.Mesh);
         * for (int i = 0; i < 16; i++)
         * {
         *  if (i < entry.Player1.Name.Length)
         *  {
         *      wtr.Write((byte)entry.Player1.Name[i]);
         *  }
         *  else
         *      wtr.Write((byte)0);
         * }
         *
         * wtr.Write((uint)entry.Player1.Level);
         * wtr.Write((uint)entry.Player1.Profession);
         * wtr.Write((uint)0);
         * wtr.Write((uint)entry.Player1.ArenaStats.Rank);
         * wtr.Write((uint)entry.Player1.ArenaStats.ArenaPoints);
         * wtr.Write((uint)entry.Player1.ArenaStats.WinsToday);
         * wtr.Write((uint)entry.Player1.ArenaStats.LossesToday);
         * wtr.Write((uint)entry.Player1.ArenaStats.CurrentHonor);
         * wtr.Write((uint)entry.Player1.ArenaStats.TotalHonor);
         *
         * wtr.Write((uint)entry.Player2.UID);
         * wtr.Write((uint)entry.Player2.Mesh);
         * for (int i = 0; i < 16; i++)
         * {
         *  if (i < entry.Player2.Name.Length)
         *  {
         *      wtr.Write((byte)entry.Player2.Name[i]);
         *  }
         *  else
         *      wtr.Write((byte)0);
         * }
         *
         * wtr.Write((uint)entry.Player2.Level);
         * wtr.Write((uint)entry.Player2.Profession);
         * wtr.Write((uint)0);
         * wtr.Write((uint)entry.Player2.ArenaStats.Rank);
         * wtr.Write((uint)entry.Player2.ArenaStats.ArenaPoints);
         * wtr.Write((uint)entry.Player2.ArenaStats.WinsToday);
         * wtr.Write((uint)entry.Player2.ArenaStats.LossesToday);
         * wtr.Write((uint)entry.Player2.ArenaStats.CurrentHonor);
         * wtr.Write((uint)entry.Player2.ArenaStats.TotalHonor);
         * }
         * int packetlength = (int)strm.Length;
         * strm.Position = 0;
         * wtr.Write((ushort)packetlength);
         * strm.Position = strm.Length;
         * wtr.Write(Encoding.ASCII.GetBytes("TQServer"));
         * strm.Position = 0;
         * byte[] buf = new byte[strm.Length];
         * strm.Read(buf, 0, buf.Length);
         * wtr.Close();
         * strm.Close();*/

        public static void Handle(Entities.GameClient client, DataPacket packet)
        {
            //if (Data.ArenaQualifier.MatchQueue.Count > 0)
            //{
            Data.ArenaMatch[] matchesArray = null;
            if (Data.ArenaQualifier.MatchQueue.Count > 0)
            {
                matchesArray = Data.ArenaQualifier.MatchQueue.ToDictionary().Values.ToArray();

                if (matchesArray.Length > 10)
                {
                    Array.Resize(ref matchesArray, 10);
                }
            }
            using (var matches = new Packets.ArenaBattleInfoPacket(matchesArray))
            {
                matches.Page = packet.ReadUInt32(4);
                matches.SetSize();
                client.Send(matches);
            }
            //}
        }
        public static void JoinArena(Entities.GameClient Player)
        {
            if (Player.Battle != null)
                return;
            if (Player.DynamicMap != null)
                return;
            if (Player.ArenaMatch != null)
                return;

            if (PlayerQueue.Contains(Player))
            {

                Player.Arena.Status = Enums.ArenaStatus.NotSignedUp;
                using (var wait = Player.Arena.Build())
                    Player.Send(wait);

                Player.Arena.Status = Enums.ArenaStatus.WaitingForOpponent;
                using (var wait = Player.Arena.Build())
                    Player.Send(wait);
            }
            else
            {
                Player.Arena.Status = Enums.ArenaStatus.WaitingForOpponent;
                using (var wait = Player.Arena.Build())
                    Player.Send(wait);
            }
            if (MatchQueue.Count > 0)
            {
                using (var matches = new Packets.ArenaBattleInfoPacket(MatchQueue.ToDictionary().Values.ToArray()))
                {
                    matches.Page = 1;
                    matches.SetSize();
                    Player.Send(matches);
                }
            }
            PlayerQueue.Add(Player);
            uint DelayedID = 0;
            DelayedID = ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() =>
                                                                               {
                                                                               	if (HandleMatchUp(Player, FindMatchUp(Player)))
                                                                               	{
                                                                               		ProjectX_V3_Lib.Threading.DelayedTask.Remove(DelayedID);
                                                                               	}
                                                                               }, 10000, 0);
        }
        /*
            MemoryStream strm = new MemoryStream();
            BinaryWriter wtr = new BinaryWriter(strm);
            wtr.Write((ushort)0); 0
            wtr.Write((ushort)2206); 2
            wtr.Write((uint)page); 4
            wtr.Write((uint)0x6); 8
            wtr.Write((uint)Matches.Count); 12
            wtr.Write((uint)PlayersInWaiting.Count); 16
            wtr.Write((uint)0); 20
            page--;
            wtr.Write((uint)(Matches.Count - page)); 24
            QualifierMatch[] GroupsList = Matches.ToArray();
            for (int count = page; count < page + 6; count++)
            {
                if (count >= Matches.Count)
                    break;

                QualifierMatch entry = GroupsList[count];

                wtr.Write((uint)entry.Player1.UID);
                wtr.Write((uint)entry.Player1.Mesh);
                for (int i = 0; i < 16; i++)
                {
                    if (i < entry.Player1.Name.Length)
                    {
                        wtr.Write((byte)entry.Player1.Name[i]);
                    }
                    else
                        wtr.Write((byte)0);
                }

                wtr.Write((uint)entry.Player1.Level);
                wtr.Write((uint)entry.Player1.Profession);
                wtr.Write((uint)0);
                wtr.Write((uint)entry.Player1.ArenaStats.Rank);
                wtr.Write((uint)entry.Player1.ArenaStats.ArenaPoints);
                wtr.Write((uint)entry.Player1.ArenaStats.WinsToday);
                wtr.Write((uint)entry.Player1.ArenaStats.LossesToday);
                wtr.Write((uint)entry.Player1.ArenaStats.CurrentHonor);
                wtr.Write((uint)entry.Player1.ArenaStats.TotalHonor);

                wtr.Write((uint)entry.Player2.UID);
                wtr.Write((uint)entry.Player2.Mesh);
                for (int i = 0; i < 16; i++)
                {
                    if (i < entry.Player2.Name.Length)
                    {
                        wtr.Write((byte)entry.Player2.Name[i]);
                    }
                    else
                        wtr.Write((byte)0);
                }

                wtr.Write((uint)entry.Player2.Level);
                wtr.Write((uint)entry.Player2.Profession);
                wtr.Write((uint)0);
                wtr.Write((uint)entry.Player2.ArenaStats.Rank);
                wtr.Write((uint)entry.Player2.ArenaStats.ArenaPoints);
                wtr.Write((uint)entry.Player2.ArenaStats.WinsToday);
                wtr.Write((uint)entry.Player2.ArenaStats.LossesToday);
                wtr.Write((uint)entry.Player2.ArenaStats.CurrentHonor);
                wtr.Write((uint)entry.Player2.ArenaStats.TotalHonor);
            }
            int packetlength = (int)strm.Length;
            strm.Position = 0;
            wtr.Write((ushort)packetlength);
            strm.Position = strm.Length;
            wtr.Write(Encoding.ASCII.GetBytes("TQServer"));
            strm.Position = 0;
            byte[] buf = new byte[strm.Length];
            strm.Read(buf, 0, buf.Length);
            wtr.Close();
            strm.Close();*/
        public static void Handle(Entities.GameClient client, DataPacket packet)
        {
            //if (Data.ArenaQualifier.MatchQueue.Count > 0)
            //{
            Data.ArenaMatch[] matchesArray = null;
            if (Data.ArenaQualifier.MatchQueue.Count > 0)
            {
                matchesArray = Data.ArenaQualifier.MatchQueue.ToDictionary().Values.ToArray();

                if (matchesArray.Length > 10)
                    Array.Resize(ref matchesArray, 10);
            }
            using (var matches = new Packets.ArenaBattleInfoPacket(matchesArray))
            {
                matches.Page = packet.ReadUInt32(4);
                matches.SetSize();
                client.Send(matches);
            }
            //}
        }