예제 #1
0
        public Table identifyTable(Image tableImage, PlayerInfoEnum playerInfo, double defaultBet, int seat)
        {
            Table table = new Table();

            // community
            Log.Debug("# scanning cards");
            table.Community = cardPipe.process(tableImage, this);

            // dealer
            Log.Debug("# scanning dealer");
            table.Dealer = buttonPipe.process(tableImage, layout.Buttons, this);
            Log.Debug("dealer position " + table.Dealer);

            // pot
            Log.Debug("# scanning pot");
            table.Pot = potPipe.process(tableImage, layout.Pot, this);
            Log.Debug("pot size " + table.Pot);

            // seat
            table.Seat = seat;

            // players
            Log.Debug("# scanning player infos");
            List <Player> players = new List <Player>();

            for (int i = 0; i < layout.Names.Length; i++)
            {
                // new player
                Player player = new Player();
                players.Add(player);

                // name & money
                bool isMySeat = (i == seat);
                processTextBox(textPipe, player, tableImage, i, playerInfo, isMySeat);
                Log.Fine("name " + (i + 1) + " = " + (player.Name.Length == 0 ? "no name" : "'" + player.Name + "'"));

                // bet
                Image  betImage = crop(tableImage, layout.Bets[i]);
                double bet      = processBet(tableImage, betImage, layout.Bets[i], this, defaultBet);
                player.Bet = bet;
                Log.Fine("bet " + (i + 1) + " = " + (bet == -1 ? "no bet" : bet.ToString()));

                // small cards
                Image smallCardsImage = crop(tableImage, layout.SmallCards[i]);
                bool  hasCards        = smallCardsPipe.process(smallCardsImage, layout.SmallCards[i], this);
                processPlayerState(player, hasCards);
                Log.Fine("has cards " + (i + 1) + " = " + hasCards);
            }
            table.Players = players;

            return(table);
        }
예제 #2
0
        private void processTextBox(TextBoxPipeline pipe, Player info, Image table, int id, PlayerInfoEnum read, bool isMySeat)
        {
            try
            {
                if (read == PlayerInfoEnum.BOTH || read == PlayerInfoEnum.NAME)
                {
                    // textbox
                    Rectangle rect = layout.Names[id];
                    info.Position = id;
                    info.NameRect = rect;
                    Image         image     = crop(table, rect);
                    List <String> textLines = pipe.process(image, id, rect, this, isMySeat);
                    if (textLines.Count == 0)
                    {
                        info.State = Player.States.NON_EXISTENT;
                    }
                    else
                    {
                        if (!containsChars(textLines[0]))
                        {
                            info.State = Player.States.NON_EXISTENT;
                        }
                        else
                        {
                            info.State = Player.States.EXISTENT;
                            info.Name  = textLines[0];
                        }
                    }
                }

                if (read == PlayerInfoEnum.BOTH || read == PlayerInfoEnum.MONEY)
                {
                    // textbox
                    Rectangle rect = layout.Money[id];
                    info.Position  = id;
                    info.MoneyRect = rect;
                    Image         image     = crop(table, rect);
                    List <String> textLines = pipe.process(image, id, rect, this, isMySeat);

                    if (textLines.Count == 0)
                    {
                        info.State = Player.States.NON_EXISTENT;
                    }
                    else
                    {
                        if (!containsChars(textLines[0]))
                        {
                            info.State = Player.States.NON_EXISTENT;
                        }
                        else
                        {
                            info.State = Player.States.EXISTENT;
                            if (textLines[0].Contains("$"))
                            {
                                info.State = Player.States.EXISTENT;
                                info.Money = TextTools.ParseDouble(textLines[0].Replace("$", "").Trim());
                            }
                            else
                            {
                                info.Money = Player.NO_MONEY;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                Log.Warn("Unable to read player info (mode = " + read + ")");
            }
        }
예제 #3
0
 public Table identifyTable(Image tableImage, PlayerInfoEnum playerInfo)
 {
     return(identifyTable(tableImage, playerInfo, DEFAULT_BET, Table.NO_SEAT));
 }