diff --git a/backend/src/main/java/de/szut/casino/blackjack/BlackJackGameEntity.java b/backend/src/main/java/de/szut/casino/blackjack/BlackJackGameEntity.java index 0dbfcc0..4f22c9d 100644 --- a/backend/src/main/java/de/szut/casino/blackjack/BlackJackGameEntity.java +++ b/backend/src/main/java/de/szut/casino/blackjack/BlackJackGameEntity.java @@ -24,10 +24,6 @@ public class BlackJackGameEntity { @GeneratedValue private Long id; - @Version - @JsonIgnore - private Long version; - @ManyToOne @JoinColumn(name = "user_id", nullable = false) @JsonIgnore diff --git a/backend/src/main/java/de/szut/casino/blackjack/CardEntity.java b/backend/src/main/java/de/szut/casino/blackjack/CardEntity.java index 27d09d6..5520b58 100644 --- a/backend/src/main/java/de/szut/casino/blackjack/CardEntity.java +++ b/backend/src/main/java/de/szut/casino/blackjack/CardEntity.java @@ -19,10 +19,6 @@ public class CardEntity { @JsonIgnore private Long id; - @Version - @JsonIgnore - private Long version; - @ManyToOne @JoinColumn(name = "game_id", nullable = false) @JsonBackReference diff --git a/frontend/src/app/enum/gameState.ts b/frontend/src/app/enum/gameState.ts new file mode 100644 index 0000000..69e3ddf --- /dev/null +++ b/frontend/src/app/enum/gameState.ts @@ -0,0 +1,6 @@ +export enum GameState { + PLAYER_WON = 'PLAYER_WON', + IN_PROGRESS = 'IN_PROGRESS', + PLAYER_LOST = 'PLAYER_LOST', + DRAW = 'DRAW', +} diff --git a/frontend/src/app/feature/deposit/deposit.component.ts b/frontend/src/app/feature/deposit/deposit.component.ts index bb38fc9..6cbae07 100644 --- a/frontend/src/app/feature/deposit/deposit.component.ts +++ b/frontend/src/app/feature/deposit/deposit.component.ts @@ -16,12 +16,12 @@ import { } from '@angular/core'; import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; import { loadStripe, Stripe } from '@stripe/stripe-js'; -import { DepositService } from '../../service/deposit.service'; import { debounceTime } from 'rxjs'; -import { environment } from '../../../environments/environment'; import { NgIf } from '@angular/common'; -import { ModalAnimationService } from '../../shared/services/modal-animation.service'; import gsap from 'gsap'; +import { DepositService } from '@service/deposit.service'; +import { environment } from '@environments/environment'; +import { ModalAnimationService } from '@shared/services/modal-animation.service'; @Component({ selector: 'app-deposit', diff --git a/frontend/src/app/feature/game/blackjack/blackjack.component.html b/frontend/src/app/feature/game/blackjack/blackjack.component.html index c47d2f6..887aeeb 100644 --- a/frontend/src/app/feature/game/blackjack/blackjack.component.html +++ b/frontend/src/app/feature/game/blackjack/blackjack.component.html @@ -49,5 +49,5 @@ [gameState]="gameState()" [amount]="currentBet()" [show]="showGameResult()" - (close)="onCloseGameResult()" + (gameResultClosed)="onCloseGameResult()" > diff --git a/frontend/src/app/feature/game/blackjack/blackjack.component.ts b/frontend/src/app/feature/game/blackjack/blackjack.component.ts index 5b5ad42..3780228 100644 --- a/frontend/src/app/feature/game/blackjack/blackjack.component.ts +++ b/frontend/src/app/feature/game/blackjack/blackjack.component.ts @@ -1,8 +1,6 @@ import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { NavbarComponent } from '../../../shared/components/navbar/navbar.component'; import { Router } from '@angular/router'; -import { UserService } from '../../../service/user.service'; import { PlayingCardComponent } from './components/playing-card/playing-card.component'; import { DealerHandComponent } from './components/dealer-hand/dealer-hand.component'; import { PlayerHandComponent } from './components/player-hand/player-hand.component'; @@ -12,6 +10,9 @@ import { Card, BlackjackGame } from './models/blackjack.model'; import { BlackjackService } from './services/blackjack.service'; import { HttpErrorResponse } from '@angular/common/http'; import { GameResultComponent } from './components/game-result/game-result.component'; +import { GameState } from '../../../enum/gameState'; +import { NavbarComponent } from '../../../shared/components/navbar/navbar.component'; +import { UserService } from '../../../service/user.service'; @Component({ selector: 'app-blackjack', @@ -40,7 +41,7 @@ export default class BlackjackComponent { balance = signal(0); currentGameId = signal(undefined); gameInProgress = signal(false); - gameState = signal('IN_PROGRESS'); + gameState = signal(GameState.IN_PROGRESS); showGameResult = signal(false); isActionInProgress = signal(false); @@ -60,15 +61,15 @@ export default class BlackjackComponent { console.log('Game state update:', game); this.currentGameId.set(game.id); this.currentBet.set(game.bet); - this.gameInProgress.set(game.state === 'IN_PROGRESS'); - this.gameState.set(game.state); + this.gameInProgress.set(game.state === GameState.IN_PROGRESS); + this.gameState.set(game.state as GameState); - const isGameOver = game.state !== 'IN_PROGRESS'; + const isGameOver = game.state !== GameState.IN_PROGRESS; this.dealerCards.set( game.dealerCards.map((card, index) => ({ ...card, - hidden: !isGameOver && index === 1 && game.state === 'IN_PROGRESS', + hidden: !isGameOver && index === 1 && game.state === GameState.IN_PROGRESS, })) ); @@ -127,7 +128,7 @@ export default class BlackjackComponent { onStand(): void { if (!this.currentGameId() || this.isActionInProgress()) return; - if (this.gameState() !== 'IN_PROGRESS') { + if (this.gameState() !== GameState.IN_PROGRESS) { console.log('Cannot stand: game is not in progress'); return; } @@ -151,7 +152,7 @@ export default class BlackjackComponent { onDoubleDown(): void { if (!this.currentGameId() || this.isActionInProgress()) return; - if (this.gameState() !== 'IN_PROGRESS' || this.playerCards().length !== 2) { + if (this.gameState() !== GameState.IN_PROGRESS || this.playerCards().length !== 2) { console.log('Cannot double down: game is not in progress or more than 2 cards'); return; } diff --git a/frontend/src/app/feature/game/blackjack/components/dealer-hand/dealer-hand.component.ts b/frontend/src/app/feature/game/blackjack/components/dealer-hand/dealer-hand.component.ts index 50ff0cf..45174ca 100644 --- a/frontend/src/app/feature/game/blackjack/components/dealer-hand/dealer-hand.component.ts +++ b/frontend/src/app/feature/game/blackjack/components/dealer-hand/dealer-hand.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { Card } from '@blackjack/models/blackjack.model'; import { PlayingCardComponent } from '../playing-card/playing-card.component'; -import { Card } from '../../models/blackjack.model'; @Component({ selector: 'app-dealer-hand', diff --git a/frontend/src/app/feature/game/blackjack/components/game-controls/game-controls.component.ts b/frontend/src/app/feature/game/blackjack/components/game-controls/game-controls.component.ts index 9922309..8a65f40 100644 --- a/frontend/src/app/feature/game/blackjack/components/game-controls/game-controls.component.ts +++ b/frontend/src/app/feature/game/blackjack/components/game-controls/game-controls.component.ts @@ -1,6 +1,8 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; import { CommonModule } from '@angular/common'; import { Card } from '../../models/blackjack.model'; +import { GameState } from '../../../../../enum/gameState'; +import { GameControlsService } from '../../services/game-controls.service'; @Component({ selector: 'app-game-controls', @@ -11,10 +13,13 @@ import { Card } from '../../models/blackjack.model';
- Deine Punkte: {{ calculateHandValue(playerCards) }} + Deine Punkte: {{ gameControlsService.calculateHandValue(playerCards) }}
- Status: {{ getStatusText(gameState) }} + Status: + {{ + gameControlsService.getStatusText(gameState) + }}
@@ -22,7 +27,7 @@ import { Card } from '../../models/blackjack.model';