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

[BE] 브랜치 Sync용 #80

Open
wants to merge 45 commits into
base: be
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
ee17944
fix: 게임종료 시 소켓 연결 해제 취소
HyowonSin Nov 8, 2023
23ce893
feat: 소켓 에러 처리 및 세션 클로즈
HyowonSin Nov 8, 2023
f8f30ee
feat: 재접속 기능 구현
HyowonSin Nov 8, 2023
07a9aea
feat: 이벤트 룰렛 -> 발생 자동
HyowonSin Nov 8, 2023
1ecf4bd
feat: 룰렛 상황 때 재접속 처리
HyowonSin Nov 8, 2023
db96575
fix: 게임 입장 세션 누락 처리, 룰렛 시간 조절, 종료 라운드 조절
HyowonSin Nov 8, 2023
a93f414
fix: 이벤트 시간 조절
HyowonSin Nov 8, 2023
9800c15
fix: 타이머 중복 감소 수정
HyowonSin Nov 8, 2023
0c9f6c0
fix: 룰렛 시간 1초 넉넉하게
HyowonSin Nov 8, 2023
e368110
fix: 타이머 시간 1초
HyowonSin Nov 8, 2023
5020ea7
fix: 룰렛 재접속 시간 수정
HyowonSin Nov 8, 2023
7054aca
refactor: 전체현황판 응답시 개인현황판 응답 수정
HyowonSin Nov 10, 2023
571c4dc
refactor: 칸도착, 개인현황판 분리
HyowonSin Nov 10, 2023
7398762
refactor: 황금카드 응답 수정, feat: 황금카드 기부 기능 추가
HyowonSin Nov 10, 2023
f47a2af
feat: 황금카드 검찰조사, 주가조작, 악성루머양산 기능 추가, fix: 순간이동 파라미터, dto noargs 수정
HyowonSin Nov 10, 2023
6c64d39
fix: 배당금 오류 수정
HyowonSin Nov 10, 2023
1e39954
test: 황금카드 주가조작으로 고정
yhpark95 Nov 13, 2023
7d2556e
fix: 주사위 중복 요청 버그 수정, 개인 현황판 타입 및 버그 수정
yhpark95 Nov 13, 2023
a9c4cca
test: 테스트를 위해 주사위 9로 고정
yhpark95 Nov 13, 2023
1bc1cc1
test: 테스트를 위해 주사위 9로 고정 해제
yhpark95 Nov 13, 2023
ac28ab9
fix: refresh Token exposed
yhpark95 Nov 14, 2023
7b21f9a
fix: refresh Token exposed-1
yhpark95 Nov 14, 2023
5ac7da9
fix: refresh Token exposed-2
yhpark95 Nov 14, 2023
dc96b92
fix: refresh Token exposed-3
yhpark95 Nov 14, 2023
709d6e7
test: 황금 카드 검찰 조사로 고정
yhpark95 Nov 14, 2023
9c18dd8
fix: 보석금으로 탈출 시 prisonDice 추가
yhpark95 Nov 14, 2023
9445cc7
fix: 보석금으로 탈출 시 prisonDice 추가
yhpark95 Nov 14, 2023
1507daf
Merge pull request #17 from gaemi-marble/feat/#13-goldcard-refactoring
yhpark95 Nov 15, 2023
dfec3ed
refactor: GameStatus에서 Player 분리 #29
yhpark95 Nov 16, 2023
318775c
refactor: player, currentPlayer, stock 분리 #29
yhpark95 Nov 17, 2023
62ca015
Merge branch 'be' into be
yhpark95 Nov 17, 2023
1490d50
refactor: player, currentPlayer, stock 분리 #29
yhpark95 Nov 17, 2023
c700f05
Merge pull request #34 from gaemi-marble/refactor/#29
yhpark95 Nov 17, 2023
5e9eebf
feat: 감정표현 기능 추가
HyowonSin Nov 17, 2023
5da7e4b
feat: 대기실 조회 기능 추가
HyowonSin Nov 17, 2023
90444c0
fix: emotion -> emoticon
HyowonSin Dec 5, 2023
521daf6
feat: 방 시작 번호, 황금카드 랜덤
HyowonSin Dec 5, 2023
7c6ebd0
fix: 대기실 조회 (세션 확인)
HyowonSin Dec 5, 2023
afcbe0a
feat: 플레이중이 아닌 방이면 삭제한다 #40
yhpark95 Dec 7, 2023
f822b32
Merge pull request #41 from gaemi-marble/feat/#40-대기실-세션상태확인
yhpark95 Dec 7, 2023
116babb
fix: 주식 가치 계산 수정-1 #45
yhpark95 Dec 7, 2023
bf6f61d
fix: 게임 시작 상태 변경, 대기실 순서 정렬
HyowonSin Dec 7, 2023
c379e3d
Merge branch 'fix/#45-calculateStockAsset' of https://github.com/gaem…
HyowonSin Dec 7, 2023
3ec94f1
Merge pull request #46 from gaemi-marble/fix/#45-calculateStockAsset
yhpark95 Dec 8, 2023
d25fb0b
Merge pull request #49 from gaemi-marble/fix/#48-대기실-정렬
yhpark95 Dec 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: 황금카드 검찰조사, 주가조작, 악성루머양산 기능 추가, fix: 순간이동 파라미터, dto noargs 수정
  • Loading branch information
HyowonSin committed Nov 10, 2023
commit f47a2af992736e10c544eac4215583c67eaeb30a
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import codesquad.gaemimarble.game.dto.request.GameEventResultRequest;
import codesquad.gaemimarble.game.dto.request.GamePrisonDiceRequest;
import codesquad.gaemimarble.game.dto.request.GameReadyRequest;
import codesquad.gaemimarble.game.dto.request.GoldCardRequest.GameArrestRequest;
import codesquad.gaemimarble.game.dto.request.GoldCardRequest.GameDonationRequest;
import codesquad.gaemimarble.game.dto.request.GoldCardRequest.GameRobRequest;
import codesquad.gaemimarble.game.dto.request.GameRollDiceRequest;
Expand All @@ -30,6 +31,8 @@
import codesquad.gaemimarble.game.dto.request.GameStatusBoardRequest;
import codesquad.gaemimarble.game.dto.request.GameStockBuyRequest;
import codesquad.gaemimarble.game.dto.request.GameTeleportRequest;
import codesquad.gaemimarble.game.dto.request.GoldCardRequest.GameStockManipulationRequest;
import codesquad.gaemimarble.game.dto.request.GoldCardRequest.GameViciousRumorRequest;
import codesquad.gaemimarble.game.dto.response.GameAccessibleResponse;
import codesquad.gaemimarble.game.dto.response.GameCellResponse;
import codesquad.gaemimarble.game.dto.response.GameDiceResult;
Expand Down Expand Up @@ -69,6 +72,10 @@ public GameController(GameService gameService, SocketDataSender socketDataSender
typeMap.put(TypeConstants.STATUS_BOARD, GameStatusBoardRequest.class);
typeMap.put(TypeConstants.CELL, GameCellArrivalRequest.class);
typeMap.put(TypeConstants.DONATION, GameDonationRequest.class);
typeMap.put(TypeConstants.VICIOUS_RUMOR, GameViciousRumorRequest.class);
typeMap.put(TypeConstants.MANIPULATION, GameStockManipulationRequest.class);
typeMap.put(TypeConstants.ARREST, GameArrestRequest.class);


this.handlers = new HashMap<>();
handlers.put(GameReadyRequest.class, req -> sendReadyStatus((GameReadyRequest)req));
Expand All @@ -86,8 +93,25 @@ public GameController(GameService gameService, SocketDataSender socketDataSender
handlers.put(GameStatusBoardRequest.class, req -> sendStatusBoard((GameStatusBoardRequest)req));
handlers.put(GameCellArrivalRequest.class, req -> sendCellArrival((GameCellArrivalRequest)req));
handlers.put(GameDonationRequest.class, req -> sendDonationResult((GameDonationRequest)req));
handlers.put(GameViciousRumorRequest.class, req -> sendViciousRumorResult((GameViciousRumorRequest)req));
handlers.put(GameStockManipulationRequest.class, req -> sendStockManipulationResult((GameStockManipulationRequest)req));
handlers.put(GameArrestRequest.class, req -> sendArrestResult((GameArrestRequest)req));
}

private void sendArrestResult(GameArrestRequest gameArrestRequest) {
socketDataSender.send(gameArrestRequest.getGameId(), new ResponseDTO<>(TypeConstants.TELEPORT,
gameService.arrest(gameArrestRequest)));
}

private void sendStockManipulationResult(GameStockManipulationRequest gameStockManipulationRequest) {
gameService.increaseStockPrice(gameStockManipulationRequest);
sendStatusBoard(GameStatusBoardRequest.builder().gameId(gameStockManipulationRequest.getGameId()).build());
}

private void sendViciousRumorResult(GameViciousRumorRequest gameViciousRumorRequest) {
gameService.dropStockPrice(gameViciousRumorRequest);
sendStatusBoard(GameStatusBoardRequest.builder().gameId(gameViciousRumorRequest.getGameId()).build());
}

private void sendDonationResult(GameDonationRequest gameDonationRequest) {
List<Player> players = gameService.donate(gameDonationRequest);
Expand Down Expand Up @@ -233,9 +257,8 @@ private void sendCellArrival(GameCellArrivalRequest gameCellArrivalRequest) {
}

private void sendTeleport(GameTeleportRequest gameTeleportRequest) {
gameService.teleport(gameTeleportRequest);
socketDataSender.send(gameTeleportRequest.getGameId(), new ResponseDTO<>(TypeConstants.TELEPORT,
GameTeleportResponse.builder().location(gameTeleportRequest.getLocation()).build()));
gameService.teleport(gameTeleportRequest)));
}

private void sendRandomEvents(GameEventRequest gameEventRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class GameBailRequest {
Long gameId;
String playerId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class GameCellArrivalRequest {
private final Long gameId;
private final String playerId;
private Long gameId;
private String playerId;

@Builder
public GameCellArrivalRequest(Long gameId, String playerId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class GamePrisonDiceRequest {
private Long gameId;
private String playerId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class GameStatusBoardRequest {
private final Long gameId;
private Long gameId;

@Builder
public GameStatusBoardRequest(Long gameId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package codesquad.gaemimarble.game.dto.request.GoldCardRequest;

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class GameArrestRequest {
private Long gameId;
private String targetId;

@Builder
public GameArrestRequest(Long gameId, String targetId) {
this.gameId = gameId;
this.targetId = targetId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class GameDonationRequest {
private Long gameId;
private String playerId;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package codesquad.gaemimarble.game.dto.request.GoldCardRequest;

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class GameStockManipulationRequest {
private Long gameId;
private String stockName;

@Builder
public GameStockManipulationRequest(Long gameId,String stockName) {
this.gameId = gameId;
this.stockName = stockName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package codesquad.gaemimarble.game.dto.request.GoldCardRequest;

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class GameViciousRumorRequest {
private Long gameId;
private String stockName;

@Builder
private GameViciousRumorRequest(Long gameId, String stockName) {
this.gameId = gameId;
this.stockName = stockName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

@Getter
public class GameTeleportResponse {
private final String playerId;
private final Integer location;

@Builder
private GameTeleportResponse(Integer location) {
private GameTeleportResponse(String playerId, Integer location) {
this.playerId = playerId;
this.location = location;
}
}
12 changes: 9 additions & 3 deletions be/src/main/java/codesquad/gaemimarble/game/entity/GoldCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@

@Getter
public enum GoldCard {
ROB("강탈", "선택한 플레이어에게서 1000만원을 강탈한다."),
DONATION("기부", "선택한 플레이어에게 1000만원을 기부한다."),
ROB("rob","강탈", "선택한 플레이어에게서 1000만원을 강탈한다."),
DONATION("donation","기부", "선택한 플레이어에게 1000만원을 기부한다."),
VICIOUS_RUMOR("viciousRumor","악성 루머 양산", "선택한 기업의 주가 -30%"),
MANIPULATION("manipulation","주가 조작", "선택한 기업의 주가 + 30%"),
TELEPORT("teleport","순간이동", "원하는 칸으로 순간이동"),
ARREST("arrest","검찰 조사", "원하는 플레이어를 유치장으로 보낸다.");

private final String cardType;
private final String title;
private final String description;

GoldCard(String title, String description) {
GoldCard(String cardType, String title, String description) {
this.cardType = cardType;
this.title = title;
this.description = description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ public final class TypeConstants {
public static final String CURRENT_PLAYER = "currentPlayer";
public static final String LOCATIONS = "locations";
public static final String DONATION = "donation";
public static final String VICIOUS_RUMOR = "viciousRumor";
public static final String MANIPULATION = "manipulation";
public static final String ARREST = "arrest";
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
import codesquad.gaemimarble.game.dto.request.GameEventResultRequest;
import codesquad.gaemimarble.game.dto.request.GamePrisonDiceRequest;
import codesquad.gaemimarble.game.dto.request.GameReadyRequest;
import codesquad.gaemimarble.game.dto.request.GoldCardRequest.GameArrestRequest;
import codesquad.gaemimarble.game.dto.request.GoldCardRequest.GameDonationRequest;
import codesquad.gaemimarble.game.dto.request.GoldCardRequest.GameRobRequest;
import codesquad.gaemimarble.game.dto.request.GameSellStockRequest;
import codesquad.gaemimarble.game.dto.request.GameStockBuyRequest;
import codesquad.gaemimarble.game.dto.request.GameTeleportRequest;
import codesquad.gaemimarble.game.dto.request.GoldCardRequest.GameStockManipulationRequest;
import codesquad.gaemimarble.game.dto.request.GoldCardRequest.GameViciousRumorRequest;
import codesquad.gaemimarble.game.dto.request.StockNameQuantity;
import codesquad.gaemimarble.game.dto.response.GameAccessibleResponse;
import codesquad.gaemimarble.game.dto.response.GameCellResponse;
Expand All @@ -37,6 +40,7 @@
import codesquad.gaemimarble.game.dto.response.GamePrisonDiceResponse;
import codesquad.gaemimarble.game.dto.response.GameReadyResponse;
import codesquad.gaemimarble.game.dto.response.GameRoomCreateResponse;
import codesquad.gaemimarble.game.dto.response.GameTeleportResponse;
import codesquad.gaemimarble.game.dto.response.PlayerAsset;
import codesquad.gaemimarble.game.dto.response.UserRankingResponse;
import codesquad.gaemimarble.game.dto.response.generalStatusBoard.GameStatusBoardResponse;
Expand Down Expand Up @@ -340,7 +344,17 @@ public GameEndTurnResponse endTurn(GameEndTurnRequest gameEndTurnRequest) {
return GameEndTurnResponse.builder().nextPlayerId(null).build();
}

public void teleport(GameTeleportRequest gameTeleportRequest) {
public GameTeleportResponse arrest(GameArrestRequest gameArrestRequest) {
GameStatus gameStatus = gameRepository.getGameStatus(gameArrestRequest.getGameId());
Player player = gameStatus.getPlayer(gameArrestRequest.getTargetId());
player.goToPrison();
return GameTeleportResponse.builder()
.playerId(player.getPlayerId())
.location(player.getLocation())
.build();
}

public GameTeleportResponse teleport(GameTeleportRequest gameTeleportRequest) {
Player player = gameRepository.getPlayer(gameTeleportRequest.getGameId(), gameTeleportRequest.getPlayerId());
if (gameTeleportRequest.getLocation().equals(player.getLocation()) && player.getLocation() == 18) {
throw new PlayTimeException("순간이동 칸으로 이동 할 수 없습니다", gameTeleportRequest.getPlayerId(),
Expand All @@ -349,6 +363,11 @@ public void teleport(GameTeleportRequest gameTeleportRequest) {
player.setLocation(
gameTeleportRequest.getLocation() > player.getLocation() ? gameTeleportRequest.getLocation() :
gameTeleportRequest.getLocation() + 24);

return GameTeleportResponse.builder()
.playerId(player.getPlayerId())
.location(gameTeleportRequest.getLocation())
.build();
}

public GameStatusBoardResponse increaseCompanyStock(Long gameId, Integer location) {
Expand Down Expand Up @@ -408,23 +427,6 @@ public List<GameUserBoardResponse> createUserStatusBoardResponse(Long gameId) {
.toList();
}

public GameGoldCardResponse selectGoldCard(Long gameId, String playerId) {
GoldCard goldCard = GoldCard.getRandomGoldCard();
return GameGoldCardResponse.builder()
.cardType(goldCard.name().toLowerCase())
.title(goldCard.getTitle())
.description(goldCard.getDescription())
.build();
}

public List<Player> rob(GameRobRequest gameRobRequest) {
Player taker = gameRepository.getPlayer(gameRobRequest.getGameId(), gameRobRequest.getPlayerId());
taker.addCashAsset(10_000_000);
Player target = gameRepository.getPlayer(gameRobRequest.getGameId(), gameRobRequest.getTargetId());
target.addCashAsset(-10_000_000);
return List.of(taker, target);
}

public boolean checkGameOver(Long gameId) {
GameStatus gameStatus = gameRepository.getGameStatus(gameId);
return gameStatus.getRoundCount() > Constants.GAME_OVER_ROUND;
Expand Down Expand Up @@ -488,11 +490,42 @@ public GameEventListResponse selectedEvents(Long gameId) {
return gameEventListResponse;
}

public GameGoldCardResponse selectGoldCard(Long gameId, String playerId) {
GoldCard goldCard = GoldCard.getRandomGoldCard();
return GameGoldCardResponse.builder()
.cardType(goldCard.getCardType())
.title(goldCard.getTitle())
.description(goldCard.getDescription())
.build();
}

public List<Player> rob(GameRobRequest gameRobRequest) {
Player taker = gameRepository.getPlayer(gameRobRequest.getGameId(), gameRobRequest.getPlayerId());
taker.addCashAsset(10_000_000);
Player target = gameRepository.getPlayer(gameRobRequest.getGameId(), gameRobRequest.getTargetId());
target.addCashAsset(-10_000_000);
return List.of(taker, target);
}

public List<Player> donate(GameDonationRequest gameDonationRequest) {
Player giver = gameRepository.getPlayer(gameDonationRequest.getGameId(), gameDonationRequest.getPlayerId());
giver.addCashAsset(-10_000_000);
Player receiver = gameRepository.getPlayer(gameDonationRequest.getGameId(), gameDonationRequest.getReceiverId());
receiver.addCashAsset(10_000_000);
return List.of(giver, receiver);
}

public void dropStockPrice(GameViciousRumorRequest gameViciousRumorRequest) {
Stock stock = gameRepository.getGameStatus(gameViciousRumorRequest.getGameId()).getStocks().
stream().filter(s -> s.getName().equals(gameViciousRumorRequest.getStockName()))
.findFirst().orElseThrow(() -> new PlayTimeException("존재하지 않는 주식입니다", null, gameViciousRumorRequest.getGameId()));
stock.changePrice(Constants.VICIOUS_RUMOR_STOCK_DROP);
}

public void increaseStockPrice(GameStockManipulationRequest gameStockManipulationRequest) {
Stock stock = gameRepository.getGameStatus(gameStockManipulationRequest.getGameId()).getStocks().
stream().filter(s -> s.getName().equals(gameStockManipulationRequest.getStockName()))
.findFirst().orElseThrow(() -> new PlayTimeException("존재하지 않는 주식입니다", null, gameStockManipulationRequest.getGameId()));
stock.changePrice(Constants.STOCK_MANIPULATION_INCREASE);
}
}
2 changes: 2 additions & 0 deletions be/src/main/java/codesquad/gaemimarble/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ public class Constants {
public static final String REFRESH_TOKEN = "Refresh-Token";
public static final int SELLING_TIME = 10;
public static final int GAME_OVER_ROUND = 5;
public static final int VICIOUS_RUMOR_STOCK_DROP = -30;
public static final int STOCK_MANIPULATION_INCREASE = 30;
}