コード例 #1
0
        public static void Start()
        {
            Playing = true;
            int currentPhase = 1;

            MainMenuView.Start();

            while (Playing)
            {
                GameController.Phase(currentPhase);
                if (currentPhase == 6)
                {
                    PrintMessageView.PrintMessage("Would you like to continue playing? yes/No ");
                    string command = Console.ReadLine().Trim().ToLower();
                    if (command == "yes" || command == "y")
                    {
                        currentPhase = 0;
                        ResetGame();
                    }
                    else
                    {
                        Playing = false;
                    }
                }
                currentPhase++;
            }
        }
コード例 #2
0
 public void Call()
 {
     Balance   -= BetController.GetHighestBet() - CurrentBid;
     CurrentBid = BetController.GetHighestBet();
     PrintMessageView.PrintNewLineMessage($"{Name} called");
     ContextsData.MessageLogContext.AddMessageLog($"{Name} called");
 }
コード例 #3
0
 public void Raise(uint raiseValue)
 {
     if (raiseValue > PlayerController.GetAllBalances().Min())
     {
         raiseValue = PlayerController.GetAllBalances().Min();
     }
     Balance   -= BetController.GetHighestBet() + raiseValue - CurrentBid;
     CurrentBid = BetController.GetHighestBet() + raiseValue;
     PrintMessageView.PrintNewLineMessage($"{Name} raised {raiseValue}");
     ContextsData.MessageLogContext.AddMessageLog($"{Name} raised {raiseValue}");
 }
コード例 #4
0
 public override void DoAction()
 {
     if (BetController.PlayerCanCall(this))
     {
         base.Call();
     }
     else
     {
         PrintMessageView.PrintNewLineMessage($"{Name} passed");
         ContextsData.MessageLogContext.AddMessageLog($"{Name} passed");
     }
 }
コード例 #5
0
ファイル: User.cs プロジェクト: DenisIvanov88/PokerGame
        public override void DoAction()
        {
            string[] command = CommandView.AskUser().ToArray();
            switch (command[0])
            {
            case "raise":
                try
                {
                    uint.Parse(command[1]);
                }
                catch (Exception)
                {
                    PrintMessageView.PrintNewLineMessage("Invalid data type!");
                    this.DoAction();
                    break;
                }
                if (uint.Parse(command[1]) > this.Balance)
                {
                    PrintMessageView.PrintNewLineMessage("Invalid amount! Amount must be lower than user's balance!");
                    this.DoAction();
                    break;
                }
                else
                {
                    base.Raise(uint.Parse(command[1]));
                }
                break;

            case "call":
                if (BetController.PlayerCanCall(this))
                {
                    base.Call();
                }
                break;

            case "fold": base.Fold(); break;

            case "stop":
            case "end": Engine.Playing = false; break;

            default: PrintMessageView.PrintNewLineMessage($"{Name} passed");
                ContextsData.MessageLogContext.AddMessageLog($"{Name} passed");
                break;
            }
        }