feat(blackjack): implement game start and controls functionality
All checks were successful
All checks were successful
This commit is contained in:
parent
d0ba0eb71d
commit
99f9f8d3c3
9 changed files with 320 additions and 54 deletions
|
@ -1,5 +1,6 @@
|
|||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { suitSymbols, Suit } from '../../models/blackjack.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-playing-card',
|
||||
|
@ -10,21 +11,49 @@ import { CommonModule } from '@angular/common';
|
|||
class="w-24 h-36 rounded-lg p-2 relative flex flex-col justify-between shadow-lg"
|
||||
[class]="hidden ? 'bg-red-800' : 'bg-white'"
|
||||
>
|
||||
<span *ngIf="!hidden" class="text-xl font-bold text-accent-red">{{ value }}</span>
|
||||
<span
|
||||
*ngIf="!hidden"
|
||||
class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-3xl text-accent-red"
|
||||
>{{ suit }}</span
|
||||
>
|
||||
<span *ngIf="!hidden" class="text-xl font-bold text-accent-red self-end rotate-180">{{
|
||||
value
|
||||
}}</span>
|
||||
@if (!hidden) {
|
||||
<span class="text-xl font-bold text-accent-red">{{ getDisplayRank(rank) }}</span>
|
||||
}
|
||||
@if (!hidden) {
|
||||
<span
|
||||
class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-3xl text-accent-red"
|
||||
>{{ getSuitSymbol(suit) }}</span
|
||||
>
|
||||
}
|
||||
@if (!hidden) {
|
||||
<span class="text-xl font-bold text-accent-red self-end rotate-180">{{
|
||||
getDisplayRank(rank)
|
||||
}}</span>
|
||||
}
|
||||
</div>
|
||||
`,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class PlayingCardComponent {
|
||||
@Input({ required: true }) value!: string;
|
||||
@Input({ required: true }) suit!: string;
|
||||
@Input({ required: true }) rank!: string;
|
||||
@Input({ required: true }) suit!: Suit;
|
||||
@Input({ required: true }) hidden!: boolean;
|
||||
|
||||
protected getSuitSymbol(suit: Suit): string {
|
||||
return suitSymbols[suit];
|
||||
}
|
||||
|
||||
protected getDisplayRank(rank: string): string {
|
||||
const rankMap: Record<string, string> = {
|
||||
TWO: '2',
|
||||
THREE: '3',
|
||||
FOUR: '4',
|
||||
FIVE: '5',
|
||||
SIX: '6',
|
||||
SEVEN: '7',
|
||||
EIGHT: '8',
|
||||
NINE: '9',
|
||||
TEN: '10',
|
||||
JACK: 'J',
|
||||
QUEEN: 'Q',
|
||||
KING: 'K',
|
||||
ACE: 'A',
|
||||
};
|
||||
return rankMap[rank] || rank;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue