Skip to content

Commit

Permalink
Merge pull request #59 from codesquad-members-2023/feat/#58-game-star…
Browse files Browse the repository at this point in the history
…t-user-status-board

[BE] 게임 시작 시 개인 현황판 추가 응답
  • Loading branch information
HyowonSin authored Oct 31, 2023
2 parents d174c6e + 78ac052 commit 66a25d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package codesquad.gaemimarble.game.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;

Expand Down Expand Up @@ -28,6 +29,7 @@
import codesquad.gaemimarble.game.dto.response.GameCellResponse;
import codesquad.gaemimarble.game.dto.response.GameEventNameResponse;
import codesquad.gaemimarble.game.dto.response.GameRoomCreateResponse;
import codesquad.gaemimarble.game.dto.response.userStatusBoard.GameUserBoardResponse;
import codesquad.gaemimarble.game.entity.TypeConstants;
import codesquad.gaemimarble.game.service.GameService;

Expand Down Expand Up @@ -128,6 +130,11 @@ private void sendFirstPlayer(GameStartRequest gameStartRequest) {
Map.of("playerId", playerId)));
socketDataSender.send(gameStartRequest.getGameId(), new ResponseDTO<>(TypeConstants.STATUS_BOARD,
gameService.createGameStatusBoardResponse(gameStartRequest.getGameId())));
List<GameUserBoardResponse> gameUserBoardResponses = gameService.createUserStatusBoardResponse(gameStartRequest.getGameId());
for (GameUserBoardResponse gameUserBoardResponse : gameUserBoardResponses) {
socketDataSender.send(gameStartRequest.getGameId(), new ResponseDTO<>(TypeConstants.USER_STATUS_BOARD,
gameUserBoardResponse));
}
}

private void sendDiceResult(GameRollDiceRequest gameRollDiceRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,12 @@ public GamePrisonDiceResponse prisonDice(GamePrisonDiceRequest gamePrisonDiceReq
.hasEscaped(player.getPrisonCount() == 0)
.build();
}

public List<GameUserBoardResponse> createUserStatusBoardResponse(Long gameId) {
GameStatus gameStatus = gameRepository.getGameStatus(gameId);
return gameStatus.getPlayers()
.stream()
.map(this::createUserBoardResponse)
.toList();
}
}

0 comments on commit 66a25d8

Please sign in to comment.