refactor(blackjack): remove unnecessary comments and clean code
All checks were successful
All checks were successful
This commit is contained in:
parent
23888ceb27
commit
05322e3d83
4 changed files with 0 additions and 9 deletions
|
@ -6,7 +6,6 @@
|
||||||
<app-dealer-hand [cards]="dealerCards()"></app-dealer-hand>
|
<app-dealer-hand [cards]="dealerCards()"></app-dealer-hand>
|
||||||
<app-player-hand [cards]="playerCards()"></app-player-hand>
|
<app-player-hand [cards]="playerCards()"></app-player-hand>
|
||||||
|
|
||||||
<!-- Action message indicator -->
|
|
||||||
@if (isActionInProgress()) {
|
@if (isActionInProgress()) {
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center">
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -43,7 +43,6 @@ export default class BlackjackComponent {
|
||||||
gameState = signal<string>('IN_PROGRESS');
|
gameState = signal<string>('IN_PROGRESS');
|
||||||
showGameResult = signal(false);
|
showGameResult = signal(false);
|
||||||
|
|
||||||
// Add loading state trackers
|
|
||||||
isActionInProgress = signal(false);
|
isActionInProgress = signal(false);
|
||||||
currentAction = signal<string>('');
|
currentAction = signal<string>('');
|
||||||
|
|
||||||
|
@ -64,7 +63,6 @@ export default class BlackjackComponent {
|
||||||
this.gameInProgress.set(game.state === 'IN_PROGRESS');
|
this.gameInProgress.set(game.state === 'IN_PROGRESS');
|
||||||
this.gameState.set(game.state);
|
this.gameState.set(game.state);
|
||||||
|
|
||||||
// When game ends, make sure all dealer cards are visible
|
|
||||||
const isGameOver = game.state !== 'IN_PROGRESS';
|
const isGameOver = game.state !== 'IN_PROGRESS';
|
||||||
|
|
||||||
this.dealerCards.set(
|
this.dealerCards.set(
|
||||||
|
@ -81,12 +79,10 @@ export default class BlackjackComponent {
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|
||||||
// Only refresh and show game result if the game has ended
|
|
||||||
if (isGameOver) {
|
if (isGameOver) {
|
||||||
console.log('Game is over, state:', game.state);
|
console.log('Game is over, state:', game.state);
|
||||||
this.refreshUserBalance();
|
this.refreshUserBalance();
|
||||||
|
|
||||||
// Show result immediately without resetting first
|
|
||||||
this.showGameResult.set(true);
|
this.showGameResult.set(true);
|
||||||
console.log('Game result dialog should be shown now');
|
console.log('Game result dialog should be shown now');
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,13 +48,11 @@ export class DealerHandComponent implements OnChanges {
|
||||||
const newCards = this.cards.length > this.lastCardCount;
|
const newCards = this.cards.length > this.lastCardCount;
|
||||||
|
|
||||||
this.cardsWithState = this.cards.map((card, index) => {
|
this.cardsWithState = this.cards.map((card, index) => {
|
||||||
// Consider a card new if it's added after the initial state and is the latest card
|
|
||||||
const isNew = newCards && index >= this.lastCardCount;
|
const isNew = newCards && index >= this.lastCardCount;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...card,
|
...card,
|
||||||
isNew,
|
isNew,
|
||||||
// Generate a unique ID to help Angular track the cards
|
|
||||||
id: `${card.suit}-${card.rank}-${index}`,
|
id: `${card.suit}-${card.rank}-${index}`,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -50,13 +50,11 @@ export class PlayerHandComponent implements OnChanges {
|
||||||
const newCards = this.cards.length > this.lastCardCount;
|
const newCards = this.cards.length > this.lastCardCount;
|
||||||
|
|
||||||
this.cardsWithState = this.cards.map((card, index) => {
|
this.cardsWithState = this.cards.map((card, index) => {
|
||||||
// Consider a card new if it's added after the initial state and is the latest card
|
|
||||||
const isNew = newCards && index >= this.lastCardCount;
|
const isNew = newCards && index >= this.lastCardCount;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...card,
|
...card,
|
||||||
isNew,
|
isNew,
|
||||||
// Generate a unique ID to help Angular track the cards
|
|
||||||
id: `${card.suit}-${card.rank}-${index}`,
|
id: `${card.suit}-${card.rank}-${index}`,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue