fix: Change lang to german
All checks were successful
CI / Get Changed Files (pull_request) Successful in 8s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Has been skipped
CI / oxlint (pull_request) Successful in 25s
CI / eslint (pull_request) Successful in 27s
CI / prettier (pull_request) Successful in 31s
CI / Docker frontend validation (pull_request) Successful in 42s
CI / test-build (pull_request) Successful in 44s
All checks were successful
CI / Get Changed Files (pull_request) Successful in 8s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Has been skipped
CI / oxlint (pull_request) Successful in 25s
CI / eslint (pull_request) Successful in 27s
CI / prettier (pull_request) Successful in 31s
CI / Docker frontend validation (pull_request) Successful in 42s
CI / test-build (pull_request) Successful in 44s
This commit is contained in:
parent
c68b3f2f7e
commit
7762048ee1
2 changed files with 58 additions and 58 deletions
|
@ -44,14 +44,14 @@ export default class CoinflipComponent implements OnInit {
|
|||
private coinflipSound?: HTMLAudioElement;
|
||||
|
||||
ngOnInit(): void {
|
||||
// Subscribe to user updates for real-time balance changes
|
||||
// Abonniere Benutzerupdates für Echtzeitaktualisierungen des Guthabens
|
||||
this.authService.userSubject.subscribe((user) => {
|
||||
if (user) {
|
||||
this.balance.set(user.balance);
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize coinflip sound
|
||||
// Initialisiere Münzwurf-Sound
|
||||
this.coinflipSound = new Audio('/sounds/coinflip.mp3');
|
||||
}
|
||||
|
||||
|
@ -65,26 +65,26 @@ export default class CoinflipComponent implements OnInit {
|
|||
const inputElement = event.target as HTMLInputElement;
|
||||
let value = Number(inputElement.value);
|
||||
|
||||
// Reset invalid bet state
|
||||
// Setze ungültigen Einsatz-Status zurück
|
||||
this.isInvalidBet.set(false);
|
||||
|
||||
// Enforce minimum bet of 1
|
||||
// Erzwinge Mindesteinsatz von 1
|
||||
if (value <= 0) {
|
||||
value = 1;
|
||||
}
|
||||
|
||||
// Cap bet at available balance and show feedback
|
||||
// Begrenze Einsatz auf verfügbares Guthaben und zeige Feedback
|
||||
if (value > this.balance()) {
|
||||
value = this.balance();
|
||||
// Show visual feedback
|
||||
// Visuelles Feedback anzeigen
|
||||
this.isInvalidBet.set(true);
|
||||
// Indicate the error briefly
|
||||
// Zeige den Fehler kurz an
|
||||
setTimeout(() => this.isInvalidBet.set(false), 800);
|
||||
// Update the input field directly to show the user the max value
|
||||
// Aktualisiere das Eingabefeld direkt, um dem Benutzer den maximalen Wert anzuzeigen
|
||||
inputElement.value = String(value);
|
||||
}
|
||||
|
||||
// Update signals
|
||||
// Aktualisiere Signale
|
||||
this.betInputValue.set(value);
|
||||
this.currentBet.set(value);
|
||||
}
|
||||
|
@ -100,34 +100,34 @@ export default class CoinflipComponent implements OnInit {
|
|||
private placeBet(side: 'HEAD' | 'TAILS') {
|
||||
if (this.gameInProgress() || this.isActionInProgress()) return;
|
||||
|
||||
// Reset previous result
|
||||
// Setze vorheriges Ergebnis zurück
|
||||
this.gameResult.set(null);
|
||||
this.errorMessage.set('');
|
||||
|
||||
// Set game state
|
||||
// Setze Spielstatus
|
||||
this.gameInProgress.set(true);
|
||||
this.isActionInProgress.set(true);
|
||||
|
||||
// Play bet sound
|
||||
// Spiele Einsatz-Sound
|
||||
this.audioService.playBetSound();
|
||||
|
||||
// Create bet request
|
||||
// Erstelle Einsatz-Anfrage
|
||||
const request: CoinflipRequest = {
|
||||
betAmount: this.currentBet(),
|
||||
coinSide: side,
|
||||
};
|
||||
|
||||
// Call API
|
||||
// API aufrufen
|
||||
this.http
|
||||
.post<CoinflipGame>('/backend/coinflip', request)
|
||||
.pipe(
|
||||
catchError((error) => {
|
||||
console.error('Error playing coinflip:', error);
|
||||
console.error('Fehler beim Spielen von Coinflip:', error);
|
||||
|
||||
if (error.status === 400 && error.error.message.includes('insufficient')) {
|
||||
this.errorMessage.set('Insufficient funds');
|
||||
this.errorMessage.set('Unzureichendes Guthaben');
|
||||
} else {
|
||||
this.errorMessage.set('An error occurred. Please try again.');
|
||||
this.errorMessage.set('Ein Fehler ist aufgetreten. Bitte versuche es erneut.');
|
||||
}
|
||||
|
||||
this.gameInProgress.set(false);
|
||||
|
@ -140,37 +140,37 @@ export default class CoinflipComponent implements OnInit {
|
|||
.subscribe((result) => {
|
||||
if (!result) return;
|
||||
|
||||
console.log('API response:', result);
|
||||
console.log('API-Antwort:', result);
|
||||
|
||||
// Fix potential property naming inconsistency from the backend
|
||||
// Behebe mögliche Inkonsistenzen bei der Eigenschaftenbenennung vom Backend
|
||||
const fixedResult: CoinflipGame = {
|
||||
isWin: result.isWin ?? result.win,
|
||||
payout: result.payout,
|
||||
coinSide: result.coinSide,
|
||||
};
|
||||
|
||||
console.log('Fixed result:', fixedResult);
|
||||
console.log('Korrigiertes Ergebnis:', fixedResult);
|
||||
|
||||
// Play coin flip animation and sound
|
||||
// Spiele Münzwurf-Animation und -Sound
|
||||
this.playCoinFlipAnimation(fixedResult.coinSide);
|
||||
|
||||
// Set result after animation completes
|
||||
// Setze Ergebnis nach Abschluss der Animation
|
||||
setTimeout(() => {
|
||||
this.gameResult.set(fixedResult);
|
||||
|
||||
// Update balance with new value from auth service
|
||||
// Aktualisiere Guthaben mit neuem Wert vom Auth-Service
|
||||
this.authService.loadCurrentUser();
|
||||
|
||||
// Play win sound if player won
|
||||
// Spiele Gewinn-Sound, wenn der Spieler gewonnen hat
|
||||
if (fixedResult.isWin) {
|
||||
this.audioService.playWinSound();
|
||||
}
|
||||
|
||||
// Reset game state after showing result
|
||||
// Setze Spielstatus nach Anzeigen des Ergebnisses zurück
|
||||
setTimeout(() => {
|
||||
this.gameInProgress.set(false);
|
||||
}, 1500);
|
||||
}, 1100); // Just after animation ends
|
||||
}, 1100); // Kurz nach Ende der Animation
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -179,48 +179,50 @@ export default class CoinflipComponent implements OnInit {
|
|||
|
||||
const coinEl = this.coinElement.nativeElement;
|
||||
|
||||
// Reset any existing animations
|
||||
// Setze bestehende Animationen zurück
|
||||
coinEl.classList.remove('animate-to-heads', 'animate-to-tails');
|
||||
|
||||
// Reset any inline styles from previous animations
|
||||
// Setze alle Inline-Styles von vorherigen Animationen zurück
|
||||
coinEl.style.transform = '';
|
||||
|
||||
// Force a reflow to restart animation
|
||||
// Erzwinge Reflow, um Animation neu zu starten
|
||||
void coinEl.offsetWidth;
|
||||
|
||||
// Play flip sound
|
||||
// Spiele Münzwurf-Sound
|
||||
if (this.coinflipSound) {
|
||||
this.coinflipSound.currentTime = 0;
|
||||
this.coinflipSound.play().catch((err) => console.error('Error playing sound:', err));
|
||||
this.coinflipSound
|
||||
.play()
|
||||
.catch((err) => console.error('Fehler beim Abspielen des Sounds:', err));
|
||||
}
|
||||
|
||||
// Add appropriate animation class based on result
|
||||
// Füge passende Animationsklasse basierend auf dem Ergebnis hinzu
|
||||
if (result === 'HEAD') {
|
||||
coinEl.classList.add('animate-to-heads');
|
||||
} else {
|
||||
coinEl.classList.add('animate-to-tails');
|
||||
}
|
||||
|
||||
console.log(`Animation applied for result: ${result}`);
|
||||
console.log(`Animation angewendet für Ergebnis: ${result}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates input as the user types to prevent invalid values
|
||||
* Validiert Eingabe während der Benutzer tippt, um ungültige Werte zu verhindern
|
||||
*/
|
||||
validateBetInput(event: KeyboardEvent) {
|
||||
// Allow navigation keys (arrows, delete, backspace, tab)
|
||||
// Erlaube Navigationstasten (Pfeile, Entf, Rücktaste, Tab)
|
||||
const navigationKeys = ['ArrowLeft', 'ArrowRight', 'Delete', 'Backspace', 'Tab'];
|
||||
if (navigationKeys.includes(event.key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only allow numbers
|
||||
// Erlaube nur Zahlen
|
||||
if (!/^\d$/.test(event.key)) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the value that would result after the keypress
|
||||
// Ermittle den Wert, der nach dem Tastendruck entstehen würde
|
||||
const input = event.target as HTMLInputElement;
|
||||
const currentValue = input.value;
|
||||
const cursorPosition = input.selectionStart || 0;
|
||||
|
@ -230,14 +232,14 @@ export default class CoinflipComponent implements OnInit {
|
|||
currentValue.substring(input.selectionEnd || cursorPosition);
|
||||
const numValue = Number(newValue);
|
||||
|
||||
// Prevent values greater than balance
|
||||
// Verhindere Werte, die größer als das Guthaben sind
|
||||
if (numValue > this.balance()) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
// We removed the paste handler for simplicity since the updateBet method
|
||||
// will handle any value that gets into the input field
|
||||
// Der Paste-Handler wurde der Einfachheit halber entfernt, da die updateBet-Methode
|
||||
// jeden Wert behandelt, der in das Eingabefeld gelangt
|
||||
|
||||
getResultClass() {
|
||||
if (!this.gameResult()) return '';
|
||||
|
|
Reference in a new issue