Exemplo n.º 1
0
        private static bool IsAutoPostBlindsVisible(TableLayout layout, Image screenshot)
        {
            Image tableImage  = CropTable(screenshot, layout);
            Image blindsImage = tableImage.crop(layout.AutoBlindPattern.X, layout.AutoBlindPattern.X + layout.AutoBlindPattern.Width,
                                                layout.AutoBlindPattern.Y, layout.AutoBlindPattern.Y + layout.AutoBlindPattern.Height);

            return(PatternLocator.locateAutoPostBlinds(blindsImage));
        }
Exemplo n.º 2
0
        public TableContainer LocateNewTable(Settings settings)
        {
            Log.Info("## scanning for tables ##");

            // find offset
            Iterator <Image> screen      = new ScreenImageIterator(deviceControl);
            Image            screenshot  = screen.next();
            Point            foundOffset = PatternLocator.locateUnknownTable(screenshot, Offsets(knownTables), new TableLayout9());

            if (foundOffset == Point.Empty)
            {
                Log.Error("No table found");
                throw new ArgumentException("No table found");
            }

            // check for new table and find seat
            Image cornerTopLeft     = CropTableTopLeftCorner(screenshot, foundOffset);
            Image cornerBottomRight = CropTableBottomRightCorner(screenshot, foundOffset);

            if (!IsOffsetKnown(foundOffset))
            {
                // corner
                Log.Info("unknown table found at x=" + foundOffset.X + " y=" + foundOffset.Y);
                TableLayout layout = new TableLayout9(foundOffset);

                // find seat
                string player = settings.Name;
                Log.Info("looking for '" + player + "' on table" + (knownTables.Count + 1));
                int seat = -1;
                for (int tries = 0; tries < 3; tries++)
                {
                    Table previousTable = tableIdentifier.identifyTableForLocation(CropTable(screen.next(), layout));
                    seat = BotAppLogic.IdentifySeat(previousTable, player);
                    if (seat != -1)
                    {
                        break;
                    }
                    Thread.Sleep(500);
                }
                if (seat == -1)
                {
                    Log.Error("Cannot find player position on table " + (knownTables.Count + 1));
                    throw new ArgumentException("Cannot find player position on table " + (knownTables.Count + 1));
                }
                Log.Info("my seat on new table " + (knownTables.Count + 1) + " is " + (seat + 1));

                // blinds
                Image tableImage  = CropTable(screenshot, layout);
                Image blindsImage = tableImage.crop(layout.AutoBlindPattern.X, layout.AutoBlindPattern.X + layout.AutoBlindPattern.Width,
                                                    layout.AutoBlindPattern.Y, layout.AutoBlindPattern.Y + layout.AutoBlindPattern.Height);
                bool isFast = !PatternLocator.locateAutoPostBlinds(blindsImage);

                // container
                TableContainer table = new TableContainer(knownTables.Count, cornerTopLeft, cornerBottomRight, layout, seat, isFast, LobbyTable.Empty);
                knownTables.Add(table);
                return(table);
            }
            else
            {
                throw new Exception("No unknown table found");
            }
        }