Skip to content

[feature/#719] 게임판 랜덤 매칭 API 구현 - #733

Merged
Dimo-2562 merged 14 commits into
developfrom
feature/#719
Aug 24, 2026
Merged

Dimo-2562 merged 14 commits into
developfrom
feature/#719

Conversation

@Dimo-2562

@Dimo-2562 Dimo-2562 commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

❤️ 기능 설명

게임판에서 바로 참여 가능한 선수 4명을 추천하는 랜덤 매칭 API를 구현했습니다.

  • POST /api/game-boards/{gameBoardId}/games/random-match
  • 불참, 대기 중, 경기 시작 후 10분 미만, 급수없음 선수 제외
  • 혼복·남복·여복 중 가능한 타입을 선택하고 경기 수·밸런스·중복 이력을 반영해 추천
  • 추천 결과는 명단 ID 4개만 반환하며 서버에 저장하지 않음
  • 확정 시 기존 CREATE_GAME에서 선수 상태를 다시 검증

연결된 issue

close #719

🩷 Approve 하기 전 확인해주세요!

  • 매치 타입은 응답에 포함하지 않고, 선수 ID는 오름차순으로 반환합니다.
  • 급수없음 제외는 랜덤 매칭 후보에만 적용하며 수동 게임 생성에서는 허용합니다.
  • 기존 CREATE_GAME 대기 생성 경로에 선수 가용 상태 재검증 로직을 추가했습니다.
  • 계산기·정책 등 도메인 서비스는 domain/game/domain/service 아래에 배치했습니다.

✅ 체크리스트

  • PR 제목 규칙 잘 지켰는가?
  • 추가/수정사항을 설명하였는가?
  • 테스트 결과 사진을 넣었는가?
  • 이슈넘버를 적었는가?

테스트

  • 랜덤 매칭 도메인 서비스 및 조회 서비스 단위 테스트 통과
  • API 성공·비저장, GAME415~417, 401·403·404 통합 테스트 통과
  • 전체 테스트는 CI에서 확인합니다.

@Dimo-2562 Dimo-2562 self-assigned this Aug 24, 2026
@Dimo-2562
Dimo-2562 requested a review from kanghana1 August 24, 2026 14:15
@Dimo-2562 Dimo-2562 added the 🛠️ FEAT This issue or pull request already exists label Aug 24, 2026

@kanghana1 kanghana1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

고생하셨습니다! 리뷰 한 번 확인해주세요

throw new GameException(GameErrorCode.INSUFFICIENT_GENDER_COMPOSITION);
}

int selectedIndex = ThreadLocalRandom.current().nextInt(availableTypes.size());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

타입 가능 여부는 전역 후보 성별 수로 판정하지만, 풀 구성은 경기수 격차 창(MAX_GAME_COUNT_GAP=5) 안에서만 성립하고 실패 시 RANDOM_MATCH_NOT_FOUND가 발생할 거 같습니다.

가능한 타입들을 순회하며 풀 구성에 성공하는 타입을 채택하고, 전부 실패할 때만 예외를 던지거나, gap에서 못찾으면 최후의 보루로 격차제한을 풀어서 매칭을 보장하면 안전할 거 같은데, 어떻게 생각하시는지 궁금합니다!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

흠 이 부분은 피그마에 적힌 요구사항대로 구현한 부분인데 PM님과 논의가 필요해보입니다!

ACTIVE_GAME_MEMBER_CANNOT_BE_INACTIVE(HttpStatus.BAD_REQUEST, "GAME413", "진행 또는 대기 중인 게임에 포함된 선수는 참여 해제할 수 없습니다."),
INACTIVE_GAME_PLAYER(HttpStatus.BAD_REQUEST, "GAME414", "불참 상태의 선수는 게임에 추가할 수 없습니다.")
INACTIVE_GAME_PLAYER(HttpStatus.BAD_REQUEST, "GAME414", "불참 상태의 선수는 게임에 추가할 수 없습니다."),
INSUFFICIENT_AVAILABLE_PLAYERS(HttpStatus.BAD_REQUEST, "GAME415", "대기 중인 인원이 부족합니다."),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

요거 "대기중인" 보다는 "매칭가능한"이 조금 더 의미가 통할 거 같은데 어떻게 생각하시나요? 중요한건 아니지만 제안드려봅니다!


GameMatchType matchType = matchTypeSelector.select(candidates);
List<GameBoardMember> candidatePool = candidatePoolSelector.select(candidates, matchType);
List<Game> completedGames = gameRepository.findByGameBoardIdAndStatusInWithPlayers(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

매 호출마다 COMPLETED 게임 전체를 players까지 로드해 페어 이력을 재계산하는 거 같습니다! 완료 게임이 많이 쌓이면 비용이 기하급수적으로 늘 수 있을 거 같습니다. 집계 쿼리로 경량화 가능할 거 같아요!

@Dimo-2562
Dimo-2562 merged commit 7614bcc into develop Aug 24, 2026
1 check passed
@Dimo-2562
Dimo-2562 deleted the feature/#719 branch August 24, 2026 22:17
@kanghana1 kanghana1 mentioned this pull request Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠️ FEAT This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 게임판 랜덤 매칭 API 구현

2 participants