Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] RushCard 색상 랜덤 기능 구현 #169

Merged
merged 2 commits into from
Aug 19, 2024
Merged

Conversation

sooyeoniya
Copy link
Member

🖥️ Preview

image image image image

close #167

✏️ 한 일

  • RushCard 색상 랜덤 기능 구현

❗️ 발생한 이슈 (해결 방안)

while (rightColorIdx === leftColorIdx) {
    rightColorIdx = Math.floor(Math.random() * colors.length);
}

두 카드의 색상이 겹치지 않도록 하기 위해서, 만약 동일한 색이 나올 경우 동일한 색이 나오지 않을 때까지 오른쪽 카드를 랜덤으로 계속 돌려주도록 구현했습니다.

❓ 논의가 필요한 사항

@sooyeoniya sooyeoniya added the feat 기능 구현 label Aug 19, 2024
@sooyeoniya sooyeoniya requested a review from jhj2713 August 19, 2024 00:08
@sooyeoniya sooyeoniya self-assigned this Aug 19, 2024
Copy link

빌드를 성공했습니다! 🎉

Copy link
Member

@jhj2713 jhj2713 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생 많으셨어용

@@ -0,0 +1,16 @@
import { CARD_COLOR } from "@/constants/Rush/rushCard.ts";

export function getRandomCardColors() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

랜덤한 index 각각 두 개를 뽑아서 서로 다른 값으로 맞춰주는 것보다는 조합으로 서로 다른 두 개의 index를 한 번에 선택하는 코드를 만들어보는건 어떨까용?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fisher-Yates 알고리즘 써서 배열을 섞어서 임의의 두 개의 인덱스 추출하도록 반영했습니다 :) 좋은 의견 감사합니다!

Copy link

빌드를 성공했습니다! 🎉

@jhj2713 jhj2713 merged commit e840df6 into dev Aug 19, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat 기능 구현
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RushCard 색상 랜덤 기능 구현
2 participants