private void GameStart() { Deck = new PlayingCardDeck(); Deck.Shuffle(); PlayersHandTotal = 0; PlayersHand.Clear(); DealersHandTotal = 0; DealersHand.Clear(); ButtonsEnabled = true; PlayerScoreText = "Players score: " + PlayerGameScore.ToString(); DealerScoreText = "Dealers score: " + DealerGameScore.ToString(); PlayersHand.Add(Deck.RemoveTopCard()); DealersHand.Add(Deck.RemoveTopCard()); PlayersHand.Add(Deck.RemoveTopCard()); DealersHand.Add(Deck.RemoveTopCard()); DealersHandTotalText = "Dealers hand total: " + DealersHandTotal; OnPropertyChanged(nameof(PlayersHand)); PlayersHandTotal = UpdateScore(PlayersHand); PlayersHandTotalText = "Players hand total: " + PlayersHandTotal.ToString(); ConvoText = "Players turn"; }
private void ReshuffleDeck() { _activeDeck = new PlayingCardDeck(); _activeDeck = ShuffleDeck(_activeDeck); Console.WriteLine("The deck was reshuffled!"); }
public void DealHand(PlayingCardDeck activeDeck, Player player, Player dealer) { for (int i = 0; i < 2; i++) { player.CurrentHand.Add(activeDeck.PlayingCards.First()); activeDeck.PlayingCards.RemoveAt(0); } dealer.CurrentHand.Add(activeDeck.PlayingCards.First()); activeDeck.PlayingCards.RemoveAt(0); }
private void GameStart() { Deck = new PlayingCardDeck(); Deck.Shuffle(); PlayersHandTotal = 0; PlayersHand.Clear(); DealersHandTotal = 0; DealersHand.Clear(); buttonHit.Enabled = true; buttonStick.Enabled = true; playerGameScoreText.Text = "Players score: " + PlayerGameScore.ToString(); dealerGameScoreText.Text = "Dealers score: " + DealerGameScore.ToString(); dealersFirstCard.Visibility = ViewStates.Visible; dealersSecondCard.Visibility = ViewStates.Visible; dealersThirdCard.Visibility = ViewStates.Invisible; dealersFourthCard.Visibility = ViewStates.Invisible; dealersFifthCard.Visibility = ViewStates.Invisible; dealersFirstCard.SetDealerCardFaceDown(); dealersSecondCard.SetDealerCardFaceDown(); playersThirdCard.Visibility = ViewStates.Invisible; playersFourthCard.Visibility = ViewStates.Invisible; playersFifthCard.Visibility = ViewStates.Invisible; PlayersHand.Add(Deck.RemoveTopCard()); DealersHand.Add(Deck.RemoveTopCard()); PlayersHand.Add(Deck.RemoveTopCard()); DealersHand.Add(Deck.RemoveTopCard()); dealersHandText.Text = "Dealers hand total: " + DealersHandTotal; PrintPlayerHand(PlayersHand); PlayersHandTotal = UpdateScore(PlayersHand); playersHandText.Text = "Players hand total: " + PlayersHandTotal.ToString(); convoText.Text = "Players turn"; }
public PlayingCardDeck ShuffleDeck(PlayingCardDeck deck) { deck.PlayingCards = deck.PlayingCards.Shuffled().ToList(); return(deck); }
public void Run() { Console.OutputEncoding = Encoding.UTF8; Console.BackgroundColor = ConsoleColor.DarkGreen; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); _activeDeck = ShuffleDeck(_activeDeck); while (true) { MenuChoice menuChoice = ShowMainMenu(); if (menuChoice == MenuChoice.PlayGame) { PlayerSelectionScreen(); Console.Clear(); while (true) { LetPlayerPlaceBet(); DealHand(_activeDeck, _currentPlayer, _dealer); PlayerPlayHand(); if (_currentPlayer.HandValue <= 21) { PlayDealerHand(); } HandResult handResult = CheckHandResult(); DisplayHandResult(handResult); UpdatePlayerChipCount(handResult); _dataAccess.UpdatePlayer(_currentPlayer); ClearHand(); if (_activeDeck.PlayingCards.Count < 10) { ReshuffleDeck(); } if (!PlayAnotherHand()) { break; } } } else if (menuChoice == MenuChoice.ShowHighscore) { ShowHighscore(); } else if (menuChoice == MenuChoice.ExitGame) { ShowExitScreen(); break; } } }