Skip to content

Commit 554e4df

Browse files
committed
fix: detecting five card trick
fixes #26
1 parent 751d8e4 commit 554e4df

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/components/Card/hooks/useCardPile.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ export function useCardPile() {
1414
const bust = useRef<boolean>(false);
1515
const fiveCardTrick = useRef<boolean>(false);
1616
const allCardsVisible = useRef<boolean>(false);
17-
const {play} = useAudioPlayer();
17+
const { play } = useAudioPlayer();
1818

1919
/**
2020
* Add cards to the pile
2121
* @param cardsToAdd The cards to be added to the pile
2222
* @param facing The direction the card should be facing when placed in the pile
2323
*/
2424
function addCards(cardsToAdd: CardObject[], facing: Facing | null = null) {
25-
cardsToAdd.forEach(card => {
26-
play('cardDealt');
25+
cardsToAdd.forEach((card) => {
26+
play("cardDealt");
2727
if (facing) card.facing = facing;
2828
});
2929
setCards([...cards].concat(cardsToAdd));
@@ -45,8 +45,9 @@ export function useCardPile() {
4545

4646
bestHand.current = calculateBestHand(cardsToSet);
4747
bust.current = bestHand.current.score > 21;
48-
fiveCardTrick.current = cards.length === 5 && bestHand.current.score <= 21;
49-
48+
fiveCardTrick.current =
49+
cardsToSet.length === 5 && bestHand.current.score <= 21;
50+
5051
setCardsState(cardsToSet);
5152
}
5253

0 commit comments

Comments
 (0)