From 06f31a46186268f56aeb438a33ac2e3ab0d5752b Mon Sep 17 00:00:00 2001 From: Bumang-Cyber Date: Thu, 14 Mar 2024 07:57:01 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=84=B1=EA=B3=B5=20=ED=9B=84=20?= =?UTF-8?q?=EB=A0=88=EB=B2=A8=20=EC=A0=84=ED=99=98=20=EC=8B=9C=20=ED=94=8C?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=20=EC=83=81=ED=83=9C=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=ED=99=94=20=EC=95=88=20=EB=90=98=EB=8A=94=20=EB=AC=B8=EC=A0=9C?= =?UTF-8?q?=20=ED=95=B4=EA=B2=B0,=20=EB=AC=BC=EC=9D=8C=ED=91=9C=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=EC=97=90=EC=84=9C=20open=20=EC=8B=9C=20?= =?UTF-8?q?=EB=AC=BC=EC=9D=8C=ED=91=9C=20=EB=A7=88=ED=81=AC=EA=B0=80=20?= =?UTF-8?q?=EB=82=A8=EB=8A=94=20=ED=98=84=EC=83=81=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Game/TileMapPanel/Tile/index.tsx | 1 + src/hooks/useLevelSwitch.ts | 12 ++++++++---- src/hooks/useTileSwitch.ts | 2 +- src/utils/detectByBfs.ts | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/Game/TileMapPanel/Tile/index.tsx b/src/components/Game/TileMapPanel/Tile/index.tsx index a75ddcb..a22c083 100644 --- a/src/components/Game/TileMapPanel/Tile/index.tsx +++ b/src/components/Game/TileMapPanel/Tile/index.tsx @@ -50,6 +50,7 @@ const Tile = ({ item, tileMapArr, onSetTileMap, rowIndex, colIndex }: TileProps) } if (isQuestioned) { + console.log(isFlagged, isMined, isOpened, isQuestioned, mineNearby, "?ITEM"); return ( diff --git a/src/hooks/useLevelSwitch.ts b/src/hooks/useLevelSwitch.ts index c4455eb..9fdac86 100644 --- a/src/hooks/useLevelSwitch.ts +++ b/src/hooks/useLevelSwitch.ts @@ -4,9 +4,10 @@ import { change } from "@store/levelSlice"; import { type RootState } from "@store/index"; import { type LevelKeyType, type LevelValueType } from "@/types/level"; import { levels } from "@/constants/level"; +import usePlayingSwitch from "./usePlayingSwitch"; const useLevelSwitch = () => { - // useLevelSwitch 훅으로 정리하기 (커스텀 레벨까지) + const { playingSwitchHandler } = usePlayingSwitch(); const dispatchLevel = useDispatch(); const currentLevel = useSelector((state: RootState) => { return state.levels.value; @@ -17,11 +18,14 @@ const useLevelSwitch = () => { const currentLevelStatus = levelValues.find(({ Y, TITLE }) => TITLE === currentLevel && Y)!; - const levelSwitchHandler = (name: LevelKeyType) => { - if (name === "Custom") { + const levelSwitchHandler = (level: LevelKeyType) => { + if (level === "Custom") { + // 커스텀 훅 정리하기 + // useLevelSwitch 훅으로 정리하기 (커스텀 레벨까지) return; } else { - dispatchLevel(change(name)); + playingSwitchHandler("stale"); + dispatchLevel(change(level)); } }; diff --git a/src/hooks/useTileSwitch.ts b/src/hooks/useTileSwitch.ts index 356d727..acdb589 100644 --- a/src/hooks/useTileSwitch.ts +++ b/src/hooks/useTileSwitch.ts @@ -48,7 +48,7 @@ const useTileSwitch = ({ item, tileMapArr, onSetTileMap, rowIndex, colIndex }: u return; } - detectByBfs(rowIndex, colIndex, tileMapArr); + detectByBfs(rowIndex, colIndex, copy); onSetTileMap(copy); }; diff --git a/src/utils/detectByBfs.ts b/src/utils/detectByBfs.ts index 3575c0f..0ad77b8 100644 --- a/src/utils/detectByBfs.ts +++ b/src/utils/detectByBfs.ts @@ -5,6 +5,7 @@ import { Queue } from "./queue"; const detectByBfs = (Y: number, X: number, tileMapArr: TileType[][]) => { const queue = new Queue(); + tileMapArr[Y][X].isQuestioned = false; queue.enqueue([Y, X]); while (queue.getLength() !== 0) { const cur = queue.dequeue();