private void DealCard(object sender, EventArgs e) { Card card = _playerDeck.DealCard(); string cardName = card.Face + card.Suit; try { DrawCardOnCanvas(playerActiveCardCanvas, cardName); } catch (FileNotFoundException exc) { MessageBox.Show(exc.Message, "File not found", MessageBoxButton.OK, MessageBoxImage.Error); } playerCardLabel.Content = card.ToString(); playerCardNumberLabel.Content = "Card #" + (_playerDeck.CurrentCard + 1); dealButton.IsEnabled = false; playerCardCanvas.IsEnabled = false; CheckWinner(); if (!_gameOver) { _computerPlayTimer.Start(); } }
private void ComputerAI(object sender, EventArgs e) { shuffledLabel.Content = ""; computerResultLabel.Content = ""; playerResultLabel.Content = ""; Card card = _computerDeck.DealCard(); if (card == null) { EndGame(); computerActiveCardCanvas.Children.Clear(); } else { string cardName = card.Face + card.Suit; try { DrawCardOnCanvas(computerActiveCardCanvas, cardName); } catch (FileNotFoundException exc) { MessageBox.Show(exc.Message, "File not found", MessageBoxButton.OK, MessageBoxImage.Error); } computerCardLabel.Content = card.ToString(); computerCardNumberLabel.Content = "Card #" + (_computerDeck.CurrentCard + 1); dealButton.IsEnabled = true; playerCardCanvas.IsEnabled = true; playerCardLabel.Content = ""; playerCardNumberLabel.Content = ""; } playerActiveCardCanvas.Children.Clear(); _computerPlayTimer.Stop(); }