Merge branch 'main' of https://git.bib.de/PBG2H25AGE/WIR-MACHEN-ALLE-ARM
This commit is contained in:
+24
-1
@@ -38,9 +38,32 @@ namespace Casino
|
|||||||
|
|
||||||
public void PlayLoopingSound(byte[] audioBlob)
|
public void PlayLoopingSound(byte[] audioBlob)
|
||||||
{
|
{
|
||||||
|
|
||||||
string tempFile = System.IO.Path.Combine(
|
string tempFile = System.IO.Path.Combine(
|
||||||
System.IO.Path.GetTempPath(),
|
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);
|
File.WriteAllBytes(tempFile, audioBlob);
|
||||||
|
|
||||||
|
|||||||
+35
-18
@@ -78,14 +78,13 @@ namespace Casino
|
|||||||
private List<Card> deck = new List<Card>();
|
private List<Card> deck = new List<Card>();
|
||||||
private List<Card> handCards = new List<Card>();
|
private List<Card> handCards = new List<Card>();
|
||||||
private ImageSource cardBackImage = null!;
|
private ImageSource cardBackImage = null!;
|
||||||
|
Audioplayer music = new Audioplayer();
|
||||||
|
|
||||||
private int currentPhase = 0;
|
private int currentPhase = 0;
|
||||||
private decimal currentBet = 0;
|
private decimal currentBet = 0;
|
||||||
private decimal currentProfit = 0;
|
private decimal currentProfit = 0;
|
||||||
private bool roundRunning = false;
|
private bool roundRunning = false;
|
||||||
|
|
||||||
private static readonly Regex NumberRegex = new Regex("^[0-9]+$");
|
|
||||||
|
|
||||||
public Busfahrer()
|
public Busfahrer()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -94,6 +93,7 @@ namespace Casino
|
|||||||
UpdateAccountDisplay();
|
UpdateAccountDisplay();
|
||||||
|
|
||||||
ShowWaitingState();
|
ShowWaitingState();
|
||||||
|
music.PlayLoopingSound_2(db.GetSound(20));
|
||||||
}
|
}
|
||||||
|
|
||||||
private User CurrentUser => users[MainWindow.currentUser];
|
private User CurrentUser => users[MainWindow.currentUser];
|
||||||
@@ -157,25 +157,38 @@ namespace Casino
|
|||||||
|
|
||||||
private void StartRound()
|
private void StartRound()
|
||||||
{
|
{
|
||||||
if (currentBet <= 0 || currentBet > CurrentUser.Geld)
|
try
|
||||||
{
|
{
|
||||||
ShowWaitingState();
|
if (currentBet <= 0 || currentBet > CurrentUser.Geld)
|
||||||
return;
|
{
|
||||||
|
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()
|
private void LoadCards()
|
||||||
@@ -553,6 +566,7 @@ namespace Casino
|
|||||||
|
|
||||||
private void Hauptmenue(object sender, RoutedEventArgs e)
|
private void Hauptmenue(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
music.Stop();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,6 +594,9 @@ namespace Casino
|
|||||||
// EINSATZ VALIDIERUNG
|
// EINSATZ VALIDIERUNG
|
||||||
// =========================
|
// =========================
|
||||||
|
|
||||||
|
|
||||||
|
private static readonly Regex NumberRegex = new Regex("^[0-9]+$");
|
||||||
|
|
||||||
private void TxtBet_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
private void TxtBet_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
||||||
{
|
{
|
||||||
e.Handled = !NumberRegex.IsMatch(e.Text);
|
e.Handled = !NumberRegex.IsMatch(e.Text);
|
||||||
|
|||||||
+21
-9
@@ -131,15 +131,27 @@ namespace Casino
|
|||||||
|
|
||||||
private async void Spin(object sender, RoutedEventArgs e)
|
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();
|
int einsatz = Convert.ToInt32(einsatzFeld.Text);
|
||||||
await Spin();
|
users[MainWindow.currentUser].Geld -= einsatz;
|
||||||
users[MainWindow.currentUser].Geld += CheckWin(currentSlot,einsatz);
|
Konto.Text = users[MainWindow.currentUser].Geld.ToString();
|
||||||
Konto.Text = users[MainWindow.currentUser].Geld.ToString();
|
await Spin();
|
||||||
db.UpdateGeld(
|
users[MainWindow.currentUser].Geld += CheckWin(currentSlot, einsatz);
|
||||||
users[MainWindow.currentUser].ID,
|
Konto.Text = users[MainWindow.currentUser].Geld.ToString();
|
||||||
users[MainWindow.currentUser].Geld);
|
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)
|
private void Hauptmenue(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user