Skip to content

Commit

Permalink
fix: backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
hellomuthu23 committed Dec 14, 2023
1 parent 8205b9f commit 3cf38b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/components/Players/CardPicker/CardPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { updatePlayerValue } from '../../../service/players';
import { Game } from '../../../types/game';
import { Player } from '../../../types/player';
import { Status } from '../../../types/status';
import { CardConfig, getRandomEmoji } from './CardConfigs';
import { CardConfig, getCards, getRandomEmoji } from './CardConfigs';
import './CardPicker.css';
import { GoogleAd } from '../../GoogleAd/GoogleAd';

Expand All @@ -26,12 +26,15 @@ export const CardPicker: React.FC<CardPickerProps> = ({ game, players, currentPl
setRandomEmoji(getRandomEmoji);
}
}, [game.gameStatus]);

const cards = game.cards?.length ? game.cards : getCards(game.gameType);

return (
<Grow in={true} timeout={1000}>
<div>
<div className='CardPickerContainer'>
<Grid container spacing={4} justify='center'>
{game.cards.map((card: CardConfig, index) => (
{cards.map((card: CardConfig, index) => (
<Grid key={card.value} item xs>
<Slide in={true} direction={'right'} timeout={(1000 * index) / 2}>
<Card
Expand Down
5 changes: 3 additions & 2 deletions src/components/Players/PlayerCard/PlayerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,16 @@ const getCardValue = (player: Player, game: Game) => {
if (player.value && player.value === -1) {
return player.emoji || '☕'; // coffee emoji
}
return getCardDisplayValue(game.cards, player.value);
return getCardDisplayValue(game, player.value);
}
return '🤔';
}
};

const getCardDisplayValue = (
cards: CardConfig[],
game: Game,
cardValue: number | undefined,
): string | number | undefined => {
const cards = game.cards?.length > 0 ? game.cards : getCards(game.gameType);
return cards.find((card) => card.value === cardValue)?.displayValue || cardValue;
};

0 comments on commit 3cf38b6

Please sign in to comment.