Ejemplo n.º 1
0
        public void unreserve(Client c, string tableId)
        {
            NoLimitHoldem table = find(tableId);

            if (table == null)
            {
                return;
            }
            string test = c.reservedTables.Find(delegate(string str) { return(str == tableId); });

            if (test == null)
            {
                return;
            }
            c.reservedTables.Remove(tableId);
            int i = 0;

            for (i = 0; i < table.tableData.reservedUserName.Length; i++)
            {
                if (table.tableData.reservedUserName[i] == c.Username)
                {
                    table.tableData.reservedUserName[i] = null;
                }
            }
            table.TableRelease(
                new string[] { "type", "msgtype", "pos", "tableId" },
                new string[] { "srvmsg", "ursv", i.ToString(), table.tableId }
                );
        }
Ejemplo n.º 2
0
        public void loadGames()
        {
            //here we initialize table and tournoments
            int tableName, tableId, seatsCount, MaxBuyin, MinBuyin, BigBlind;
            int index;

            SqlDataReader reader = Globals.DB.getNLHoldemTables();

            tableName  = reader.GetOrdinal("tableName");
            tableId    = reader.GetOrdinal("tableId");
            seatsCount = reader.GetOrdinal("seatsCount");
            MaxBuyin   = reader.GetOrdinal("MaxBuyin");
            MinBuyin   = reader.GetOrdinal("MinBuyin");
            BigBlind   = reader.GetOrdinal("BigBlind");

            NoLimitedHoldemTables = new NoLimitHoldem[0];
            while (reader.Read())
            {
                Array.Resize(ref NoLimitedHoldemTables, NoLimitedHoldemTables.Length + 1);
                index = NoLimitedHoldemTables.Length - 1;
                NoLimitedHoldemTables[index] = new NoLimitHoldem(
                    reader.GetString(tableId),
                    Convert.ToString(reader.GetValue(tableName)),
                    reader.GetInt32(seatsCount),
                    (float)reader.GetDouble(MinBuyin),
                    (float)reader.GetDouble(MaxBuyin),
                    (float)reader.GetDouble(BigBlind));
            }
        }
Ejemplo n.º 3
0
        public void sendTableData(Client c, string tableId)
        {
            NoLimitHoldem table = find(tableId);

            if (table != null)
            {
                table.sendTableData(c);
            }
        }
Ejemplo n.º 4
0
        public void addWatcher(Client c, string tableId)
        {
            NoLimitHoldem table = find(tableId);

            if (table != null)
            {
                table.addWatcher(c);
            }
        }
Ejemplo n.º 5
0
        public void Call(Client c, string tableId)
        {
            NoLimitHoldem table = find(tableId);

            if (table == null)
            {
                c.Kill(); return;
            }

            if (!table.isHisPos(c))
            {
                return;
            }

            table.tableData.currentAct.action = pokerActions.Call;
        }
Ejemplo n.º 6
0
        public void SitUp(Client c, string tableId, int pos)
        {
            NoLimitHoldem table = find("tableId");

            if (table != null)
            {
                c.Kill();
                return;
            }
            if (table.playerData[pos].client != c)
            {
                float addingChip = table.playerData[pos].Chips;
                table.sitUp(pos);
                c.incBalance(addingChip);
            }
        }
Ejemplo n.º 7
0
        public void Check(Client c, string tableId)
        {
            NoLimitHoldem table = find(tableId);

            if (table == null)
            {
                c.Kill(); return;
            }

            if (!table.isHisPos(c))
            {
                return;
            }

            if (table.tableData.toCall != 0)
            {
                c.Kill(); return;
            }
        }
Ejemplo n.º 8
0
        public void Bet(Client c, string tableId, int betAmount)
        {
            NoLimitHoldem table = find(tableId);

            if (table == null)
            {
                c.Kill(); return;
            }

            if (!table.isHisPos(c))
            {
                return;
            }

            if (table.tableData.toCall > betAmount)
            {
                c.Kill(); return;
            }

            table.tableData.currentAct.action    = pokerActions.Bet;
            table.tableData.currentAct.betAmount = betAmount;
        }
Ejemplo n.º 9
0
        public void reserve(Client c, string tableId, int pos)
        {
            //we should start a timer for 30 second after it we should delete him
            NoLimitHoldem table = find(tableId);

            if (table == null)
            {
                return;
            }
            if (pos >= table.seatsCount)
            {
                return;
            }
            if (c.sittedTables.Find(delegate(string str) { return(str == tableId); }) != null)
            {
                c.send(
                    new string[] { "type", "msgtype", "message" },
                    new string[] { "srvmsg", "error", "Sorry.. You already siited down on this table" }
                    );
                return;
            }

            object myObj = c.reservedTables.Find(delegate(string str) { return(str == tableId); });

            if (myObj != null) // he reserve a seat on this table later or not
            {
                return;
            }
            if (table.tableData.reservedUserName[pos] != null || !table.isVacant(pos))//some one reserve this seat or seat on it he can not seat here
            {
                return;
            }

            c.reservedTables.Add(tableId);
            table.tableData.reservedUserName[pos] = c.Username;

            ThreadStart timer = new ThreadStart(delegate() {
                table.TableRelease(
                    new string[] { "type", "msgtype", "pos", "username", "tableId" },
                    new string[] { "srvmsg", "rsv", pos.ToString(), c.Username, table.tableId }
                    );
                c.send(
                    new string[] { "type", "msgtype", "pos", "username", "tableId", "minBuyIn", "maxBuyIn" },
                    new string[] { "srvmsg", "rsvShow", pos.ToString(), c.Username, table.tableId, table.minBuyin.ToString(), table.maxBuyin.ToString() }
                    );
                int seconds    = 30;
                int counter    = 0;
                string checker = c.reservedTables.Find(delegate(string str) { return(str == tableId); });
                while (seconds > 0 && checker != null && c.isAvailable)//here i think we have a bug .... check it later mamal
                {
                    checker = c.reservedTables.Find(delegate(string str) { return(str == tableId); });
                    Thread.Sleep(100);
                    if (checker == null)
                    {
                        break;
                    }
                    counter += 100;
                    if (counter == 1000)
                    {
                        seconds--;
                        counter = 0;
                        if (c.reservedTables.Find(delegate(string str) { return(str == tableId); }) == null)
                        {
                            break;
                        }
                        table.TableRelease(
                            new string[] { "type", "msgtype", "pos", "timeExist", "tableId" },
                            new string[] { "srvmsg", "rsvTime", pos.ToString(), seconds.ToString(), table.tableId }
                            );
                    }
                }
                // time out or disconnect or cancel
                table.TableRelease(
                    new string[] { "type", "msgtype", "tableId", "pos" },
                    new string[] { "srvmsg", "ursv", table.tableId, pos.ToString() }
                    );
                c.send(
                    new string[] { "type", "msgtype", "tableId", "pos" },
                    new string[] { "srvmsg", "unrsv", table.tableId, pos.ToString() }
                    );
                c.reservedTables.Remove(tableId);
                table.tableData.reservedUserName[pos] = null;
            });
            Thread th = new Thread(timer);

            th.Start();
        }
Ejemplo n.º 10
0
        //private static void updateData()
        //{
        //    // create cash games
        //    string TableName, TableID;
        //    int SeatsCount, LastId = 0, BigBlind, MaxBuyin, MinBuyin;
        //    do
        //    {


        //        TableName = DB.get("TableName", "CashgameTables", new string[] { "id", ">", LastId.ToString() });
        //        if (TableName != "")
        //        {
        //            LastId = Int32.Parse(DB.get("id", "CashgameTables", new string[] { "TableName", "=", TableName }));
        //            TableID = DB.get("TableID", "CashgameTables", new string[] { "id", "=", LastId.ToString() });
        //            SeatsCount = Int32.Parse(DB.get("SeatsCount", "CashgameTables", new string[] { "id", "=", LastId.ToString() }));
        //            MaxBuyin = Int32.Parse(DB.get("MaxBuyin", "CashgameTables", new string[] { "id", "=", LastId.ToString() }));
        //            MinBuyin = Int32.Parse(DB.get("MinBuyin", "CashgameTables", new string[] { "id", "=", LastId.ToString() }));
        //            BigBlind = Int32.Parse(DB.get("BigBlind", "CashgameTables", new string[] { "id", "=", LastId.ToString() }));

        //            int last = cashTables.Length;
        //            Array.Resize(ref cashTables, last + 1);
        //            cashTables[last] = new CashGameTable(TableID, TableName, SeatsCount, MinBuyin, MaxBuyin, BigBlind);
        //        }
        //    } while (TableName != "");

        //    // create tournments

        //    // create sits and goes

        //    // add players to tournoments
        //}

        /////////////////////////
        // here we write some function to check data and then call function for each table
        ////////////////////////
        public void SitDown(Client c, string tableId, int chip, int pos)
        {
            if (!c.isAvailable)
            {
                return;
            }
            NoLimitHoldem table = find(tableId);

            if (table == null)
            {
                c.Kill(); return;
            }
            //checking inputs
            if (chip > table.maxBuyin || chip < table.minBuyin)
            {
                c.send(
                    new string[] { "type", "msgtype", "tableId", "message" },
                    new string[] { "srvmsg", "error", table.tableId, "Please buy chips between Minimum buyin and Maximum buyin. " }
                    );
                table.TableRelease(
                    new string[] { "type", "msgtype", "tableId", "pos" },
                    new string[] { "srvmsg", "ursv", table.tableId, pos.ToString() }
                    );
                c.send(
                    new string[] { "type", "msgtype", "tableId", "pos" },
                    new string[] { "srvmsg", "unrsv", table.tableId, pos.ToString() }
                    );
                return;
            }
            if (!table.isVacant(pos))
            {
                c.send(
                    new string[] { "type", "msgtype", "tableId", "message" },
                    new string[] { "srvmsg", "error", table.tableId, "Sorry.. Can not sit down here" }
                    );
                table.TableRelease(
                    new string[] { "type", "msgtype", "tableId", "pos" },
                    new string[] { "srvmsg", "ursv", table.tableId, pos.ToString() }
                    );
                c.send(
                    new string[] { "type", "msgtype", "tableId", "pos" },
                    new string[] { "srvmsg", "unrsv", table.tableId, pos.ToString() }
                    );
                return;
            }
            if (c.decBalance(chip) == -1)
            {
                c.send(
                    new string[] { "type", "msgtype", "tableId", "message" },
                    new string[] { "srvmsg", "error", table.tableId, "Sorry.. You don't have enought balance to sit on table.\n Please deposit and try again." }
                    );
                table.TableRelease(
                    new string[] { "type", "msgtype", "tableId", "pos" },
                    new string[] { "srvmsg", "ursv", table.tableId, pos.ToString() }
                    );
                c.send(
                    new string[] { "type", "msgtype", "tableId", "pos" },
                    new string[] { "srvmsg", "unrsv", table.tableId, pos.ToString() }
                    );
                return;
            }
            if (c.sittedTables.Find(delegate(string str) { return(str == tableId); }) != null)
            {
                c.send(
                    new string[] { "type", "msgtype", "tableId", "message" },
                    new string[] { "srvmsg", "error", table.tableId, "Sorry.. You already sited down on this table" }
                    );
                table.TableRelease(
                    new string[] { "type", "msgtype", "tableId", "pos" },
                    new string[] { "srvmsg", "ursv", table.tableId, pos.ToString() }
                    );
                c.send(
                    new string[] { "type", "msgtype", "tableId", "pos" },
                    new string[] { "srvmsg", "unrsv", table.tableId, pos.ToString() }
                    );
                return;
            }
            if (table.tableData.reservedUserName[pos] != c.Username)
            {
                //the player didn't reserved the table after
                c.Kill();
                return;
            }
            table.sitDown(c, chip, pos);
        }