Beispiel #1
0
        int Play(int playerIdx)
        {
            // ===========================下注=============================
            int money = g.GetPlayerMoney(playerIdx);

            Console.WriteLine(g.Players[playerIdx].Name + "的余额为: " + money + ", 请下注:");
            int bet = Convert.ToInt32(Console.ReadLine());

            for (; bet > money;)
            {
                Console.WriteLine("没钱别乱下注, again!");
                bet = Console.Read();
            }
            g.PlayerBet(playerIdx, bet);
            // 先给玩家两张牌
            for (int i = 0; i < 2; i++)
            {
                Card c = g.DealOneCardToPlayer(playerIdx);
                Console.WriteLine("得到一张牌: " + c.GetCardFace());
            }
            // 由玩家决定是否继续
            for (int i = 0; i < 999; i++)
            {
                Console.WriteLine("您有三种选择:1.stand(直接结束), 2.hit(继续要牌), 3.addBet(增加赌注).");
                Console.WriteLine("输出(1/2/3)进行您的选择:");
                int op = Convert.ToInt32(Console.ReadLine());
                if (op == 1)
                {
                    break;
                }
                else if (op == 2)
                {
                    if (!Hit(playerIdx))
                    {
                        break;
                    }
                }
                else if (op == 3)
                {
                    AddBet(playerIdx);
                }
                else
                {
                    Console.WriteLine("输入错误,请重新输入.");
                }
            }

            int point = g.PlayerTotalPoint(playerIdx);

            if (!g.IsPointOut(playerIdx))
            {
                Console.WriteLine("您的点数为:" + point);
            }
            Console.WriteLine("--------您的表演结束了---------");
            return(g.IsPointOut(playerIdx) ? -1 : point);
        }
Beispiel #2
0
        private bool Hit(int playerIdx)
        {
            Card c = g.DealOneCardToPlayer(playerIdx);

            Console.WriteLine("得到一张牌: " + c.GetCardFace());
            if (g.IsPointOut(playerIdx))
            {
                Console.WriteLine("您爆牌了,输了输了");
                return(false);
            }
            return(true);
        }