From a3b89abeeedbd1987ed9885a1bd7b4f71c54ff0e Mon Sep 17 00:00:00 2001 From: da-in Date: Sun, 21 Jan 2024 12:28:10 +0900 Subject: [PATCH] fix block probability --- src/pages/play/PlayPage.vue | 2 +- src/utils/get-block-index.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/play/PlayPage.vue b/src/pages/play/PlayPage.vue index be1e5c8..abd1888 100644 --- a/src/pages/play/PlayPage.vue +++ b/src/pages/play/PlayPage.vue @@ -143,8 +143,8 @@ } const setNextBlock = () => { - nextBlockRef.value = getBlockIndex(totalBlockCountRef.value) totalBlockCountRef.value += 1 + nextBlockRef.value = getBlockIndex(totalBlockCountRef.value) } const dropBlock = () => { diff --git a/src/utils/get-block-index.ts b/src/utils/get-block-index.ts index 054cc34..f74567c 100644 --- a/src/utils/get-block-index.ts +++ b/src/utils/get-block-index.ts @@ -1,3 +1,7 @@ +/* + * @param count 몇 번째 블럭인지 + */ export const getBlockIndex = (count: number) => { - return Math.floor(Math.random() * count) + 1 // 1 ~ count + const _count = count > 6 ? 6 : count + return Math.floor(Math.random() * (_count - 1)) + 1 // 1 ~ count }