Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3a12a76
feat: 피스 생성 테스트 및 구현
seongbeenkim Aug 16, 2021
667d30a
feat: 피스 위치 캐싱 테스트 및 구현
seongbeenkim Aug 16, 2021
05e7c1d
feat: 체스판 32개의 피스 초기화, 생성 테스트 및 구현
seongbeenkim Aug 16, 2021
2d33803
feat: 기물 종류에 따라 이름을 매핑하는 기물 이름 매퍼 테스트 및 구현
seongbeenkim Aug 17, 2021
cc54492
feat: 체스판 전체 출력하는 기능 구현
seongbeenkim Aug 17, 2021
8bc0bd5
feat: 체스 게임 시작&종료 명령어 입력 테스트 및 구현
seongbeenkim Aug 17, 2021
f6c2eb4
feat: 기물 이동 시 공통 예외 케이스 테스트 및 구현
seongbeenkim Aug 17, 2021
22d29d1
feat: 비숍 이동 규칙 테스트 및 구현
seongbeenkim Aug 17, 2021
c877ccd
feat: 룩 이동 규칙 테스트 및 구현
seongbeenkim Aug 17, 2021
adc18b6
feat: 퀸 이동 규칙 테스트 및 구현
seongbeenkim Aug 17, 2021
f3c877a
feat: 킹 이동 규칙 테스트 및 구현
seongbeenkim Aug 17, 2021
12da4ca
feat: 나이트 이동 규칙 테스트 및 구현
seongbeenkim Aug 17, 2021
44ecf39
feat: 폰 이동 규칙 테스트 및 구현
seongbeenkim Aug 19, 2021
4498862
feat: 체스판에서 피스 이동 테스트 및 구현
seongbeenkim Aug 19, 2021
a40508d
refactor: 피스 색상별 체스판 분리
seongbeenkim Aug 19, 2021
c30f242
feat: 비숍, 룩 공격 가능한 경로 반환하는 테스트 및 기능 구현
seongbeenkim Aug 19, 2021
483c149
feat: 폰 제외한 기물 패턴 테스트 및 기능 구현
seongbeenkim Aug 20, 2021
c2f0dea
feat: 기물 이동 시 공격 가능 위치를 갱신하는 테스트 및 기능 구현
seongbeenkim Aug 20, 2021
c17c852
feat: 킹 이동제한조건 테스트 및 기능 구현, 예외 처리 및 게임 흐름 제어
jiwoo-kimm Aug 20, 2021
5d69a67
feat: 점수 계산 기능 테스트 및 구현
seongbeenkim Aug 20, 2021
be1d67e
feat: 점수 및 게임 결과 출력 기능 구현
jiwoo-kimm Aug 20, 2021
aba4a3a
refactor: 패키지 구조 및 테스트 케이스 정리
jiwoo-kimm Aug 20, 2021
0401fb6
feat: 웹 체스 MVC 구조 및 초기화면 세팅
jiwoo-kimm Aug 29, 2021
bdb9729
feat: 기물 이동, 현재 점수, 안내 메시지 출력 구현
jiwoo-kimm Aug 30, 2021
ffec341
feat: 게임 종료, 결과 출력 기능 구현
jiwoo-kimm Aug 31, 2021
8e2830b
refactor: ChessGame 도메인 삭제, ChessService로 통합
jiwoo-kimm Aug 31, 2021
778b8d6
refactor: ChessService의 isGameFinished flag 제거, Status의 isKingDead fl…
jiwoo-kimm Aug 31, 2021
cdc9cda
fix: 퀸 이동 패턴 수정
jiwoo-kimm Sep 3, 2021
a0a341c
refactor: ChessGame 도메인 삭제, ChessService로 통합, 게임종료플래그
jiwoo-kimm Sep 3, 2021
b3770b2
refactor: Controller 역할을 Service, Command, Operation으로 분리
jiwoo-kimm Sep 3, 2021
d97f271
refactor: Board 가독성 개선, 메서드 길이 제한 확인
jiwoo-kimm Sep 3, 2021
cd61bd7
refactor: 기물 이동 리팩토링
jiwoo-kimm Sep 5, 2021
9931625
test: 공격 경로 탐색 테스트 수정
jiwoo-kimm Sep 5, 2021
2026dac
refactor: Player -> Team 으로 명칭 변경
jiwoo-kimm Sep 15, 2021
8a8ccbb
refactor: Team 정적 팩토리 생성자 도입
jiwoo-kimm Sep 15, 2021
ea4b38f
refactor: Board → ChessGame 으로 명칭 변경
jiwoo-kimm Sep 15, 2021
46a6daa
refactor: 기물 이동 메서드 이름 수정
jiwoo-kimm Sep 15, 2021
b574593
refactor: 플레이어의 플레이 순서 관리 추가
jiwoo-kimm Sep 29, 2021
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: 체스 게임 시작&종료 명령어 입력 테스트 및 구현
  • Loading branch information
seongbeenkim committed Aug 17, 2021
commit 8bc0bd5b409f56e0c9347efa37fdcf2c67bc98bf
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,38 @@
## 구현해야할 목록

- [] 입력
- [x] 시작 여부 입력
- [] 출력
- [x] 체스판 전체 출력

- [x] 기물(Piece)
- [x] 색상
- [ ] 체스게임(ChessGame)
- [x] 체스판
- [x] 게임 시작&종료 상태 제어
- [x] 명령어 검증 및 처리

- [x] 기물 위치(Position)
- [x] 파일
- [x] 랭크
- [x] 64개의 캐싱된 위치
- [x] 체스판(Board)
- [x] 체스판
- [x] 생성 시 32개의 기물 초기화
- [x] 인자로 전달받은 위치에 기물이 있는지 확인

- 기능
- [x] 전달받은 인자에 해당하는 위치 객체 반환

- [x] 기물 색상(Color)
- [x] 기물(Piece)
- [x] 색상

- [x] 기물 이름 매퍼
- [x] 기물 종류에 따라 이름을 매핑
- [x] 기물 위치(Position)
- [x] 파일
- [x] 랭크
- [x] 64개의 캐싱된 위치

- 기능
- [x] 전달받은 인자에 해당하는 위치 객체 반환

- [x] 기물 색상(Color)
- [x] 색상

- [x] 기물 이름 매퍼
- [x] 기물 종류에 따라 이름을 매핑

- [x] 체스판(Board)
- [x] 체스판
- [x] 생성 시 32개의 기물 초기화
- [x] 인자로 전달받은 위치에 기물이 있는지 확인

## 이동 규칙

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

각 기물 뒤에 나온 숫자가 점수인 것으로 보이는데,
점수 계산에 대한 것도 기능 목록으로 빼면 어떨까요?
해당 코드만 보고 이해하는 사람에게는 어떤 숫자를 의미하는지 알기가 어려울 것 같아요.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵! Player 기능목록에 점수 계산도 추가했습니다


Expand Down
5 changes: 4 additions & 1 deletion src/main/java/chess/ConsoleApplication.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package chess;

import chess.controller.ChessController;
import chess.view.ConsoleInputView;
import chess.view.ConsoleOutputView;
import chess.view.InputView;
import chess.view.OutputView;

public class ConsoleApplication {

public static void main(String[] args) {
OutputView outputView = new ConsoleOutputView();
ChessController chessController = new ChessController(outputView);
InputView inputView = new ConsoleInputView();
ChessController chessController = new ChessController(inputView, outputView);
chessController.run();
}
}
17 changes: 12 additions & 5 deletions src/main/java/chess/controller/ChessController.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
package chess.controller;

import chess.controller.dto.BoardDto;
import chess.domain.board.Board;
import chess.domain.ChessGame;
import chess.view.InputView;
import chess.view.OutputView;

public class ChessController {

private final InputView inputView;
private final OutputView outputView;

public ChessController(final OutputView outputView) {
public ChessController(final InputView inputView, final OutputView outputView) {
this.inputView = inputView;
this.outputView = outputView;
}

public void run() {
Board board = new Board();
BoardDto boardDto = new BoardDto(board);
outputView.printBoard(boardDto);
String initialCommand = inputView.getInitialCommand();
ChessGame chessGame = new ChessGame(initialCommand);

while (chessGame.isRunning()) {
BoardDto boardDto = new BoardDto(chessGame.getBoard());
outputView.printBoard(boardDto);
}
}
}
34 changes: 34 additions & 0 deletions src/main/java/chess/domain/ChessGame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package chess.domain;

import chess.domain.board.Board;

public class ChessGame {

private static final String START = "start";
private static final String END = "end";

private final Board board = new Board();
private boolean isRunning = false;

public ChessGame(final String initialCommand) {
if (initialCommand.equals(START)) {
isRunning = true;
return;
}

if (initialCommand.equals(END)) {
return;
}

throw new UnsupportedOperationException("유효하지 않은 명령어입니다.");
}


public boolean isRunning() {
return isRunning;
}

public Board getBoard() {
return board;
}
}
23 changes: 23 additions & 0 deletions src/main/java/chess/view/ConsoleInputView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package chess.view;

import java.util.Scanner;

public class ConsoleInputView implements InputView {
private static final Scanner scanner = new Scanner(System.in);
private static final String HEADER = "> ";

@Override
public String getInitialCommand() {
System.out.println(HEADER + "체스 게임을 시작합니다.");
System.out.println(HEADER + "게임 시작은 start, 종료는 end 명령을 입력하세요.");
String input = scanner.nextLine();
validateNull(input);
return input.trim();
}

private void validateNull(final String input) {
if (input == null) {
throw new IllegalArgumentException("잘못된 입력입니다.");
}
}
}
5 changes: 5 additions & 0 deletions src/main/java/chess/view/InputView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package chess.view;

public interface InputView {
String getInitialCommand();
}
46 changes: 46 additions & 0 deletions src/test/java/chess/domain/ChessGameTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package chess.domain;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class ChessGameTest {

@Test
@DisplayName("게임 시작 명령어를 입력받을 경우 게임을 시작한다.")
void create_start_command() {
//given
String command = "start";

//when
ChessGame chessGame = new ChessGame(command);

//then
assertThat(chessGame.isRunning()).isTrue();
}

@Test
@DisplayName("게임 종료 명령어를 입력받을 경우 게임을 종료한다.")
void create_end_command() {
//given
String command = "end";

//when
ChessGame chessGame = new ChessGame(command);

//then
assertThat(chessGame.isRunning()).isFalse();
}

@Test
@DisplayName("유효하지 않은 명령어를 입력받을 경우 예외를 던진다.")
void create_invalid_command() {
//given
String command = "invalid_command";

//when, then
assertThrows(UnsupportedOperationException.class, () -> new ChessGame(command));
}
}