Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…m-2-BE into sandbox
  • Loading branch information
comforest committed Aug 24, 2024
2 parents f03dca4 + dff709e commit 58bfd29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.xorker.draw.mafia.MafiaKeyword
import com.xorker.draw.mafia.MafiaPhase
import com.xorker.draw.mafia.MafiaPhaseMessenger
import com.xorker.draw.mafia.MafiaPlayer
import com.xorker.draw.room.RoomId
import com.xorker.draw.user.UserId
import com.xorker.draw.websocket.SessionMessage
import com.xorker.draw.websocket.broker.WebSocketBroadcaster
Expand Down Expand Up @@ -55,7 +56,7 @@ internal class MafiaPhaseMessengerImpl(
is MafiaPhase.Ready -> MafiaPhaseReadyMessage(
MafiaPhaseReadyBody(
startTime = phase.job.startTime,
mafiaGameInfo = generateMafiaGameInfoMessage(phase.mafiaPlayer, phase.turnList, phase.keyword, gameOption),
mafiaGameInfo = generateMafiaGameInfoMessage(this.room.id, phase.mafiaPlayer, phase.turnList, phase.keyword, gameOption),
),
)

Expand All @@ -66,15 +67,16 @@ internal class MafiaPhaseMessengerImpl(
startTurnTime = phase.job.startTime,
draw = phase.getDraw(),
currentDraw = phase.getCurrentDraw(),
mafiaGameInfo = generateMafiaGameInfoMessage(phase.mafiaPlayer, phase.turnList, phase.keyword, gameOption),
mafiaGameInfo = generateMafiaGameInfoMessage(this.room.id, phase.mafiaPlayer, phase.turnList, phase.keyword, gameOption),
),
)

is MafiaPhase.Vote -> MafiaPhaseVoteMessage(
MafiaPhaseVoteBody(
startTime = phase.job.startTime,
mafiaGameInfo = if (isOrigin.not()) {
generateMafiaGameInfoMessage(phase.mafiaPlayer, phase.turnList, phase.keyword, gameOption)
val room = this.room
generateMafiaGameInfoMessage(room.id, phase.mafiaPlayer, phase.turnList, phase.keyword, gameOption)
} else {
null
},
Expand All @@ -87,7 +89,8 @@ internal class MafiaPhaseMessengerImpl(
MafiaPhaseInferAnswerBody(
startTime = phase.job.startTime,
mafiaGameInfo = if (isOrigin.not()) {
generateMafiaGameInfoMessage(phase.mafiaPlayer, phase.turnList, phase.keyword, gameOption)
val room = this.room
generateMafiaGameInfoMessage(room.id, phase.mafiaPlayer, phase.turnList, phase.keyword, gameOption)
} else {
null
},
Expand All @@ -100,7 +103,8 @@ internal class MafiaPhaseMessengerImpl(
MafiaPhaseEndBody(
startTime = phase.job.startTime,
mafiaGameInfo = if (isOrigin.not()) {
generateMafiaGameInfoMessage(phase.mafiaPlayer, phase.turnList, phase.keyword, gameOption)
val room = this.room
generateMafiaGameInfoMessage(room.id, phase.mafiaPlayer, phase.turnList, phase.keyword, gameOption)
} else {
null
},
Expand All @@ -114,13 +118,15 @@ internal class MafiaPhaseMessengerImpl(
}

private fun generateMafiaGameInfoMessage(
roomId: RoomId,
mafiaPlayer: MafiaPlayer,
turnList: List<MafiaPlayer>,
keyword: MafiaKeyword,
gameOption: MafiaGameOption,
): MafiaGameInfoMessage =
MafiaGameInfoMessage(
MafiaGameInfoBody(
roomId = roomId,
mafiaUserId = mafiaPlayer.userId,
turnList = turnList,
category = keyword.category,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.xorker.draw.websocket.message.response.dto.phase

import com.xorker.draw.mafia.MafiaGameOption
import com.xorker.draw.mafia.MafiaPlayer
import com.xorker.draw.room.RoomId
import com.xorker.draw.user.UserId
import com.xorker.draw.websocket.ResponseAction
import com.xorker.draw.websocket.SessionMessage
Expand All @@ -14,6 +15,7 @@ data class MafiaGameInfoMessage(
}

data class MafiaGameInfoBody(
val roomId: RoomId,
val mafiaUserId: UserId,
val turnList: List<MafiaPlayer>,
val category: String,
Expand Down

0 comments on commit 58bfd29

Please sign in to comment.