Skip to content

Commit

Permalink
Fix: 문제지 선택 시 모든 유저가 요청 보내는 문제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
leewooseong committed May 19, 2024
1 parent 7252f00 commit 4407d31
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions frontend/app/(page)/(needProtection)/game/component/AnswerSpot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { Center, Cylinder, Text3D } from '@react-three/drei'
import { CylinderCollider, RigidBody } from '@react-three/rapier'
import React, { useEffect } from 'react'
import { AnswerEnum, gameStateEnum } from '../lib/store-type'
import { useAnswerSelectStore, useGameRoomStore, useRoundResultStore } from '../lib/store'
import {
useAnswerSelectStore,
useGameRoomStore,
usePlayerStore,
useRoundResultStore,
} from '../lib/store'
import { useGame } from '@/app/hooks/useSocket'

const AnswerSpot = () => {
Expand All @@ -12,6 +17,9 @@ const AnswerSpot = () => {
const { gameState } = useGameRoomStore((state) => ({
gameState: state.gameState,
}))
const { playerHandle } = usePlayerStore((state) => ({
playerHandle: state.playerHandle,
}))

useEffect(() => {
if (gameState === gameStateEnum.COUNTDOWN) {
Expand All @@ -25,8 +33,10 @@ const AnswerSpot = () => {
<RigidBody
colliders={false}
type="fixed"
onCollisionEnter={() => {
setSelectAnswer(answer as AnswerEnum)
onCollisionEnter={(event) => {
if (event.collider.handle === playerHandle) {
setSelectAnswer(answer as AnswerEnum)
}
selectAnswerField(answer as AnswerEnum)
}}
>
Expand Down

0 comments on commit 4407d31

Please sign in to comment.