Skip to content

Commit

Permalink
fix: 세번 더블 시 감옥으로 순간이동 #69
Browse files Browse the repository at this point in the history
  • Loading branch information
yhpark95 committed Nov 2, 2023
1 parent 7514f0b commit f7becd4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import codesquad.gaemimarble.game.dto.request.GameTeleportRequest;
import codesquad.gaemimarble.game.dto.response.GameAccessibleResponse;
import codesquad.gaemimarble.game.dto.response.GameCellResponse;
import codesquad.gaemimarble.game.dto.response.GameDiceResult;
import codesquad.gaemimarble.game.dto.response.GameEventNameResponse;
import codesquad.gaemimarble.game.dto.response.GameRoomCreateResponse;
import codesquad.gaemimarble.game.dto.response.GameTeleportResponse;
Expand Down Expand Up @@ -153,8 +154,14 @@ private void sendFirstPlayer(GameStartRequest gameStartRequest) {
}

private void sendDiceResult(GameRollDiceRequest gameRollDiceRequest) {
GameDiceResult gameDiceResult = gameService.rollDice(gameRollDiceRequest.getGameId(),
gameRollDiceRequest.getPlayerId());
socketDataSender.send(gameRollDiceRequest.getGameId(), new ResponseDTO<>(TypeConstants.DICE,
gameService.rollDice(gameRollDiceRequest.getGameId(), gameRollDiceRequest.getPlayerId())));
gameDiceResult));
if (gameDiceResult.getTripleDouble()) {
socketDataSender.send(gameRollDiceRequest.getGameId(), new ResponseDTO<>(TypeConstants.TELEPORT,
GameTeleportResponse.builder().location(6).build()));
}
sendCellArrival(gameRollDiceRequest.getGameId(), gameRollDiceRequest.getPlayerId());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
@Getter
@NoArgsConstructor
public class GameDiceResult {
private Integer startLocation;
private Boolean tripleDouble;
private Integer dice1;
private Integer dice2;

@Builder
public GameDiceResult(Integer startLocation, Integer dice1, Integer dice2) {
this.startLocation = startLocation;
public GameDiceResult(Boolean tripleDouble, Integer dice1, Integer dice2) {
this.tripleDouble = tripleDouble;
this.dice1 = dice1;
this.dice2 = dice2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ public GameDiceResult rollDice(Long gameId, String playerId) {

if (countDouble == 3) {
player.goToPrison();
return new GameDiceResult(startLocation, dice1, dice2);
return new GameDiceResult(true, dice1, dice2);
}
}
player.move(dice1 + dice2);
return new GameDiceResult(startLocation, dice1, dice2);
return new GameDiceResult(false, dice1, dice2);
}

public GameCellResponse arriveAtCell(Long gameId, String playerId) {
Expand Down

0 comments on commit f7becd4

Please sign in to comment.