Esempio n. 1
0
            /// <summary>
            /// Safely removes a slot from the game if they are an AI.
            /// </summary>
            /// <param name="slot">Slot to remove from game.</param>
            /// <returns>Returns true if the slot is an AI and removing them from the game was successful.</returns>
            public bool RemoveFromGameIfAI(int slot)
            {
                if (!cg.IsSlotValid(slot))
                {
                    throw new InvalidSlotException(string.Format("Slot {0} is out of range of possible slots to remove from game.", slot));
                }

                Point slotLocation = cg.Interact.OpenSlotMenu(slot);

                if (slotLocation.IsEmpty)
                {
                    return(false);
                }

                if (cg.Interact.MenuOptionScan(slotLocation, CG_Interact.RemoveAllBotsMarkup, 80, 6).IsEmpty)
                {
                    cg.CloseOptionMenu();
                    return(false);
                }

                Point removeFromGameOptionLocation = cg.Interact.MenuOptionScan(slotLocation, CG_Interact.RemoveFromGameMarkup, 80, 6);

                if (removeFromGameOptionLocation.IsEmpty)
                {
                    cg.CloseOptionMenu();
                    return(false);
                }

                return(cg.Interact.SelectMenuOption(removeFromGameOptionLocation));
            }
            /// <summary>
            /// Scans a player menu for an option.
            /// </summary>
            /// <param name="slot">Slot's menu to scan.</param>
            /// <param name="markup">Bitmap markup of option to scan for.</param>
            /// <param name="minimumPercent">Minimum percent the markup has to match an option in the menu.</param>
            /// <param name="max">Maximum options to scan.</param>
            /// <param name="yincrement">Amount to skip on Y axis after every markup scan.</param>
            /// <returns>Returns true if the option in the markup has been found, else returns false.</returns>
            /// <exception cref="InvalidSlotException">Thrown if slot argument is out of range.</exception>
            public bool MenuOptionScan(int slot, Bitmap markup, int minimumPercent, int max, double yincrement = 11.5)
            {
                if (!cg.IsSlotValid(slot))
                {
                    throw new InvalidSlotException(string.Format("Slot {0} is out of range.", slot));
                }

                Point slotlocation = OpenSlotMenu(slot);

                if (slotlocation.IsEmpty)
                {
                    return(false);
                }

                Point optionLocation = MenuOptionScan(slotlocation, markup, minimumPercent, max, yincrement);

                if (optionLocation.IsEmpty)
                {
                    cg.CloseOptionMenu();
                    return(false);
                }
                else
                {
                    SelectMenuOption(optionLocation);
                    return(true);
                }
            }