コード例 #1
0
ファイル: HoldemGame.cs プロジェクト: Kar98/MiniCasino
        private PlayerAction HumanPlay(PokerPlayer player, BetStage bs)
        {
            bool awaitResp = true;

            Console.WriteLine($"Current betting stage : {bs.ToString()}");
            Console.WriteLine("Enter 'raise #', 'call', 'hand' or 'fold' for player actions");
            Console.WriteLine("Enter 'hand' to view current hand");

            while (awaitResp)
            {
                var action = WaitForCommand();
                action = action.ToLower();

                var splitAct = action.Split(' ');

                if (splitAct.Length == 1)
                {
                    switch (splitAct[0])
                    {
                    case "call":
                        var a = Call(player);
                        if (a != PlayerAction.NONE)
                        {
                            return(Call(player));
                        }
                        break;

                    case "money":
                        LogLine("Chips: " + player.Chips);
                        break;

                    case "fold":
                        return(Fold(player));

                    case "hand":
                        PrintTableCards();
                        player.PrintCards();
                        Console.WriteLine();
                        break;
                    }
                }
                else if (splitAct.Length > 1 && splitAct[0] == "raise")
                {
                    if (int.TryParse(splitAct[1], out int res))
                    {
                        var a = Raise(player, res);
                        if (a != PlayerAction.NONE)
                        {
                            return(Raise(player, res));
                        }
                    }
                }
                else
                {
                    LogLine("Enter a valid value");
                }
            }

            throw new Exception("No player action performed!");
        }