示例#1
0
 public TableData(TableData old)
 {
     initialize();
     error = old.error;
     players = old.players;
     myPos = old.myPos;
     for (int i = 0; i < 10; i++)
     {
         stacks[i] = old.stacks[i];
         bets[i] = old.bets[i];
     }
     dealerPos = old.dealerPos;
     for (int i = 0; i < 2; i++)
         handCards[i] = old.handCards[i];
     handIndex = -1;
     for (int i = 0; i < 5; i++)
         boardCards[i] = old.boardCards[i];
     noSB = old.noSB;
     BBindex = old.BBindex;
     BBsize = old.BBsize;
     errorStr = old.errorStr;
     allinIndex = old.allinIndex;
     tableType = old.tableType;
     casinoname = old.casinoname;
     SelectedAction = old.SelectedAction;
 }
示例#2
0
        /*
        protected Point[][] stackpos;
        protected Color[] stackcolors;
        protected Point[] betpos;
        protected Color betcolor;
        protected int[][] dealercheck;

        protected int stackxcount;
        protected int betxcount;
        protected int stackwidth;
        protected int stackheight;
        */
        /**
         * @param name="aBlindStruct" blindi structure
         * @param name="aStackPos" stackien paikka. Koottu siten, että taulukossa on
         * listoja mahdollisista positioista. Taulukon indeksi määrää mistä pelaajasta kyse.
         */
        public PokerTable(IntPtr ihwnd)
        {
            img = new OwnImage();
            data = new TableData();
            this.hwnd = ihwnd;
            if (hwnd.ToInt64() < 0)
                isReadFromWindow = false;
            casinoname = "";

            //System.IO.FileStream joo = new System.IO.FileStream(
        }
示例#3
0
 public TableFinder(PokerTable ireader)
 {
     reader = ireader;
     iData = new TableData();
     tableNames = new String[8];            
     tableHwnd = new IntPtr(-1);
     
     TableName2Hwnd = new Hashtable();
     BlindStruct = ireader.blindStruct;
     foundtables = new SortedDictionary<string,SortedDictionary<Int64,PokerTable>>();
     foundtables[partystr] = new SortedDictionary<Int64,PokerTable>();
     foundtables[starsstr] = new SortedDictionary<Int64,PokerTable>();
     foundtables[fulltiltstr] = new SortedDictionary<Int64, PokerTable>();
     iCasinoBlinds = new Dictionary<string,List<BlindInfo>>();
 }
示例#4
0
        public void readFromWindow(TableData iData)
        {
            Debug.WriteLine("readFromWindow 1");
            if (hwnd.ToInt32() == -1)
                return;
            Debug.WriteLine("readFromWindow 2");
            isReadFromWindow = true;
            img = new OwnImage();
            data = iData;
            // otetaan ikkunan sijainti muistiin
            Rectangle oldWindowRect = new Rectangle();
            User32.GetWindowRect(hwnd, ref oldWindowRect);

            // minimoidaan ja suurennetaan ikkuna Partyn grafiikkavirheiden takia
            try
            {
                Debug.WriteLine("readFromWindow 3");
                firsttry = true;
                takeScreenShot();
                Debug.WriteLine("readFromWindow 4");
                firsttry = false;
                mainReader();
                Debug.WriteLine("readFromWindow 5");
            }
            finally
            {
                uint flag = 0;

                if (User32.SupportPrintWindow())
                    flag = 4; //no zorder
                    //flag = 0;

                // Pienennetään pöytä siihen mikä se oli ennen
                oldWindowRect.Width -= oldWindowRect.X;
                oldWindowRect.Height -= oldWindowRect.Y;
                User32.SetWindowPos(hwnd, new IntPtr(-2), oldWindowRect.X, oldWindowRect.Y, oldWindowRect.Width, oldWindowRect.Height, flag);
                AfterResize(oldWindowRect);
            }
        }
示例#5
0
 public void readFromImage(string imageFileName, TableData iData)
 {
     isReadFromWindow = false;
     data = iData;
     img.LoadImage(imageFileName);
     mainReader();
 }
示例#6
0
        // Handles game data parsing moves dealer to 0 position and checks stacks
        public void parseGame(TableData oData) 
        {
            oData.error = iData.error;
            oData.errorStr = iData.errorStr;
            if (iData.error != 0)
                return;
            Debug.WriteLine("\n************************************************\n");
            

            // Check for serious errors

            //  postflop
            if (iData.boardCards[0] >= 0 || iData.boardCards[1] >= 0)
            {
                oData.error = 1;
                oData.errorStr = "This program is only useful in preflop. Can't continue.";
                return;
            }

            // Couldn't find own position
            if (iData.myPos < 0)
            {
                oData.error = 3;
                oData.errorStr = "Couldn't find own position. Can't continue.";
                
                return;
            }

            if (iData.BBindex < 0)
            {
                oData.error = 2;
                oData.errorStr = "Couldn't find blind size. Can't continue";
                return;
            }
            
            if (iData.dealerPos < 0)
            {
                oData.error = 3;
                oData.errorStr = "Couldn't find dealer position. Can't continue.";
                return;
            }


            Debug.WriteLine("Starting point:");
            for (int i = 0; i < 10; i++)
            {
                Console.Write("{0}\t{1}\t{2}", i, iData.stacks[i], iData.bets[i]);
                if (i == iData.myPos)
                    Console.Write(" me");
                if (i == iData.dealerPos)
                    Console.Write(" dealer ");
                Debug.WriteLine("");
            }
            Debug.WriteLine("");
           
            int BBsize = blindIndextoSize(iData.BBindex);
            
            // Count player amount
            int playersCount = 0;
            for (int i = 0; i < 10; i++)
                if (iData.bets[i] > 0 || iData.stacks[i] > 0)
                    playersCount++;

            // Put players to two dimensional table, dealer at position 0
            
            int POS    = 0; // position on table 0-9            
            int STACK  = 1;
            int BET    = 2;            

            int[,] tmpPlayers = new int[playersCount, 3];
            int index = 0;
            for (int i = iData.dealerPos; i < 10; i++)
            {
                if (iData.bets[i] > 0 || iData.stacks[i] > 0)
                {
                    tmpPlayers[index, POS] = i;
                    if (iData.stacks[i] > -1)
                        tmpPlayers[index, STACK] = iData.stacks[i];
                    if (iData.bets[i] > -1)
                        tmpPlayers[index, BET] = iData.bets[i];
                    index++;
                }
            }
            if (iData.dealerPos > 0)
            {
                for (int i = 0; i < iData.dealerPos; i++)
                {
                    if (iData.bets[i] > 0 || iData.stacks[i] > 0)
                    {
                        tmpPlayers[index, POS] = i;
                        if (iData.stacks[i] > -1)
                            tmpPlayers[index, STACK] = iData.stacks[i];
                        if (iData.bets[i] > -1)
                            tmpPlayers[index, BET] = iData.bets[i];
                        index++;
                    }
                }
            }
            

            Debug.WriteLine("tmpPlayers: button first");
            for (int i = 0; i < playersCount; i++)
                Debug.WriteLine("{0}\t{1}\t{2}", tmpPlayers[i, POS], tmpPlayers[i, STACK], tmpPlayers[i, BET]);
            

            int[] oldPos = new int[10]; // Here we store old indexes
            int myNewIndex = 0;         // .. so that we can get our own index in oData table

            // two players -> small blind is button
            if (playersCount == 2)
            {
                // if we are button we are in push mode
                if (iData.dealerPos == iData.myPos)
                {
                    oData.mode = true;  // push
                    oData.stacks[0] = tmpPlayers[1, STACK] + tmpPlayers[1, BET] + anteSize(iData.BBindex); //opp
                    oData.stacks[1] = tmpPlayers[0, STACK] + tmpPlayers[0, BET] + anteSize(iData.BBindex); //me
                }
                // otherwise opponent may have gone all-in
                else
                {
                    // If opponent has gone all-in
                    if (tmpPlayers[0, STACK] == 0)
                    {
                        oData.allinIndex = 1;
                        oData.mode = false;  // call
                        oData.stacks[0] = tmpPlayers[1, STACK] + tmpPlayers[1, BET] + anteSize(iData.BBindex);
                        oData.stacks[1] = tmpPlayers[0, STACK] + tmpPlayers[0, BET] + anteSize(iData.BBindex);
                    }
                    // No all-in -> set error code
                    else
                    {
                        oData.allinIndex = 1;
                        oData.mode = false;  // call
                        oData.stacks[0] = tmpPlayers[1, STACK] + tmpPlayers[1, BET] + anteSize(iData.BBindex);
                        oData.stacks[1] = tmpPlayers[0, STACK] + tmpPlayers[0, BET] + anteSize(iData.BBindex);
                        oData.error = 11;
                        oData.errorStr = "There is less than all in sized bet. Can't continue.";
                    }
                }
            }
            
            // More than 2 players
            else
            {
                // Index 1 and 2 contains small blind and big blind
                int SBpos = 1;
                int BBpos = 2;
                bool foundBBpos = false;
                
                // Check for big blind                                
                if (tmpPlayers[BBpos, BET] > 0 && tmpPlayers[BBpos, BET] <= BBsize)
                {
                    Debug.WriteLine("Iso blindi löydettiin");
                    foundBBpos = true;
                }

                //If normal big blind hasn't paid anything, player next to dealer 
                //is only blind payer (Partys nosb)
                if (foundBBpos == false && !iData.noSB)
                {
                    BBpos = SBpos;
                    oData.noSB = true;
                }

                Debug.WriteLine("BBpos: {0} oData.noSB: {1}", BBpos, oData.noSB);

                // Put stacks and blinds to result object by goind counterclockwise                
                index = 0;
                for (int i = BBpos; i >= 0; i--)
                {
                    oldPos[index] = tmpPlayers[i, POS];
                    oData.stacks[index] = tmpPlayers[i, STACK] + tmpPlayers[i, BET] + anteSize(iData.BBindex);
                    oData.bets[index] = tmpPlayers[i, BET];
                    index++;
                }
                if (BBpos < playersCount - 1)
                {
                    for (int i = playersCount - 1; i > BBpos; i--)
                    {
                        oldPos[index] = tmpPlayers[i, POS];
                        oData.stacks[index] = tmpPlayers[i, STACK] + tmpPlayers[i, BET] + anteSize(iData.BBindex);
                        oData.bets[index] = tmpPlayers[i, BET];
                        index++;
                    }
                }

                // Search our own position from tables
                for (int i = 0; i < 10; i++)
                {
                    if (oldPos[i] == iData.myPos)
                    {
                        myNewIndex = i;                        
                        break;
                    }
                }
            }

            Debug.WriteLine("\nMy new index: {0}", myNewIndex);
            Debug.WriteLine("\noData.stacks:");
            for (int i = 0; i < playersCount; i++)
                Debug.WriteLine("{0}\t{1}\t{2}", i, oData.stacks[i], oData.bets[i]);
            

            // Set remaining table data
            if (iData.BBindex >= 0)
                oData.BBindex = iData.BBindex;
            else
                oData.BBindex = 0;
            oData.BBsize = BBsize;
            for (int i = 0; i < 5; i++)
                oData.boardCards[i] = iData.boardCards[i];
            oData.handCards[0] = iData.handCards[0];
            oData.handCards[1] = iData.handCards[1];
            oData.handIndex = indexFromHand(iData.handCards);
            oData.myPos = myNewIndex;
            oData.players = playersCount;
            oData.tableType = iData.tableType;

            
            if (playersCount > 2)
            {
                // // If we are first to act, we surely are in PUSH-mode
                if (playersCount - 1 == myNewIndex)
                    oData.mode = true;
                else
                {
                    //Go table from UTG towards our own position. If we came to our own position without all-in 
                    //we are in push mode else call

                    int i = 0;
                    int limpersOrRaisers = 0;
                    int allins = 0;
                    for (i = playersCount - 1; i > myNewIndex; i--)
                    {
                        //Opponent wen't all-in
                        if (oData.bets[i] >= 0 && oData.bets[i] + anteSize(iData.BBindex) == oData.stacks[i])
                        {
                            allins++;
                            oData.allinIndex = i;
                        }

                        // opponent went all-in but didn't go allin
                        else if (oData.bets[i] > 0 && oData.bets[i] + anteSize(iData.BBindex) < oData.stacks[i])
                        {
                            //If bet is smaller than big blind and bet maker still has stack, small blind folded                                                        
                            if (oData.bets[i] < BBsize && i == 1)
                                continue;

                            // Limping 
                            limpersOrRaisers++;
                            if(oData.allinIndex < 0)
                                oData.allinIndex = i;  // Set all-in index to better. THIS IS WRONG!!!!!!
                        }
                        
                    }
                    // limpers -> can't calculate
                    if (limpersOrRaisers > 0)
                    {
                        oData.error = 12;
                        BlindInfo blind = BlindStruct[iData.BBindex];

                        oData.errorStr = "There is limpers or less than all in sized bet. Can't continue.";
                        oData.mode = true;
                    }
                    // no limpers, but one all-in, can be calculated in call-mode
                    else if (limpersOrRaisers == 0 && allins == 1)
                    {
                        oData.mode = false;
                    }
                    // multiple all-ins can't calculate
                    else if (allins > 1)
                    {
                        oData.error = 13;
                        oData.errorStr = "There is more than one all in. Can't continue.";
                        oData.mode = false;
                    }
                    // No limpers, or all-ins  -> push mode
                    else if (allins == 0 && limpersOrRaisers == 0)
                        oData.mode = true;
                }
            }

            // Own cards not found
            if (iData.handCards[0] < 0 || iData.handCards[1] < 0)
            {
                oData.handIndex = 0; // AA oletuksena
                oData.error = 14;
                oData.errorStr = "Couldn't recognize cards. Can't continue.";
            }

            // Unable to determine blind size
            else if (iData.BBindex < 0)
            {
                oData.BBindex = 0; // 20/40 oletuksena
                oData.error = 15;
                oData.errorStr = "Couldn't find blind size. Can't continue.";             
            }

            // There has to be more than 2 players
            else if (oData.players < 2)
            {                
                oData.error = 4;
                oData.errorStr = "Couldn't find player count. Can't continue.";
            }

            // Sum of chips doesn't match
            int chipSum = 0;
            for (int i = 0; i < 10; i++)
                if (oData.stacks[i] > 0)
                    chipSum += oData.stacks[i];
           
            float chipsPerPlayer = chipSum / oData.tableType;
            if (chipsPerPlayer != 1500 && chipsPerPlayer != 2000 && chipsPerPlayer != 300)
            {
                Debug.WriteLine("oData.tableType: {0} chipSum: {1}", oData.tableType, chipSum);

                // Error is serious, if none of the stacks can be read
                if (chipSum == 0)
                {
                    oData.error = 5;
                    oData.errorStr = "Couldn't find any stack size. Can't continue.";
                }
                // ... and less serious if we got something
                else
                {
                    oData.error = 16;
                    oData.errorStr = "Couldn't find all stacks sizes. Can't continue.";
                }
            }


            // Print all calculated infos
            Debug.WriteLine("\noData.error: {0}", oData.error);
            Debug.WriteLine("oData.errorStr: {0}", oData.errorStr);
            Debug.WriteLine("oData.mode: {0}", oData.mode);
            Debug.WriteLine("oData.myPos: {0}", oData.myPos);
            Debug.WriteLine("handCards: {0} {1}", oData.handCards[0], oData.handCards[1]);
            Debug.WriteLine("handIndex: {0}", oData.handIndex);
            Debug.WriteLine("noSB: {0}", oData.noSB);
            Debug.WriteLine("BBsize: {0}", oData.BBsize);
            Debug.WriteLine("BBindex: {0}", oData.BBindex);
            Debug.WriteLine("allinIndex: {0}", oData.allinIndex);
            Debug.WriteLine("Stacks:");
            for (int i = 0; i < playersCount; i++)
                Debug.WriteLine("{0}\t{1}", i, oData.stacks[i], oData.bets[i]);
        }
示例#7
0
        // Gets tables information to oData         
        public void getTableData(ref TableData oData, PokerTable table)
        {

            iData = new TableData();
            table.readFromWindow(iData);
  
            parseGame(oData);
        }
示例#8
0
        //Internal debugging function which loads specified image
        public void getTableData(ref TableData oData, string filename)
        {
            if (filename == "From oData")
                iData = new TableData(oData);
            else
                iData = new TableData();
                       
            oData = new TableData();            

            if (filename != "From oData" && filename != "")
                reader.readFromImage(filename, iData);

            parseGame(oData);
        }
示例#9
0
文件: SNGEGT.cs 项目: stephica/SNGEGT
        // asettaa komponentit ja tekee laskut joko avatun tiedostonimen tai listaindeksi mukaan
        private void setFormsAndDoCalc(bool readFromPPlist, String fileName)
        {
            if (readFromPPlist && (listBoxTables.SelectedIndex == -1))
                return;

            PokerTable table = null;

            try
            {
                fillingform = true;
                pictureBox1.Image = null;
                labelWarning.Text = "";
                String searchfor = "";

                TableData data = new TableData();

                // getTableData(partyTableData oData, string tableNameStr, int iHwndIndex, string fileName)

                if (readFromPPlist)
                {
                    table = (PokerTable)listBoxTables.SelectedItem;
                    searchfor = table.getCasinoName();
                }
                else if (fileName != "")
                {

                    party.getTableData(ref data, fileName);
                    searchfor = iCasinoName;
                }
                else
                {
                    pictureBox1.Image = SystemIcons.Warning.ToBitmap();
                    labelWarning.Text = "Can't find a game";
                    return;
                }
                if (searchfor != "")
                {
                    comboBoxCasinos.SelectedIndex = -1;
                    for (int i = 0; i < comboBoxCasinos.Items.Count; i++)
                        if ((string)comboBoxCasinos.Items[i] == searchfor)
                        {
                            comboBoxCasinos.SelectedIndex = i;

                            break;
                        }
                }

                if (table != null)
                {
                    table.SetBlindStruct(((BlindSaver)structures[searchfor]).blinds);
                    party.getTableData(ref data, table);
                }
                FillForm(data);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
                pictureBox1.Image = SystemIcons.Error.ToBitmap();
                labelWarning.Text = "Serious error when reading poker table.";
                //labelWarning.Text = e.ToString();
                //textBoxDebug.Text = e.ToString();
            }
            finally
            {

            }
        }
示例#10
0
文件: SNGEGT.cs 项目: stephica/SNGEGT
        private void FillForm(TableData data)
        {
            Image img = null;
            // Serious errors 1-10 -> end
            if (data.error >= 1 && data.error <= 10)
            {
                pictureBox1.Image = SystemIcons.Warning.ToBitmap();
                labelWarning.Text = data.errorStr;
                return;
            }

            fillingform = true;

            for (int i = 0; i < 10; i++)
            {
                game.players[i].chips.Text = "0";
                game.players[i].bets.Text = "0";
            }
            for (int i = 0; i < data.players; i++)
            {
                if (data.stacks[i] >= 0)
                    game.players[i].chips.Text = Convert.ToString(data.stacks[i]);
                else
                    game.players[i].chips.Text = "";
            }

            if (data.mode == true)
                radioButtonPush.Checked = true;
            else
                radioButtonCall.Checked = true;

            //Search for struct where there is wanted amount of players
            for (int i = 0; i < blindstruct.awards.Count; i++)
            {
                if (blindstruct.awards[i].playercount == data.tableType)
                {
                    for (int j = 0; j < comboBoxGame.Items.Count; j++)
                        if (blindstruct.awards[i] == comboBoxGame.Items[j])
                        {
                            comboBoxGame.SelectedIndex = j;
                            break;
                        }
                    break;
                }
            }

            comboBoxPlayers.SelectedIndex = data.players - 2;
            comboBoxHand.SelectedIndex = data.handIndex;
            comboBoxBlinds.SelectedIndex = data.BBindex;
            checkBoxNoSB.Checked = data.noSB;
            game.players[data.myPos].position.Checked = true;
            game.players[data.allinIndex].allin.Checked = true;

            if (data.error <= 0)
            {
                fillingform = false;
                Gameinfo_Changed(this, null);
            }
            // Less serious errors
            else
            {
                // callers
                if (data.error == 11 && data.BBindex >= 0)
                {
                    BlindInfo info = (BlindInfo)(comboBoxBlinds.SelectedItem);
                    for (int i = 0; i < 10; i++)
                        if (data.stacks[i] > 0)
                            game.players[i].bets.Text = Convert.ToString((Math.Min(info.Ante, data.stacks[i])));

                    game.players[0].bets.Text = Convert.ToString(Math.Min(data.stacks[0], info.Ante + info.Bigblind));
                    if (!checkBoxNoSB.Checked)
                        game.players[1].bets.Text = Convert.ToString(Math.Min(data.stacks[1], info.Ante + info.Smallblind));
                }
                img = SystemIcons.Warning.ToBitmap();
            }

            fillingform = false;
            Gameinfo_Changed(this, null);

            pictureBox1.Image = img;
            labelWarning.Text = data.errorStr;
            Activate();
        }
示例#11
0
文件: SNGEGT.cs 项目: stephica/SNGEGT
        public void GameChanged(TableData data)
        {
            TableData temp = new TableData(data);
            if (temp.casinoname != "")
            {
                comboBoxCasinos.SelectedIndex = -1;
                for (int i = 0; i < comboBoxCasinos.Items.Count; i++)
                    if (comboBoxCasinos.Items[i].ToString() == temp.casinoname)
                    {
                        comboBoxCasinos.SelectedIndex = i;
                        break;
                    }
            }

            party.getTableData(ref temp, "From oData");
            FillForm(temp);
        }