feat: add stand and get game features to blackjack game with animations #105

Merged
jleibl merged 22 commits from task/CAS-50/add_rest_blackjack_logic_with_frontend_animations into main 2025-04-02 08:28:43 +00:00
3 changed files with 18 additions and 10 deletions
Showing only changes of commit 4a7c54eab8 - Show all commits

View file

@ -106,7 +106,8 @@ export class GameResultComponent {
} }
getResultMessage(): string { getResultMessage(): string {
if (this.gameState === GameState.PLAYER_BLACKJACK) return 'Glückwunsch! Du hast mit einem Blackjack gewonnen!'; if (this.gameState === GameState.PLAYER_BLACKJACK)
return 'Glückwunsch! Du hast mit einem Blackjack gewonnen!';
if (this.isWin) return 'Glückwunsch! Du hast diese Runde gewonnen.'; if (this.isWin) return 'Glückwunsch! Du hast diese Runde gewonnen.';
if (this.isLoss) return 'Schade! Du hast diese Runde verloren.'; if (this.isLoss) return 'Schade! Du hast diese Runde verloren.';
if (this.isDraw) return 'Diese Runde endet unentschieden. Dein Einsatz wurde zurückgegeben.'; if (this.isDraw) return 'Diese Runde endet unentschieden. Dein Einsatz wurde zurückgegeben.';

View file

@ -20,14 +20,14 @@ export class UserService {
public getUser(id: string): Observable<User | null> { public getUser(id: string): Observable<User | null> {
return this.http.get<User | null>(`/backend/user/${id}`).pipe( return this.http.get<User | null>(`/backend/user/${id}`).pipe(
catchError(() => EMPTY), catchError(() => EMPTY),
tap(user => this.currentUserSubject.next(user)) tap((user) => this.currentUserSubject.next(user))
); );
} }
public getCurrentUser(): Observable<User | null> { public getCurrentUser(): Observable<User | null> {
return this.http.get<User | null>('/backend/user').pipe( return this.http.get<User | null>('/backend/user').pipe(
catchError(() => EMPTY), catchError(() => EMPTY),
tap(user => this.currentUserSubject.next(user)) tap((user) => this.currentUserSubject.next(user))
); );
} }
@ -36,12 +36,12 @@ export class UserService {
} }
public createUser(id: string, username: string): Observable<User> { public createUser(id: string, username: string): Observable<User> {
return this.http.post<User>('/backend/user', { return this.http
keycloakId: id, .post<User>('/backend/user', {
username: username, keycloakId: id,
}).pipe( username: username,
tap(user => this.currentUserSubject.next(user)) })
); .pipe(tap((user) => this.currentUserSubject.next(user)));
} }
public async getOrCreateUser(userProfile: KeycloakProfile) { public async getOrCreateUser(userProfile: KeycloakProfile) {

View file

@ -1,4 +1,11 @@
import { ChangeDetectionStrategy, Component, inject, OnInit, OnDestroy, signal } from '@angular/core'; import {
ChangeDetectionStrategy,
Component,
inject,
OnInit,
OnDestroy,
signal,
} from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { KeycloakService } from 'keycloak-angular'; import { KeycloakService } from 'keycloak-angular';
import { CurrencyPipe } from '@angular/common'; import { CurrencyPipe } from '@angular/common';