-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [또링] 웹 기반 체스 게임 1단계 구현 (#52) * feat : 코드 마이그레이션 * docs : README 작성 * refactor : 테이블 구조 변경 - 단일 게임만 가능하던 구조에서 다중 게임이 가능하도록 수정 * refactor : 예외를 try-catch에서 exception handler로 관리 * refactor : unicode로 변환하는 기능을 service에서 분리 * fix : 적을 잡으면 DB에서 삭제하도록 수정 * refactor : 페이지 렌더링 방식 변경 * refactor : 게임 종료 시 alert를 통해 알림 * fix : í�폰이 대각선으로 움직이는 기능 수정 * refactor : autoBoxing 비용 절감 * refactor : SQLException을 SQLAccessException으로 처리 * refactor : SQLException 발생 시 SQLAccessException에 해당 에러 정보 전달 * refactor : DBConnector에서 에러 발생시 프로그램 종료 * refactor : PieceDao의 save() 반환타입 변경 및 사용하지 않는 메서드 제거 * refactor : 추상적인 메서드 이름을 구체적으로 변경 * docs : 2단계 README 작성 * refactor : Spring Application으로 변경 * refactor : exception handler를 위한 advice 생성 * test : controller 테스트 추가 * test : controller의 save, load 테스트 추가 * [또링] 웹 기반 체스 게임 2단계 구현 (#106) * docs : 2단계 README 작성 * refactor : Spring Application으로 변경 * refactor : exception handler를 위한 advice 생성 * test : controller 테스트 추가 * test : controller의 save, load 테스트 추가 * docs : 3단계 README 작성 * feat : entity 생성 * feat : repository 생성 * feat : 3단계 Spring Data JDBC 적용 * refactor : 서비스 코드 개선 Co-authored-by: 또링 <jnsorn@gmail.com>
- Loading branch information
Showing
32 changed files
with
269 additions
and
543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package wooteco.chess.domain.entity; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.relational.core.mapping.MappedCollection; | ||
import org.springframework.data.relational.core.mapping.Table; | ||
|
||
import wooteco.chess.domain.board.ChessGame; | ||
import wooteco.chess.domain.command.MoveCommand; | ||
import wooteco.chess.domain.piece.Piece; | ||
import wooteco.chess.util.PieceConverter; | ||
|
||
@Table("GAME") | ||
public class Game { | ||
@Id | ||
private Long id; | ||
private String turn; | ||
@MappedCollection(idColumn = "game_id", keyColumn = "id") | ||
private List<GamePiece> gamePieces; | ||
|
||
protected Game() { | ||
} | ||
|
||
public Game(String turn, List<GamePiece> gamePieces) { | ||
this.turn = turn; | ||
this.gamePieces = gamePieces; | ||
} | ||
|
||
public Game(Long id, String turn, List<GamePiece> gamePiece) { | ||
this(turn, gamePiece); | ||
this.id = id; | ||
} | ||
|
||
public Game(ChessGame chessGame) { | ||
this(chessGame.getTurnName(), chessGame.toPieceEntity()); | ||
} | ||
|
||
public void move(MoveCommand moveCommand) { | ||
ChessGame chessGame = getChessGame(); | ||
chessGame.move(moveCommand); | ||
this.turn = chessGame.getTurnName(); | ||
this.gamePieces = chessGame.toPieceEntity(); | ||
} | ||
|
||
private List<Piece> toPieces() { | ||
return this.gamePieces.stream() | ||
.map(piece -> PieceConverter.of(piece.getSymbol(), piece.getPosition())) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public ChessGame getChessGame() { | ||
return new ChessGame(toPieces(), turn); | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public String getTurn() { | ||
return turn; | ||
} | ||
} |
Oops, something went wrong.