Aufteilung
This commit is contained in:
+37
-63
@@ -15,7 +15,7 @@ namespace Casino
|
||||
{
|
||||
public partial class Busfahrer : Window
|
||||
{
|
||||
public class Card
|
||||
public class Card //Colin Langer
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string WertRaw { get; set; } = string.Empty;
|
||||
@@ -25,11 +25,9 @@ namespace Casino
|
||||
|
||||
public bool IsRed =>
|
||||
FarbeRaw.Equals("Hearts", StringComparison.OrdinalIgnoreCase) ||
|
||||
FarbeRaw.Equals("Diamonds", StringComparison.OrdinalIgnoreCase) ||
|
||||
FarbeRaw.Equals("Diamond", StringComparison.OrdinalIgnoreCase) ||
|
||||
FarbeRaw.Equals("Herz", StringComparison.OrdinalIgnoreCase) ||
|
||||
FarbeRaw.Equals("Karo", StringComparison.OrdinalIgnoreCase);
|
||||
FarbeRaw.Equals("Diamond", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
//Colin Langer
|
||||
public Card(int id, string wert, string farbe, byte[] imgBytes)
|
||||
{
|
||||
Id = id;
|
||||
@@ -42,19 +40,19 @@ namespace Casino
|
||||
Image = ByteArrayToImage(imgBytes);
|
||||
}
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private static int ParseValue(string wert)
|
||||
{
|
||||
return wert.Trim() switch
|
||||
{
|
||||
"Jack" or "Bube" => 11,
|
||||
"Queen" or "Dame" => 12,
|
||||
"King" or "König" => 13,
|
||||
"Ace" or "Ass" => 14,
|
||||
"Jack" => 11,
|
||||
"Queen" => 12,
|
||||
"King" => 13,
|
||||
"Ace" => 14,
|
||||
_ => int.TryParse(wert, out int value) ? value : 0
|
||||
};
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private static BitmapImage ByteArrayToImage(byte[] bytes)
|
||||
{
|
||||
BitmapImage image = new BitmapImage();
|
||||
@@ -98,30 +96,23 @@ namespace Casino
|
||||
|
||||
private User CurrentUser => users[MainWindow.currentUser];
|
||||
|
||||
// =========================
|
||||
// KONTO
|
||||
// =========================
|
||||
|
||||
// Lenard Gerdes
|
||||
private void UpdateAccountDisplay()
|
||||
{
|
||||
Konto.Text = CurrentUser.Geld.ToString();
|
||||
}
|
||||
|
||||
// Lenard Gerdes
|
||||
private void SaveAccount()
|
||||
{
|
||||
db.UpdateGeld(CurrentUser.ID, CurrentUser.Geld);
|
||||
UpdateAccountDisplay();
|
||||
}
|
||||
|
||||
// =========================
|
||||
// SPIEL STARTEN
|
||||
// =========================
|
||||
|
||||
//Colin Langer
|
||||
private void BtnStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
StartGameFromInput();
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private void StartGameFromInput()
|
||||
{
|
||||
if (roundRunning)
|
||||
@@ -154,7 +145,7 @@ namespace Casino
|
||||
currentBet = bet;
|
||||
StartRound();
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private void StartRound()
|
||||
{
|
||||
try
|
||||
@@ -190,7 +181,7 @@ namespace Casino
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private void LoadCards()
|
||||
{
|
||||
deck = db.GetAllCards()
|
||||
@@ -211,7 +202,7 @@ namespace Casino
|
||||
handCards.Add(DrawCard());
|
||||
}
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private Card DrawCard()
|
||||
{
|
||||
Card card = deck[0];
|
||||
@@ -222,7 +213,7 @@ namespace Casino
|
||||
// =========================
|
||||
// KARTEN ANZEIGEN
|
||||
// =========================
|
||||
|
||||
//Colin Langer
|
||||
private void UpdateHandUI()
|
||||
{
|
||||
Bild_1.Source = cardBackImage;
|
||||
@@ -286,7 +277,7 @@ namespace Casino
|
||||
// =========================
|
||||
// SPIELLOGIK
|
||||
// =========================
|
||||
|
||||
// Lenard Gerdes
|
||||
private async Task ProcessGuessAsync(bool success)
|
||||
{
|
||||
if (!roundRunning)
|
||||
@@ -345,7 +336,7 @@ namespace Casino
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private decimal CalculateCurrentProfit()
|
||||
{
|
||||
return currentPhase switch
|
||||
@@ -357,11 +348,7 @@ namespace Casino
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
// =========================
|
||||
// FRAGEN
|
||||
// =========================
|
||||
|
||||
//Colin Langer
|
||||
private async void ColorButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is not Button button)
|
||||
@@ -383,7 +370,7 @@ namespace Casino
|
||||
|
||||
await ProcessGuessAsync(success);
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private async void HigherLowerButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is not Button button)
|
||||
@@ -402,7 +389,7 @@ namespace Casino
|
||||
|
||||
await ProcessGuessAsync(success);
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private async void InsideOutsideButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is not Button button)
|
||||
@@ -424,7 +411,7 @@ namespace Casino
|
||||
|
||||
await ProcessGuessAsync(success);
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private async void BtnSuit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is not Button button || button.Tag == null)
|
||||
@@ -439,7 +426,7 @@ namespace Casino
|
||||
|
||||
await ProcessGuessAsync(success);
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private static bool IsSameSuit(string cardSuit, string chosenSuit)
|
||||
{
|
||||
if (cardSuit.Equals(chosenSuit, StringComparison.OrdinalIgnoreCase))
|
||||
@@ -449,25 +436,20 @@ namespace Casino
|
||||
|
||||
return chosenSuit switch
|
||||
{
|
||||
"Hearts" => cardSuit.Equals("Herz", StringComparison.OrdinalIgnoreCase),
|
||||
"Diamonds" => cardSuit.Equals("Karo", StringComparison.OrdinalIgnoreCase) ||
|
||||
cardSuit.Equals("Diamond", StringComparison.OrdinalIgnoreCase),
|
||||
"Spades" => cardSuit.Equals("Pik", StringComparison.OrdinalIgnoreCase),
|
||||
"Clubs" => cardSuit.Equals("Kreuz", StringComparison.OrdinalIgnoreCase),
|
||||
"Hearts" => cardSuit.Equals("Hearts", StringComparison.OrdinalIgnoreCase),
|
||||
"Diamonds" => cardSuit.Equals("Diamond", StringComparison.OrdinalIgnoreCase),
|
||||
"Spades" => cardSuit.Equals("Spades", StringComparison.OrdinalIgnoreCase),
|
||||
"Clubs" => cardSuit.Equals("Clubs", StringComparison.OrdinalIgnoreCase),
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private enum CardColor
|
||||
{
|
||||
Red,
|
||||
Black
|
||||
}
|
||||
|
||||
// =========================
|
||||
// CASH OUT
|
||||
// =========================
|
||||
|
||||
//Colin Langer
|
||||
private void BtnCashOut_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!roundRunning || currentProfit <= 0)
|
||||
@@ -488,7 +470,7 @@ namespace Casino
|
||||
|
||||
ShowWaitingState();
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private void PayoutCurrentProfit()
|
||||
{
|
||||
if (currentProfit <= 0)
|
||||
@@ -503,7 +485,7 @@ namespace Casino
|
||||
// =========================
|
||||
// UI
|
||||
// =========================
|
||||
|
||||
//Colin Langer
|
||||
private void SetPhaseUI()
|
||||
{
|
||||
PanelRedBlack.Visibility = Visibility.Collapsed;
|
||||
@@ -541,7 +523,7 @@ namespace Casino
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private void ShowWaitingState()
|
||||
{
|
||||
roundRunning = false;
|
||||
@@ -554,26 +536,18 @@ namespace Casino
|
||||
BtnStart.Visibility = Visibility.Visible;
|
||||
TxtBet.IsEnabled = true;
|
||||
}
|
||||
|
||||
//Colin Langer
|
||||
private void UpdateWinDisplay()
|
||||
{
|
||||
BtnCashOut.Content = $"Cash Out (${currentProfit:F2})";
|
||||
}
|
||||
|
||||
// =========================
|
||||
// HAUPTMENÜ
|
||||
// =========================
|
||||
|
||||
//Colin Langer
|
||||
private void Hauptmenue(object sender, RoutedEventArgs e)
|
||||
{
|
||||
music.Stop();
|
||||
Close();
|
||||
}
|
||||
|
||||
// =========================
|
||||
// BILD AUS BYTE[]
|
||||
// =========================
|
||||
|
||||
//Colin Langer
|
||||
private static BitmapImage ByteArrayToImage(byte[] bytes)
|
||||
{
|
||||
BitmapImage image = new BitmapImage();
|
||||
@@ -591,7 +565,7 @@ namespace Casino
|
||||
}
|
||||
|
||||
// =========================
|
||||
// EINSATZ VALIDIERUNG
|
||||
// EINSATZfeld Colin Langer
|
||||
// =========================
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user