Skip to content

Commit e54b9a6

Browse files
committed
♻️ refactor : PR 리뷰 반영(stream().allMatch, gameSetting 내부 메서드)
1 parent e63e36c commit e54b9a6

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

backend/src/main/java/io/f1/backend/domain/game/app/GameService.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ private Integer checkGameSetting(Room room, Long quizId) {
5757

5858
GameSetting gameSetting = room.getGameSetting();
5959

60-
Long roomQuizId = gameSetting.getQuizId();
61-
62-
if (!roomQuizId.equals(quizId)) {
60+
if (!gameSetting.checkQuizId(quizId)) {
6361
throw new IllegalArgumentException("E409002 : 게임 설정이 다릅니다. (게임을 시작할 수 없습니다.)");
6462
}
6563

@@ -70,12 +68,8 @@ private boolean validateReadyStatus(Room room) {
7068

7169
Map<String, Player> playerSessionMap = room.getPlayerSessionMap();
7270

73-
for (Player player : playerSessionMap.values()) {
74-
if (!player.isReady()) {
75-
return false;
76-
}
77-
}
78-
return true;
71+
return playerSessionMap.values().stream().allMatch(Player::isReady);
72+
7973
}
8074

8175
private static String getDestination(Long roomId) {

backend/src/main/java/io/f1/backend/domain/game/model/GameSetting.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@ public class GameSetting {
1010
private Long quizId;
1111
private Integer round; // 게임 변경 시 해당 게임의 총 문제 수로 설정
1212
private int timeLimit = 60;
13+
14+
public boolean checkQuizId(Long quizId) {
15+
if(this.quizId != null && this.quizId.equals(quizId)) {
16+
return false;
17+
}
18+
return true;
19+
}
1320
}

backend/src/main/java/io/f1/backend/domain/game/model/Room.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ public void removeUserId(Long id) {
5757
public void removeSessionId(String sessionId) {
5858
this.playerSessionMap.remove(sessionId);
5959
}
60+
6061
}

0 commit comments

Comments
 (0)