/// <summary> /// Deals a new game. This is invoked through the Deal button in PokerForm.cs /// </summary> public void DealNewGame() { // Create a new deck and then shuffle the deck deck = new Deck(); deck.Shuffle(); // Reset the player and the dealer's hands in case this is not the first game foreach (Player p in Players) { p.NewHand(); } // Deal two cards to each person's hand for (int p = 0; p < players.Count; p++) { for (int i = 0; i < 2; i++) { Card c = deck.Draw(); players[p].Hand.Cards.Add(c); } } // Give the player and the dealer a handle to the current deck // player.CurrentDeck = deck; //dealer.CurrentDeck = deck; }
// Deal the card to each player based on the number of cards for each player static List <Player> DealCardToPlayers(List <Player> players, Deck deck) { var playerList = players; for (int time = 0; time < NUMBER_OF_CARD_PER_PLAYER; time++) { foreach (Player p in playerList) { p.Cards.Add(deck.Draw()); } } return(playerList); }
/// <summary> /// Player has hit, draw a card from the deck and add it to the player's hand /// </summary> public void Hit() { Card c = currentDeck.Draw(); hand.Cards.Add(c); }