Skip to content

Commit

Permalink
client:Implement drawing cards from the deck
Browse files Browse the repository at this point in the history
This commit adds the ability for a player to draw card by clicking on
the back uno card.On hovering the cursor changes to pointer and on
clicking it triggers the event.

fixes #160
  • Loading branch information
ritwik-69 committed Jun 25, 2024
1 parent 4191a64 commit e9a1fc4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontend/src/pages/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Button from '../library/button';
import { useModal } from '../library/modal/ModalContext';
import CopyButton from '../library/copyButton';
import Chatbox from '../library/chatbox/Chatbox';
import { GameEventTypes } from '../../../backend/src/types';
import * as channel from '../channel';

function Game() {
const { gameState } = useGameContext();
Expand All @@ -14,6 +16,11 @@ function Game() {
}
// eslint-disable-next-line
}, [gameState]);
const drawCard = () => {
channel.triggerEvent({
type: GameEventTypes.DRAW_CARD,
});
};

function GamePropertiesModal() {
return (
Expand Down Expand Up @@ -114,7 +121,8 @@ function Game() {
<img
src="/card_faces/back.jpeg"
alt="Card 1"
className="w-15 h-20"
className="w-15 h-20 cursor-pointer"
onClick={drawCard}
/>
<img
src={
Expand Down

0 comments on commit e9a1fc4

Please sign in to comment.