private void ResetWindow() { DealerSection.Children.Clear(); PlayerSection.Children.Clear(); PlayerPanels.Clear(); CurrentPlayer = null; LabelWinnerIs.Content = "Winner is: "; }
// Updates the PlayerSection with the next players information, // if there is no next player the current players information is updated private void UpdatePlayerSection(Player nextPlayer) { if (nextPlayer != null && nextPlayer != CurrentPlayer) { PlayerSection.Children.Clear(); PlayerSection.Children.Add( PlayerPanels.FirstOrDefault(p => p.Player.PlayerId == nextPlayer.PlayerId)); } }
private void BtnNewRound_Click(object sender, RoutedEventArgs e) { BtnNewRound.IsEnabled = false; ResetWindow(); (Player dealer, List <Player> players) = GameManager.NewRound(); PlayerPanel dealerPanel = new PlayerPanel(dealer); players.ForEach(p => PlayerPanels.Add(new PlayerPanel(p))); DealerSection.Children.Add(dealerPanel); Player firstPlayer = GameManager.ContinueRound(ShowWinner); if (firstPlayer != null) { PlayerSection.Children.Add( PlayerPanels.FirstOrDefault(p => p.Player.PlayerId == firstPlayer.PlayerId)); } }
private void BtnNewGame_Click(object sender, RoutedEventArgs e) { ResetWindow(); NewGameWindow ngw = new NewGameWindow(this); ngw.ShowDialog(); (Player dealer, List <Player> players) = ngw.StartingPlayers; PlayerPanel dealerPanel = new PlayerPanel(dealer); players.ForEach(p => PlayerPanels.Add(new PlayerPanel(p))); DealerSection.Children.Add(dealerPanel); Player firstPlayer = GameManager.ContinueRound(ShowWinner); if (firstPlayer != null) { PlayerSection.Children.Add( PlayerPanels.FirstOrDefault(p => p.Player.PlayerId == firstPlayer.PlayerId)); } LabelNbrOfDecks.Content = $"Decks: {GameManager.Deck.Multiplier}"; }