Пример #1
0
            /// <summary>
            /// Gets the team a player in the queue is queueing for.
            /// </summary>
            /// <param name="slot">Slot to check.</param>
            /// <returns>Team that the player is queueing for.</returns>
            /// <exception cref="InvalidSlotException">Thrown if slot argument is out of range.</exception>
            public QueueTeam GetQueueTeam(int slot)
            {
                if (slot < Queueid || slot > Queueid + 5)
                {
                    throw new InvalidSlotException(string.Format("Slot argument '{0}' is out of range.", slot));
                }
                Point check = cg.Interact.FindSlotLocation(slot);

                check.X -= 25;
                cg.updateScreen();
                Color color = cg.GetPixelAt(check.X, check.Y);

                // If the blue color is greater than the red color, the queue slot is on blue team.
                if (color.B > color.R)
                {
                    return(QueueTeam.Blue);
                }
                // If the green color is less than 90, the queue slot is on the red team.
                else if (color.G < 90)
                {
                    return(QueueTeam.Red);
                }
                // Else, the queue slot is on neutral team.
                else
                {
                    return(QueueTeam.Neutral);
                }
            }
            private void ExitMoveMenu()
            {
                cg.updateScreen();

                /*
                 * if (cg.CompareColor(717, 180, new int[] { 160, 124, 80 }, 30)) cg.LeftClick(717, 183, 25); // with add AI button
                 * else cg.LeftClick(660, 180, 25); // without add AI button
                 */

                Color color = cg.GetPixelAt(661, 175);

                if (color.R - color.B > 40)
                {
                    cg.LeftClick(660, 175, 25);
                }
                else
                {
                    cg.LeftClick(717, 175, 25);
                }

                cg.ResetMouse();
            }
Пример #3
0
            /// <summary>
            /// Gets the difficulty of the AI in the input slot.
            /// <para>If the input slot is not an AI, returns null.
            /// If checking an AI's difficulty in the queue, it will always return easy, or null if it is a player.</para>
            /// </summary>
            /// <param name="slot">Slot to check</param>
            /// <param name="noUpdate"></param>
            /// <returns>Returns a value in the Difficulty enum if the difficulty is found. Returns null if the input slot is not an AI.</returns>
            /// <exception cref="InvalidSlotException">Thrown when slot is out of range.</exception>
            public Difficulty?GetAIDifficulty(int slot, bool noUpdate = false)
            {
                if (!cg.IsSlotValid(slot))
                {
                    throw new InvalidSlotException(string.Format("Slot {0} is out of range of possible slots to check for AI.", slot));
                }

                if (slot == 5 && cg.OpenChatIsDefault)
                {
                    cg.Chat.CloseChat();
                }

                if (!noUpdate)
                {
                    cg.updateScreen();
                }

                if (cg.IsSlotBlue(slot) || cg.IsSlotRed(slot))
                {
                    bool draw = cg.debugmode;                       // For debug mode

                    List <int>        rl = new List <int>();        // Likelyhood in percent for difficulties.
                    List <Difficulty> dl = new List <Difficulty>(); // Difficulty

                    bool foundWhite      = false;
                    int  foundWhiteIndex = 0;
                    int  maxWhite        = 3;
                    // For each check length in IsAILocations
                    for (int xi = 0; xi < DifficultyLocations[slot, 2] && foundWhiteIndex < maxWhite; xi++)
                    {
                        if (foundWhite)
                        {
                            foundWhiteIndex++;
                        }

                        Color cc = cg.GetPixelAt(DifficultyLocations[slot, 0] + xi, DifficultyLocations[slot, 1]);
                        // Check for white color of text
                        if (cg.CompareColor(DifficultyLocations[slot, 0] + xi, DifficultyLocations[slot, 1], CALData.WhiteColor, 110) &&
                            (slot > 5 || cc.B - cc.R < 20))
                        {
                            foundWhite = true;

                            // For each difficulty markup
                            for (int b = 0; b < DifficultyMarkups.Length; b++)
                            {
                                Bitmap tmp = null;
                                if (draw)
                                {
                                    tmp = cg.BmpClone(0, 0, cg.bmp.Width, cg.bmp.Height);
                                }

                                // Check if bitmap matches checking area
                                double success = 0;
                                double total   = 0;
                                for (int x = 0; x < DifficultyMarkups[b].Width; x++)
                                {
                                    for (int y = DifficultyMarkups[b].Height - 1; y >= 0; y--)
                                    {
                                        // If the color pixel of the markup is not white, check if valid.
                                        Color pc = DifficultyMarkups[b].GetPixel(x, y);
                                        if (pc != Color.FromArgb(255, 255, 255, 255))
                                        {
                                            // tc is true if the pixel is black, false if it is red.
                                            bool tc = pc == Color.FromArgb(255, 0, 0, 0);

                                            total++; // Indent the total
                                                     // If the checking color in the bmp bitmap is equal to the pc color, add to success.
                                            if (cg.CompareColor(DifficultyLocations[slot, 0] + xi + x, DifficultyLocations[slot, 1] - Extensions.InvertNumber(y, DifficultyMarkups[b].Height - 1), CALData.WhiteColor, 50) == tc)
                                            {
                                                success++;

                                                if (draw)
                                                {
                                                    if (tc)
                                                    {
                                                        tmp.SetPixel(DifficultyLocations[slot, 0] + xi + x, DifficultyLocations[slot, 1] - Extensions.InvertNumber(y, DifficultyMarkups[b].Height - 1), Color.Blue);
                                                    }
                                                    else
                                                    {
                                                        tmp.SetPixel(DifficultyLocations[slot, 0] + xi + x, DifficultyLocations[slot, 1] - Extensions.InvertNumber(y, DifficultyMarkups[b].Height - 1), Color.Lime);
                                                    }
                                                }
                                            }
                                            else if (draw)
                                            {
                                                if (tc)
                                                {
                                                    tmp.SetPixel(DifficultyLocations[slot, 0] + xi + x, DifficultyLocations[slot, 1] - Extensions.InvertNumber(y, DifficultyMarkups[b].Height - 1), Color.Red);
                                                }
                                                else
                                                {
                                                    tmp.SetPixel(DifficultyLocations[slot, 0] + xi + x, DifficultyLocations[slot, 1] - Extensions.InvertNumber(y, DifficultyMarkups[b].Height - 1), Color.Orange);
                                                }
                                            }

                                            if (draw)
                                            {
                                                tmp.SetPixel(DifficultyLocations[slot, 0] + xi + x, DifficultyLocations[slot, 1] - DifficultyMarkups[b].Height * 2 + y, DifficultyMarkups[b].GetPixel(x, y));
                                                cg.g.DrawImage(tmp, new Rectangle(0, -750, tmp.Width * 3, tmp.Height * 3));
                                                Thread.Sleep(1);
                                            }
                                        }
                                    }
                                }
                                // Get the result
                                double result = (success / total) * 100;

                                rl.Add((int)result);
                                dl.Add((Difficulty)b);

                                if (draw)
                                {
                                    tmp.SetPixel(DifficultyLocations[slot, 0] + xi, DifficultyLocations[slot, 1], Color.MediumPurple);
                                    cg.g.DrawImage(tmp, new Rectangle(0, -750, tmp.Width * 3, tmp.Height * 3));
                                    Console.WriteLine((Difficulty)b + " " + result);
                                    Thread.Sleep(1000);
                                }
                            }
                        }
                    }

                    if (slot == 5 && cg.OpenChatIsDefault)
                    {
                        cg.Chat.OpenChat();
                    }

                    // Return the difficulty that is most possible.
                    if (rl.Count > 0)
                    {
                        int max = rl.Max();
                        if (max >= 75)
                        {
                            return(dl[rl.IndexOf(max)]);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }

                else if (cg.QueueCount > 0)
                {
                    int y = DifficultyLocationsQueue[slot - Queueid];
                    for (int x = DifficultyLocationQueueX; x < 150 + DifficultyLocationQueueX; x++)
                    {
                        if (cg.CompareColor(x, y, new int[] { 180, 186, 191 }, 10))
                        {
                            return(null);
                        }
                    }
                    return(Difficulty.Easy);
                }

                else
                {
                    return(null);
                }
            }