Skip to content

Commit

Permalink
fix block probability
Browse files Browse the repository at this point in the history
  • Loading branch information
da-in committed Jan 21, 2024
1 parent c6d1a3f commit a3b89ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/pages/play/PlayPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
}
const setNextBlock = () => {
nextBlockRef.value = getBlockIndex(totalBlockCountRef.value)
totalBlockCountRef.value += 1
nextBlockRef.value = getBlockIndex(totalBlockCountRef.value)
}
const dropBlock = () => {
Expand Down
6 changes: 5 additions & 1 deletion src/utils/get-block-index.ts
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit a3b89ab

Please sign in to comment.