feat: Create Coinflip ui (CAS-64) #206

Merged
jank merged 6 commits from feat/coinflip into main 2025-05-21 09:13:35 +00:00
3 changed files with 55 additions and 0 deletions
Showing only changes of commit 41f3b506a0 - Show all commits

View file

@ -38,6 +38,11 @@ export const routes: Routes = [
loadComponent: () => import('./feature/game/blackjack/blackjack.component'), loadComponent: () => import('./feature/game/blackjack/blackjack.component'),
canActivate: [authGuard], canActivate: [authGuard],
}, },
{
path: 'game/coinflip',
loadComponent: () => import('./feature/game/coinflip/coinflip.component'),
canActivate: [authGuard],
},
{ {
path: 'game/slots', path: 'game/slots',
loadComponent: () => import('./feature/game/slots/slots.component'), loadComponent: () => import('./feature/game/slots/slots.component'),

View file

@ -0,0 +1,16 @@
<p>Coinflip works!</p>
<div class="container mx-auto">
<div class="grid grid-cols-4">
<div class="col-span-3"></div>
<div class="col-span-1">
<app-game-info
[balance]="balance()"
[currentBet]="currentBet()"
[gameInProgress]="gameInProgress()"
[isActionInProgress]="isActionInProgress()"
(newGame)="onNewGame($event)"
></app-game-info>
</div>
</div>
</div>

View file

@ -0,0 +1,34 @@
import { ChangeDetectionStrategy, Component, inject, OnInit, signal } from '@angular/core';
import { GameInfoComponent } from '@blackjack/components/game-info/game-info.component';
import { AuthService } from '@service/auth.service';
import { AudioService } from '@shared/services/audio.service';
@Component({
selector: 'app-coinflip',
standalone: true,
imports: [GameInfoComponent],
templateUrl: './coinflip.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export default class CoinflipComponent implements OnInit {
currentBet = signal(0);
balance = signal(0);
gameInProgress = signal(false);
isActionInProgress = signal(false);
audioService = inject(AudioService);
authService = inject(AuthService);
onNewGame(bet: number): void {
this.isActionInProgress.set(true);
this.audioService.playBetSound();
}
ngOnInit(): void {
// Subscribe to user updates for real-time balance changes
this.authService.userSubject.subscribe((user) => {
if (user) {
this.balance.set(user.balance);
}
});
}
}