コード例 #1
0
 private void ResetWindow()
 {
     DealerSection.Children.Clear();
     PlayerSection.Children.Clear();
     PlayerPanels.Clear();
     CurrentPlayer         = null;
     LabelWinnerIs.Content = "Winner is: ";
 }
コード例 #2
0
 // 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));
     }
 }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
        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}";
        }