Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
dbc4008
docs: README에 게임 규칙 및 입력/출력 설명 추가
smiinii Mar 25, 2026
5a2c009
feat: Position 클래스 구현 및 캐싱 로직 추가
smiinii Mar 25, 2026
9d73439
test: Position 클래스 테스트 코드 추가
smiinii Mar 25, 2026
426ad7f
feat: 커스텀 예외 클래스 추가
smiinii Mar 25, 2026
0932e8f
docs(README): 리드미 수정
koomingu Mar 25, 2026
95e0e56
style: README 파일의 마지막 줄 개행 추가
smiinii Mar 25, 2026
8601545
test: row, col 테스트 코드 작성
koomingu Mar 26, 2026
a135b2c
feat: Row, Column 값 객체 구현
koomingu Mar 26, 2026
5fcf6be
feat: Row, Column 범위 예외 구현
koomingu Mar 26, 2026
de86e24
test: Position 테스트 구현
koomingu Mar 26, 2026
8112d42
refactor: Row, Column 값객체 변경으로 인한 Position 수정
koomingu Mar 26, 2026
228870e
refactor: Row 및 Column 범위 상수 수정
smiinii Mar 26, 2026
ddde159
test: Row 및 Column 클래스 테스트 케이스 수정
smiinii Mar 26, 2026
ddb05a6
style: Position 클래스 내부 불필요한 공백 제거
smiinii Mar 26, 2026
cc341de
feat: Position 클래스에 좌표 반환 메서드 추가
smiinii Mar 26, 2026
5522e54
feat: Board 및 기물 초기화 로직 추가
smiinii Mar 26, 2026
d889e9c
feat: Piece 클래스 추가
smiinii Mar 26, 2026
00ddedd
feat: MoveStorage 인터페이스 추가
smiinii Mar 26, 2026
02914c1
feat: 각 기물의 MoveStorage 클래스 추가
smiinii Mar 26, 2026
55557b7
feat: 팀 구분을 위한 Team enum 클래스 추가
smiinii Mar 26, 2026
9979b4b
feat: 체스판 상태 확인을 위한 BoardState 인터페이스 추가
smiinii Mar 26, 2026
dfa00b1
feat: 기물 이동 및 체스판 상태 관리 기능 추가
smiinii Mar 26, 2026
d32648d
feat: Board 객체 변환을 위한 BoardDto 클래스 추가
smiinii Mar 26, 2026
76b68ab
feat: Controller 클래스 및 기본 운영 로직 추가
smiinii Mar 26, 2026
6489109
feat: 사용자 입력 처리를 위한 InputView 클래스 추가
smiinii Mar 26, 2026
70b6da2
feat: 체스판 출력을 위한 OutputView 클래스 추가
smiinii Mar 26, 2026
a64c952
feat: Application 클래스 추가
smiinii Mar 26, 2026
201fc2e
docs: README 체크리스트 상태 업데이트
smiinii Mar 27, 2026
83fe29b
feat: 차(Cha) 기물의 이동 가능 여부 판단 로직 추가
smiinii Mar 27, 2026
fb2f492
test: 차(Cha) 이동 로직 단위 테스트 추가
smiinii Mar 27, 2026
de02ec9
refactor: 차(Cha) 이동 가능 여부 로직 리팩토링
smiinii Mar 28, 2026
ec53683
test: ChaMoveStorage 테스트 케이스 메서드명 수정 및 가독성 개선
smiinii Mar 28, 2026
0e1ec00
test: 차(Cha) 이동 불가능 경로 예외 테스트 추가
smiinii Mar 28, 2026
58baa25
feat: 포(Po) 이동 가능 여부 판단 로직 추가
smiinii Mar 28, 2026
c67f4f3
test: 포(Po) 이동 로직 단위 테스트 추가
smiinii Mar 28, 2026
004fcf5
feat: Position 클래스 equals와 hashCode 메서드 추가
smiinii Mar 28, 2026
562a9ce
feat: 상(Sang) 이동 가능 여부 판단 로직 추가
smiinii Mar 28, 2026
3952208
test: 상(Sang) 이동 로직 단위 테스트 추가
smiinii Mar 28, 2026
71ec004
feat: 마(Ma) 이동 가능 여부 판단 로직 추가
smiinii Mar 28, 2026
7675b63
test: 마(Ma) 이동 로직 단위 테스트 추가
smiinii Mar 28, 2026
b15a267
feat: 졸(Jol) 이동 저장소 클래스 기본 구조 추가
smiinii Mar 28, 2026
d08cb7f
test: 졸(Jol) 이동 로직 단위 테스트 추가
smiinii Mar 28, 2026
13ed308
refactor: 궁(Gung)과 사(Sa) 이동 저장소 통합
smiinii Mar 28, 2026
6f30824
refactor: 궁(Gung)과 사(Sa) 이동 로직 저장소 통합 적용
smiinii Mar 28, 2026
ac7c8b4
test: Position 좌표 생성 로직에 대한 테스트 수정
smiinii Mar 28, 2026
aca2d42
feat: 졸(Jol) 이동 가능 여부 판단 로직 추가
smiinii Mar 28, 2026
633b898
feat: 궁(Gung)과 사(Sa) 이동 가능 여부 판단 로직 추가
smiinii Mar 28, 2026
f3cca02
test: 궁(Gung)과 사(Sa) 이동 로직 단위 테스트 추가
smiinii Mar 28, 2026
e910f04
test: 이동 로직 테스트 메서드명 수정
smiinii Mar 28, 2026
782a1da
feat: 이동 검증 로직에 예외 처리 추가
smiinii Mar 28, 2026
173a6ea
test: Piece 클래스 이동 검증 로직 단위 테스트 추가
smiinii Mar 28, 2026
0d01534
feat: InvalidMoveException 클래스 추가
smiinii Mar 28, 2026
9778e6e
docs: README 체크리스트 상태 업데이트
smiinii Mar 28, 2026
dd5d85c
feat: Piece 클래스 equals 및 hashCode 구현 추가
smiinii Mar 28, 2026
8ce5db4
feat: 빈 위치 이동 시 예외 처리 추가
smiinii Mar 28, 2026
33c47f1
test: Board 클래스 단위 테스트 추가
smiinii Mar 28, 2026
9f54724
feat: EmptyPositionException 클래스 추가
smiinii Mar 28, 2026
0b1fc34
docs: README 체크리스트 항목 추가 및 오류 메시지 설명 업데이트
smiinii Mar 28, 2026
64ecbd9
fix: 초 기물 배치 오류 수정
smiinii Mar 28, 2026
5574554
feat: Team 열거형에 팀 전환 및 이름 조회 기능 추가
smiinii Mar 28, 2026
bec8227
refactor: 이동 가능성 검증 로직 중복 제거 및 변수 추출
smiinii Mar 28, 2026
c03350e
refactor: 팀 조회 로직 변수 추출로 중복 제거
smiinii Mar 28, 2026
1e86296
feat: 플레이 턴 입력 로직 및 좌표 파싱 기능 추가
smiinii Mar 28, 2026
ed1ebfd
feat: 에러 메시지 출력 기능 추가
smiinii Mar 28, 2026
6511015
feat: 사용자 턴 진행 및 이동 처리 로직 추가
smiinii Mar 28, 2026
9299635
docs: README 체크리스트 진행 상황 업데이트
smiinii Mar 28, 2026
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
156 changes: 155 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,157 @@
# java-janggi

장기 미션 저장소
# 기능 명세서

---

## 기능

### 게임 초기화

- [x] 한나라가 위, 초나라를 아래로 위치시켜 보드를 초기화한다.

### 게임 진행

- [x] 초나라 선, 한나라 후로 게임이 반복적으로 진행된다.
- [x] 입력을 받은 좌표와 기물 규칙에 따라 기물을 이동시킨다.
- [ ] 궁을 잡는 수를 두면 장군이다.
- [ ] 장군을 피하는 수를 두면 멍군이다.
- [ ] 빅장일 때 게임을 종료하기 싫으면 빅장을 깨뜨리는 수를 둘 수 있다.

### 기물 이동 규칙

| **기물** | **기본 이동 방식** | **궁성(3x3) 내 특수 규칙** | **특징 (구현 시 고려사항)** |
| --- |----------------------------------| --- |----------------------------------------------------------|
| **궁(將/楚)** | 상하좌우 1칸 | 대각선 선을 따라 1칸 이동 가능 | 궁성 밖으로 절대 나갈 수 없음 |
| **사(士)** | 상하좌우 1칸 | 대각선 선을 따라 1칸 이동 가능 | 궁성 밖으로 절대 나갈 수 없음 |
| **차(車)** | 상하좌우 직선으로 거리 제한 없이 이동 | 대각선 선을 따라 이동 가능 | 경로에 다른 기물이 있으면 못 지나감 |
| **포(包)** | 상하좌우로 다른 기물 하나를 뛰어넘어 거리 제한 없이 이동 | 대각선 선을 따라 기물 하나를 넘어서 이동 | 포끼리는 서로 넘을 수 없음<br>포끼리는 잡을 수 없음<br>넘을 기물이 반드시 1개 있어야 함 |
| **마(馬)** | 상하좌우 직선 1칸 + 이동한 방향으로 대각선 1칸 | 해당 없음 | 멱(길목)이 막혀 있으면 못 감 |
| **상(象)** | 상하좌우 직선 1칸 + 이동한 방향으로 대각선 2칸 | 해당 없음 | 멱(길목)이 막혀 있으면 못 감 |
| **졸/병(卒/兵)** | 앞 또는 옆으로 1칸 | 적군 궁성 내에서 대각선 앞으로 1칸 이동 가능 | 진영에 따라 '앞'의 방향이 다름<br>뒤로는 못감 |

### 게임 종료

- [ ] 외통수이면 승리한다.
- [ ] 빅장이면 점수를 계산해 승패를 결정한다.
- [ ] 한나라에 1.5점을 더해서 점수를 계산한다.

## 입력

- [x] 초나라가 기물을 선택하고 행마를 입력한다.

```java
초나라 턴입니다. 이동할 기물의 좌표와 도착할 좌표를 입력하세요. (예 : (1, 2), (3, 3))
```

- [x] 한나라가 기물을 선택하고 행마를 입력한다.

```java
한나라 턴입니다. 이동할 기물의 좌표와 도착할 좌표를 입력하세요. (예 : (1, 2), (3, 3))
```


## 출력

- [x] 게임 시작 멘트를 출력한다.

```java
게임을 시작하겠습니다.
```

- [x] 보드판을 출력한다.

```java
0 1 2 3 4 5 6 7 8

0 [車]-------[馬]-------[象]-------[士]-------[ ]-------[士]-------[象]-------[馬]-------[車]
ㅣ ㅣ ㅣ ㅣ \ ㅣ / ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ \ ㅣ / ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ \ ㅣ / ㅣ ㅣ ㅣ ㅣ
1 [ ]-------[ ]-------[ ]-------[ ]-------[漢]-------[ ]-------[ ]-------[ ]-------[ ]
ㅣ ㅣ ㅣ ㅣ / ㅣ \ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ / ㅣ \ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ / ㅣ \ ㅣ ㅣ ㅣ ㅣ
2 [ ]-------[包]-------[ ]-------[ ]-------[ ]-------[ ]-------[ ]-------[包]-------[ ]
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
3 [兵]-------[ ]-------[兵]-------[ ]-------[兵]-------[ ]-------[兵]-------[ ]-------[兵]
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
4 [ ]-------[ ]-------[ ]-------[ ]-------[ ]-------[ ]-------[ ]-------[ ]-------[ ]
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
5 [ ]-------[ ]-------[ ]-------[ ]-------[ ]-------[ ]-------[ ]-------[ ]-------[ ]
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
6 [卒]-------[ ]-------[卒]-------[ ]-------[卒]-------[ ]-------[卒]-------[ ]-------[卒]
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ ㅣ
7 [ ]-------[包]-------[ ]-------[ ]-------[ ]-------[ ]-------[ ]-------[包]-------[ ]
ㅣ ㅣ ㅣ ㅣ \ ㅣ / ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ \ ㅣ / ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ \ ㅣ / ㅣ ㅣ ㅣ ㅣ
8 [ ]-------[ ]-------[ ]-------[ ]-------[楚]-------[ ]-------[ ]-------[ ]-------[ ]
ㅣ ㅣ ㅣ ㅣ / ㅣ \ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ / ㅣ \ ㅣ ㅣ ㅣ ㅣ
ㅣ ㅣ ㅣ ㅣ / ㅣ \ ㅣ ㅣ ㅣ ㅣ
9 [車]-------[馬]-------[象]-------[士]-------[ ]-------[士]-------[象]-------[馬]-------[車]
```

- [ ] 장군이면 장군을 출력한다.

```java
장군입니다! 기물을 움직여 궁을 살리세요.
```

- [ ] 외통이면 게임 종료를 출력한다.

```java
외통입니다. 초나라/한나라의 승리입니다.
```

- [ ] 빅장이면 상대방이 선택할 수 있게 조건을 출력한다.

```java
빅장입니다. 게임을 종료하기 싫으면 왕 앞에 기물을 놔두세요!
```

- [ ] 빅장으로 게임이 종료되면 점수를 출력한다.

```java
빅장입니다.

초나라 점수 :
한나라 점수 :

결과 : 초나라/한나라의 승리입니다.
```


## 유효성

### Position

- [x] 장기판 범위를 벗어난 경우
```java
[ERROR] 장기판 범위를 벗어난 좌표입니다.
```

### Piece

- [x] 기물이 이동할 수 없을 경우
```
[ERROR] 유효하지 않는 행마입니다.
```

### Board

- [x] 출발지에 이동할 기물이 없는 경우
```
[ERROR] 출발지에 이동할 기물이 없습니다.
```
Empty file removed src/main/java/.gitkeep
Empty file.
16 changes: 16 additions & 0 deletions src/main/java/janggi/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package janggi;

import janggi.controller.Controller;
import janggi.view.InputView;
import janggi.view.OutputView;

public class Application {
public static void main(String[] args) {

InputView inputView = new InputView();
OutputView outputView = new OutputView();
Controller controller = new Controller(inputView, outputView);

controller.run();
}
}
53 changes: 53 additions & 0 deletions src/main/java/janggi/controller/Controller.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package janggi.controller;

import janggi.domain.Board;
import janggi.domain.BoardFactory;
import janggi.domain.Column;
import janggi.domain.Position;
import janggi.domain.Row;
import janggi.domain.Team;
import janggi.dto.BoardDto;
import janggi.exception.BusinessException;
import janggi.view.InputView;
import janggi.view.OutputView;

import java.util.List;

public class Controller {
private final InputView inputView;
private final OutputView outputView;

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

public void run() {
outputView.printStartMessage();
Board board = new Board(BoardFactory.generate());
outputView.printBoard(BoardDto.from(board));

outputView.printStartMessage();

Team currentTeam = Team.CHO;

for (int i = 0; i < 10; i++) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

턴이 10번 지나가면 반드시 끝나네요. phase1이라도 어플리케이션은 지속적으로 동작해야합니다.

while (true) {
try {
List<Integer> positions = inputView.playTurn(currentTeam.getTeam());
Position from = Position.of(Row.of(positions.get(0)), Column.of(positions.get(1)));
Position to = Position.of(Row.of(positions.get(2)), Column.of(positions.get(3)));
Comment on lines +38 to +39
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

controller에서 input의 형식을 알고있습니다. input에서 몇번째가 누구의 입력인지를 파악해서 추출하는게 controller의 책임일까요?


board.move(from, to);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

팀에 대한 정보는 보드를 옮길때 넘겨주지 않습니다. 선택한 기물이 어떤 팀인지에 판단은 어떤 객체에서 하고있나요?

outputView.printBoard(BoardDto.from(board));

currentTeam = currentTeam.switchTeam();
Comment on lines +37 to +44
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

상대팀 기물을 옮겨도 따로 검사를 하지 않는거 같네요.

break;

} catch (BusinessException e) {
outputView.printErrorMessage(e.getMessage());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

사용자가 실수로 잘못된 입력을 한 경우 어플리케이션이 그냥 끝나겠군요. 사용자 입장에서 한참 게임하고있는데 게임이 끝나버리는 경우가 생길거 같습니다.

}
}
Comment on lines +34 to +50
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

3 depth네요. 1depth를 유지하도록 수정해보시죠!

}
}
}
40 changes: 40 additions & 0 deletions src/main/java/janggi/domain/Board.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package janggi.domain;

import janggi.exception.EmptyPositionException;

import java.util.HashMap;
import java.util.Map;

public class Board implements BoardState{
private final Map<Position, Piece> board;

public Board(Map<Position, Piece> initialPieces) {
this.board = new HashMap<>(initialPieces);
}

@Override
public boolean hasPieceAt(Position position) {
return board.containsKey(position);
}

@Override
public Piece getPieceAt(Position position) {
return board.get(position);
}

public void move(Position from, Position to) {
Piece movingPiece = board.get(from);

if (movingPiece == null) {
throw new EmptyPositionException();
}

movingPiece.verifyMove(from, to, this);
board.remove(from);
board.put(to, movingPiece);
}

public Map<Position, Piece> getBoard() {
return board;
}
}
105 changes: 105 additions & 0 deletions src/main/java/janggi/domain/BoardFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package janggi.domain;

import janggi.domain.movestorage.ChaMoveStorage;
import janggi.domain.movestorage.GungAndSaMoveStorage;
import janggi.domain.movestorage.JolMoveStorage;
import janggi.domain.movestorage.MaMoveStorage;
import janggi.domain.movestorage.SangMoveStorage;

import java.util.HashMap;
import java.util.Map;

public class BoardFactory {
public static Map<Position, Piece> generate() {
Map<Position, Piece> board = new HashMap<>();

SetHanPieces(board);
SetChoPieces(board);

return board;
}

private static void SetHanPieces(Map<Position, Piece> board) {
// 차
board.put(Position.of(Row.of(0), Column.of(0)),
new Piece(new ChaMoveStorage(), Team.HAN, 13, "車"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

위치, 점수, 이름 데이터가 factory에서 관리되고있으니 헷갈릴만한 여지가 많은거 같습니다. 어떻게 하면 성격이 같은 데이터끼리 모아서 관리할 수 있을지 고민해보세요!

board.put(Position.of(Row.of(8), Column.of(0)),
new Piece(new ChaMoveStorage(), Team.HAN, 13, "車"));
// 상
board.put(Position.of(Row.of(1), Column.of(0)),
new Piece(new SangMoveStorage(), Team.HAN, 3, "象"));
board.put(Position.of(Row.of(6), Column.of(0)),
new Piece(new SangMoveStorage(), Team.HAN, 3, "象"));
// 마
board.put(Position.of(Row.of(2), Column.of(0)),
new Piece(new MaMoveStorage(), Team.HAN, 5, "馬"));
board.put(Position.of(Row.of(7), Column.of(0)),
new Piece(new MaMoveStorage(), Team.HAN, 5, "馬"));
// 사
board.put(Position.of(Row.of(3), Column.of(0)),
new Piece(new GungAndSaMoveStorage(), Team.HAN, 3, "士"));
board.put(Position.of(Row.of(5), Column.of(0)),
new Piece(new GungAndSaMoveStorage(), Team.HAN, 3, "士"));
// 궁
board.put(Position.of(Row.of(4), Column.of(1)),
new Piece(new GungAndSaMoveStorage(), Team.HAN, 0, "漢"));
// 포
board.put(Position.of(Row.of(1), Column.of(2)),
new Piece(new SangMoveStorage(), Team.HAN, 7, "包"));
board.put(Position.of(Row.of(7), Column.of(2)),
new Piece(new SangMoveStorage(), Team.HAN, 7, "包"));
Comment on lines +47 to +50
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.

포의 움직임으로 초기화되도록 수정하였습니다.

// 졸
board.put(Position.of(Row.of(0), Column.of(3)),
new Piece(new JolMoveStorage(), Team.HAN, 2, "兵"));
board.put(Position.of(Row.of(2), Column.of(3)),
new Piece(new JolMoveStorage(), Team.HAN, 2, "兵"));
board.put(Position.of(Row.of(4), Column.of(3)),
new Piece(new JolMoveStorage(), Team.HAN, 2, "兵"));
board.put(Position.of(Row.of(6), Column.of(3)),
new Piece(new JolMoveStorage(), Team.HAN, 2, "兵"));
board.put(Position.of(Row.of(8), Column.of(3)),
new Piece(new JolMoveStorage(), Team.HAN, 2, "兵"));
}

private static void SetChoPieces(Map<Position, Piece> board) {
// 차
board.put(Position.of(Row.of(0), Column.of(9)),
new Piece(new ChaMoveStorage(), Team.CHO, 13, "車"));
board.put(Position.of(Row.of(8), Column.of(9)),
new Piece(new ChaMoveStorage(), Team.CHO, 13, "車"));
// 상
board.put(Position.of(Row.of(1), Column.of(9)),
new Piece(new SangMoveStorage(), Team.CHO, 3, "象"));
board.put(Position.of(Row.of(6), Column.of(9)),
new Piece(new SangMoveStorage(), Team.CHO, 3, "象"));
// 마
board.put(Position.of(Row.of(2), Column.of(9)),
new Piece(new MaMoveStorage(), Team.CHO, 5, "馬"));
board.put(Position.of(Row.of(7), Column.of(9)),
new Piece(new MaMoveStorage(), Team.CHO, 5, "馬"));
// 사
board.put(Position.of(Row.of(3), Column.of(9)),
new Piece(new GungAndSaMoveStorage(), Team.CHO, 3, "士"));
board.put(Position.of(Row.of(5), Column.of(9)),
new Piece(new GungAndSaMoveStorage(), Team.CHO, 3, "士"));
// 궁
board.put(Position.of(Row.of(4), Column.of(8)),
new Piece(new GungAndSaMoveStorage(), Team.CHO, 0, "楚"));
// 포
board.put(Position.of(Row.of(1), Column.of(7)),
new Piece(new SangMoveStorage(), Team.CHO, 7, "包"));
board.put(Position.of(Row.of(7), Column.of(7)),
new Piece(new SangMoveStorage(), Team.CHO, 7, "包"));
// 졸
board.put(Position.of(Row.of(0), Column.of(6)),
new Piece(new JolMoveStorage(), Team.CHO, 2, "卒"));
board.put(Position.of(Row.of(2), Column.of(6)),
new Piece(new JolMoveStorage(), Team.CHO, 2, "卒"));
board.put(Position.of(Row.of(4), Column.of(6)),
new Piece(new JolMoveStorage(), Team.CHO, 2, "卒"));
board.put(Position.of(Row.of(6), Column.of(6)),
new Piece(new JolMoveStorage(), Team.CHO, 2, "卒"));
board.put(Position.of(Row.of(8), Column.of(6)),
new Piece(new JolMoveStorage(), Team.CHO, 2, "卒"));
}
}
6 changes: 6 additions & 0 deletions src/main/java/janggi/domain/BoardState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package janggi.domain;

public interface BoardState {
boolean hasPieceAt(Position position);
Piece getPieceAt(Position position);
}
Loading