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

refactor: 퀴즈게임상태로직개선 #127

Merged
merged 9 commits into from
Dec 4, 2024
6 changes: 3 additions & 3 deletions src/main/kotlin/yjh/cstar/play/domain/QuizGame.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package yjh.cstar.play.domain

import java.time.LocalDateTime
import yjh.cstar.common.BaseException
import yjh.cstar.game.application.GameResultService
import yjh.cstar.game.domain.GameResultCreateCommand
Expand All @@ -19,7 +20,6 @@ import yjh.cstar.util.Logger
import yjh.cstar.util.TimeUtil.Companion.getCurrentLocalDateTime
import yjh.cstar.util.TimeUtil.Companion.getCurrentTime
import yjh.cstar.util.TimeUtil.Companion.getDuration
import java.time.LocalDateTime

class QuizGame(
private val gameInfo: GameInfo,
Expand Down Expand Up @@ -62,8 +62,8 @@ class QuizGame(

try {
runGameWhile({ roomQuizSet.isRunning() }) {
val (quizNo, quiz) = roomQuizSet.getNextQuizInfo()
val quizId: Long = quiz.id
val quizInfo = roomQuizSet.getNextQuizInfo()
val (quizNo, quizId, quiz) = quizInfo

submitQuizToPlayers(quizId, quizNo, quiz)
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/kotlin/yjh/cstar/play/domain/quiz/QuizInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package yjh.cstar.play.domain.quiz

data class QuizInfo(
val quizNo: Int,
val quizId: Long,
val quiz: Quiz,
)
Comment on lines +3 to +7
Copy link
Member

Choose a reason for hiding this comment

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

객체를 생성해야할 때 먼저 data class로 가능한지 생각해봐야겠습니다! 관련해서 리뷰 달려고 했는데 바로 반영해주셨네요! 역시 지훈님!! 입니다.😁😁

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 감사해요 😁

4 changes: 2 additions & 2 deletions src/main/kotlin/yjh/cstar/play/domain/quiz/RoomQuizSet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class RoomQuizSet(
return currQuizNo < quizzes.size
}

fun getNextQuizInfo(): Pair<Int, Quiz> {
fun getNextQuizInfo(): QuizInfo {
validateFinished()

val currQuiz = quizzes[currQuizNo++]
return Pair(currQuizNo, currQuiz)
return QuizInfo(currQuizNo, currQuiz.id, currQuiz)
}

fun getQuizList(): List<Quiz> =
Expand Down
Loading