using System.Media;
using System.Reflection.Emit;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        int[] ZufallsZahlen = new int[6];

        private List<int> selectedNummbers = new List<int>();
        int meinGeld = 100;
        public MainWindow()
        {
            InitializeComponent();
        }

       
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Zufallszahlen();
            InLabels();
            int treffer = 0;

            foreach (int num in selectedNummbers)
            {
                for (int i = 0; i < ZufallsZahlen.Length; i++)
                {
                    if (num == ZufallsZahlen[i])
                    {
                        treffer++;
                        break;
                    }
                }
            }
            MessageBox.Show($"Du hast {treffer} Treffer!");

            switch (treffer)
            {
                case 1:
                    Kontostand.Content = "Gwinn: 1$";
                    break;
                case 2:
                    Kontostand.Content = "Gwinn: 10$";
                    break;
                case 3:
                    Kontostand.Content = " Gwinn: 100$";
                    break;
                case 4:
                    Kontostand.Content = "Gwinn: 1000$";
                    break;
                case 5:
                    Kontostand.Content = "Gwinn: 10000$";
                    break;
                case 6:
                    Kontostand.Content = "Gwinn: 1000.000$";
                    break;
                default:
                    Kontostand.Content = "0$";
                    break;
            }



        }

        private void NumberButton_Click(object sender, RoutedEventArgs e)
        {
            Button clickbutton = sender as Button;

            int number = int.Parse(clickbutton.Content.ToString());

            if (selectedNummbers.Contains(number))
            {
                selectedNummbers.Remove(number);
                clickbutton.Background = Brushes.LightGray;
            }
            else
            {
                if (selectedNummbers.Count < 6)
                {
                    selectedNummbers.Add(number);
                    clickbutton.Background = Brushes.Red;
                }
                else
                {
                    SystemSounds.Exclamation.Play();
                    MessageBox.Show("⚠️ Maximal 6 Zahlen erlaubt!");
                }
            }

            
        }

        private void Zufallszahlen()
        {
            Random random = new Random();

            int index = 0;

            while (index < 6)
            {
                int zahl = random.Next(1, 50);

                if (ZufallsZahlen.Contains(zahl))
                {
                }
                else
                {
                    ZufallsZahlen[index] = zahl;
                    index++;
                }
            }
        }

        private void InLabels()
        {
            Label0.Content = ZufallsZahlen[0].ToString();
            Label1.Content = ZufallsZahlen[1].ToString();
            Label2.Content = ZufallsZahlen[2].ToString();
            Label3.Content = ZufallsZahlen[3].ToString();
            Label4.Content = ZufallsZahlen[4].ToString();
            Label5.Content = ZufallsZahlen[5].ToString();
        }

        
    }
}

