From cf90775bade318d1a2604ea87c593937f168548c Mon Sep 17 00:00:00 2001 From: "NBTEMP\\bib" Date: Sun, 13 Sep 2026 15:40:50 +0200 Subject: [PATCH 1/2] Busfahrer hintergrundmusik --- Casino/Audioplayer.cs | 25 ++++++++++++++++++++++++- Casino/Busfahrer.xaml.cs | 8 ++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Casino/Audioplayer.cs b/Casino/Audioplayer.cs index ce70285..036e91f 100644 --- a/Casino/Audioplayer.cs +++ b/Casino/Audioplayer.cs @@ -38,9 +38,32 @@ namespace Casino public void PlayLoopingSound(byte[] audioBlob) { + string tempFile = System.IO.Path.Combine( System.IO.Path.GetTempPath(), - "background.mp3"); + "Hintergrundmusik.mp3"); + + player.Volume = 0.1; + + File.WriteAllBytes(tempFile, audioBlob); + + player.Open(new Uri(tempFile)); + + player.MediaEnded -= Player_MediaEnded; + player.MediaEnded += Player_MediaEnded; + + player.Play(); + } + + + public void PlayLoopingSound_2(byte[] audioBlob) + { + + string tempFile = System.IO.Path.Combine( + System.IO.Path.GetTempPath(), + "Hintergrundmusik_Bus.mp3"); + + player.Volume = 0.1; File.WriteAllBytes(tempFile, audioBlob); diff --git a/Casino/Busfahrer.xaml.cs b/Casino/Busfahrer.xaml.cs index 4399f75..b9f6ce8 100644 --- a/Casino/Busfahrer.xaml.cs +++ b/Casino/Busfahrer.xaml.cs @@ -78,14 +78,13 @@ namespace Casino private List deck = new List(); private List handCards = new List(); private ImageSource cardBackImage = null!; + Audioplayer music = new Audioplayer(); private int currentPhase = 0; private decimal currentBet = 0; private decimal currentProfit = 0; private bool roundRunning = false; - private static readonly Regex NumberRegex = new Regex("^[0-9]+$"); - public Busfahrer() { InitializeComponent(); @@ -94,6 +93,7 @@ namespace Casino UpdateAccountDisplay(); ShowWaitingState(); + music.PlayLoopingSound_2(db.GetSound(20)); } private User CurrentUser => users[MainWindow.currentUser]; @@ -553,6 +553,7 @@ namespace Casino private void Hauptmenue(object sender, RoutedEventArgs e) { + music.Stop(); Close(); } @@ -580,6 +581,9 @@ namespace Casino // EINSATZ VALIDIERUNG // ========================= + + private static readonly Regex NumberRegex = new Regex("^[0-9]+$"); + private void TxtBet_PreviewTextInput(object sender, TextCompositionEventArgs e) { e.Handled = !NumberRegex.IsMatch(e.Text); From 51f22f4155673a2a31be4a607cc5a5c78e819e58 Mon Sep 17 00:00:00 2001 From: "NBTEMP\\bib" Date: Sun, 13 Sep 2026 15:59:13 +0200 Subject: [PATCH 2/2] merge_1 --- Casino/Busfahrer.xaml.cs | 45 ++++++++++++++++++++++++++-------------- Casino/Slots.xaml.cs | 30 +++++++++++++++++++-------- 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/Casino/Busfahrer.xaml.cs b/Casino/Busfahrer.xaml.cs index b9f6ce8..87b5afa 100644 --- a/Casino/Busfahrer.xaml.cs +++ b/Casino/Busfahrer.xaml.cs @@ -157,25 +157,38 @@ namespace Casino private void StartRound() { - if (currentBet <= 0 || currentBet > CurrentUser.Geld) + try { - ShowWaitingState(); - return; + if (currentBet <= 0 || currentBet > CurrentUser.Geld) + { + ShowWaitingState(); + return; + } + + // Einsatz vom Konto abziehen + CurrentUser.Geld -= Convert.ToInt32(currentBet); + SaveAccount(); + + currentProfit = 0; + currentPhase = 0; + roundRunning = true; + TxtBet.IsEnabled = false; + + LoadCards(); + UpdateHandUI(); + UpdateWinDisplay(); + SetPhaseUI(); + } + catch (NullReferenceException) + { + MessageBox.Show( + "Bitte ein Betrag eingeben", + "Fehlermeldung 101", + MessageBoxButton.OK, + MessageBoxImage.Information); } - // Einsatz vom Konto abziehen - CurrentUser.Geld -= Convert.ToInt32(currentBet); - SaveAccount(); - - currentProfit = 0; - currentPhase = 0; - roundRunning = true; - TxtBet.IsEnabled = false; - - LoadCards(); - UpdateHandUI(); - UpdateWinDisplay(); - SetPhaseUI(); + } private void LoadCards() diff --git a/Casino/Slots.xaml.cs b/Casino/Slots.xaml.cs index a2e73d7..fcd158f 100644 --- a/Casino/Slots.xaml.cs +++ b/Casino/Slots.xaml.cs @@ -131,15 +131,27 @@ namespace Casino private async void Spin(object sender, RoutedEventArgs e) { - int einsatz = Convert.ToInt32(einsatzFeld.Text); - users[MainWindow.currentUser].Geld-=einsatz; - Konto.Text = users[MainWindow.currentUser].Geld.ToString(); - await Spin(); - users[MainWindow.currentUser].Geld += CheckWin(currentSlot,einsatz); - Konto.Text = users[MainWindow.currentUser].Geld.ToString(); - db.UpdateGeld( - users[MainWindow.currentUser].ID, - users[MainWindow.currentUser].Geld); + + + int einsatz = Convert.ToInt32(einsatzFeld.Text); + users[MainWindow.currentUser].Geld -= einsatz; + Konto.Text = users[MainWindow.currentUser].Geld.ToString(); + await Spin(); + users[MainWindow.currentUser].Geld += CheckWin(currentSlot, einsatz); + Konto.Text = users[MainWindow.currentUser].Geld.ToString(); + db.UpdateGeld( + users[MainWindow.currentUser].ID, + users[MainWindow.currentUser].Geld); + + /* catch (NullReferenceException) + { + MessageBox.Show( + "Bitte ein Betrag eingeben", + "Fehlermeldung 101", + MessageBoxButton.OK, + MessageBoxImage.Information); + }*/ + } private void Hauptmenue(object sender, RoutedEventArgs e)