Exemple #1
0
        /// <summary>
        /// Method called to start a new deal.
        /// </summary>
        public void NewDeal()
        {
            if (gameOver)
            {
                return;
            }
            foreach (Player p in players)
            {
                if (p.Money <= 0 && p.PlayerStatus != PlayerStatus.OutGame)
                {
                    Loss(p);
                }
            }
            if (players.FindAll(p => p.PlayerStatus == PlayerStatus.OutGame).Count >= players.Count - 1)
            {
                Winner = players.Find(p => p.PlayerStatus != PlayerStatus.OutGame);
                GameControler.GameOver();
                return;
            }
            pot = 0;
            if (deal > 0 && anteDoubles)
            {
                ante *= 2;
            }
            currentRound = 0;
            deck.Clear();
            commonCards.Clear();
            List <Card> randomOrderCards = Card.Deck.OrderBy(c => rng.Next(int.MaxValue)).ToList();

            for (int i = Card.Deck.Count; i > 0; i--)
            {
                deck.Push(randomOrderCards[rng.Next(0, i)]);
                randomOrderCards.Remove(deck.Peek());
            }
            foreach (Player p in players)
            {
                if (p.PlayerStatus == PlayerStatus.OutDeal)
                {
                    p.PlayerStatus = PlayerStatus.In;
                }
                p.Hand.Clear();
                p.CurrentBet = 0;
                if (p.Money <= 0 && p.PlayerStatus != PlayerStatus.OutGame)
                {
                    Loss(p);
                }
            }
            currentPlayer = players.Find(p => p.PlayerStatus != PlayerStatus.OutGame);
            deal++;
            GameControler.DisplayNewDeal(players.FindAll(p => p.PlayerStatus == PlayerStatus.In));
            Prompt();
        }
Exemple #2
0
 private void Victory(Player player)
 {
     if (gameOver)
     {
         return;
     }
     player.Gain(pot);
     GameControler.DisplayDealWon(player.Name, pot);
     if (OtherPlayers.All(p => p.Money <= 0 || p.PlayerStatus == PlayerStatus.OutGame))
     {
         Winner = player;
         GameControler.GameOver();
     }
 }
Exemple #3
0
 private void Loss(Player currentPlayer)
 {
     if (gameOver)
     {
         return;
     }
     currentPlayer.PlayerStatus = PlayerStatus.OutGame;
     GameControler.DisplayLoss(currentPlayer.Name);
     if (players.FindAll(p => p.PlayerStatus != PlayerStatus.OutGame).Count <= 1)
     {
         Winner = players.Find(p => p.PlayerStatus != PlayerStatus.OutGame);
         GameControler.GameOver();
     }
 }
Exemple #4
0
 /// <summary>
 /// Method called to make the player act.
 /// If the player is human, the controller is used to display the possible actions and to wait on
 /// the input of the player.
 /// If the player is an AI, automatic play is engaged.
 /// </summary>
 public void Prompt()
 {
     if (gameOver)
     {
         return;
     }
     if (currentPlayer == null)
     {
         GameControler.GameOver();
     }
     GameControler.DisplayInitialPrompt("Game: " + gameName +
                                        ", Player: " + currentPlayer.Name + ", round= " + theRounds[currentRound]);
     if (currentPlayer.PlayerType == PlayerType.AI)
     {
         AutoPlay(currentPlayer);
     }
     else
     {
         GameControler.DisplayPossibleActions(PossibleActions(theRounds[currentRound]));
     }
 }