예제 #1
0
        protected void call(int pos)
        {
            //checking process should be later in gamecore
            playerData[pos].Chips -= tableData.toCall;
            Client c = playerData[pos].updateClient();

            c.decBalance(tableData.toCall);
            tableData.pot           += tableData.toCall;
            playerData[pos].haveMove = false; // but player is in game
            this.TableRelease(
                new string[] { "type", "actType", "pos", "tableId", "amount" },
                new string[] { "act", "call", pos.ToString(), this.tableId, tableData.toCall.ToString() }
                );
        }
예제 #2
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);
        }