Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e350817
docs: add feature list in README
Giyoul Mar 24, 2026
54c52f7
docs: update printing format
Giyoul Mar 24, 2026
cea7131
feat(domain): set up initial project structure for Janggi game
Giyoul Mar 25, 2026
a4dd966
feat(validation): add input validation and retry logic for arrangemenโ€ฆ
Giyoul Mar 25, 2026
2ecd53b
feat(domain): implement board initialization with piece layout
Giyoul Mar 25, 2026
dc5aea1
feat(domain): complete board setup by placing all pieces via Positionโ€ฆ
Giyoul Mar 25, 2026
e80a819
feat(console): add board display with piece layout and circular depenโ€ฆ
Giyoul Mar 25, 2026
6fae64a
feat(console): add move prompt output after board display
Giyoul Mar 25, 2026
47da921
feat(validation): add move command input with coordinate parsing and โ€ฆ
Giyoul Mar 25, 2026
c332484
feat(domain): implement piece movement execution and validation
Giyoul Mar 26, 2026
0e135c2
feat(domain): implement turn switching after each move
Giyoul Mar 26, 2026
0705f6a
feat(domain): validate piece ownership on move
Giyoul Mar 26, 2026
f23ebdd
feat: add ascii code color to output
Giyoul Mar 27, 2026
f4e3164
feat: add ReadyState
Giyoul Mar 27, 2026
e777f0f
feat: add ReadyState final version
Giyoul Mar 27, 2026
e3019f7
refactor(domain): VO/์ผ๊ธ‰ ์ปฌ๋ ‰์…˜ ๋„์ž…
Giyoul Mar 29, 2026
8202ac2
refactor(domain): getter & setter ์ œ๊ฑฐ
Giyoul Mar 29, 2026
79e0ec1
refactor(domain): ๋ฉ”์„œ๋“œ ๋ถ„๋ฆฌ ๋ฐ ๋“ค์—ฌ์“ฐ๊ธฐ ๊นŠ์ด ์ œํ•œ ์ˆ˜์ •
Giyoul Mar 29, 2026
67523a2
refactor(domain): ํ•œ ์ค„ ์  ํ•˜๋‚˜ ๊ทœ์น™ ์ ์šฉ
Giyoul Mar 29, 2026
232df9b
refactor: ๋„๋ฉ”์ธ ๊ฐœ๋… ๋‹จ์œ„๋กœ ํŒจํ‚ค์ง€ ์žฌ๊ตฌ์„ฑ
Giyoul Mar 29, 2026
507f00b
refactor: ๋ถˆํ•„์š” ํ•จ์ˆ˜ ์ œ๊ฑฐ
Giyoul Mar 29, 2026
d1cc672
refactor: ์ค‘๋ณต ํ•จ์ˆ˜ ์‚ญ์ œ
Giyoul Mar 30, 2026
9b7c1e6
test(domain): ์ „์ฒด ๋„๋ฉ”์ธ ๋‹จ์œ„ ํ…Œ์ŠคํŠธ ์ถ”๊ฐ€
Giyoul Mar 30, 2026
895149b
docs: README ๊ธฐ๋Šฅ ํ๋ฆ„๋„ ์ž‘์„ฑ
Giyoul Mar 30, 2026
10fa86b
refactor: Pieces ์ƒ์„ฑ์ž ๋ฐฉ์–ด์  ๋ณต์‚ฌ ์ถ”๊ฐ€
symflee Mar 31, 2026
488a630
refactor: ์ปจ๋ฒค์…˜์— ์–ด๊ธ‹๋‚œ ์ƒ์ˆ˜๋ฉด ์ˆ˜์ •
symflee Mar 31, 2026
f1856ae
refactor: Arrangements๊ฐ€ ์ƒˆ ๊ฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•˜์—ฌ ๋ถˆ๋ณ€ ๊ฐ์ฒด์ฒ˜๋Ÿผ ๋™์ž‘ํ•˜๋„๋ก ์ˆ˜์ •
symflee Apr 1, 2026
fad8f35
refactor*(GameConsole): ์œ ํšจ์ž…๋ ฅ๊นŒ์ง€ ๋ฐ˜๋ณต๋กœ์ง์˜ ์žฌ๊ท€๊ตฌ์กฐ ์ œ๊ฑฐํ•˜์—ฌ StackOverflow ์œ„ํ—˜ ์ œ๊ฑฐ
symflee Apr 1, 2026
6d6c28f
refactor: Col -> Column ๋„ค์ด๋ฐ ๋ณ€๊ฒฝ
symflee Apr 2, 2026
552a14d
refactor(Column): ๋ถˆํ•„์š”ํ•œ try๋ฌธ ์ œ๊ฑฐ
symflee Apr 2, 2026
9c10571
refactor(MovementFactory): Movement ๊ตฌํ˜„์ฒด ์ƒ์„ฑ ๋กœ์ง ํ†ต์ผ
symflee Apr 2, 2026
65d48a8
refactor: ์ง์„  ์ด๋™ ๋ฐ ๋ง์ƒ ๋ถ„๊ธฐ ๋„ค์ด๋ฐ ์ •๋ฆฌ
symflee Apr 2, 2026
8ecccff
refactor: ๋„๋ฉ”์ธ์˜ OutputView ์˜์กด ์ œ๊ฑฐ
symflee Apr 2, 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ out/

### VS Code ###
.vscode/

REFACTORING.md
171 changes: 170 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,172 @@
# java-janggi

์žฅ๊ธฐ ๋ฏธ์…˜ ์ €์žฅ์†Œ
## ๐Ÿ“‹ ๋ชฉ์ฐจ

- [๊ฐœ์š”](#-๊ฐœ์š”)
- [๊ตฌํ˜„ ๊ธฐ๋Šฅ ๋ชฉ๋ก](#-๊ตฌํ˜„-๊ธฐ๋Šฅ-๋ชฉ๋ก)
- [์ž…์ถœ๋ ฅ ์š”๊ตฌ ์‚ฌํ•ญ](#์ž…์ถœ๋ ฅ-์š”๊ตฌ-์‚ฌํ•ญ)
- [์ปค๋ฐ‹ ์ปจ๋ฒค์…˜](#์ปค๋ฐ‹-์ปจ๋ฒค์…˜)

---

## 1๏ธโƒฃ ๊ฐœ์š”

### ๊ธฐ๋Šฅ ํ๋ฆ„

```
[๊ฒŒ์ž„ ์‹œ์ž‘]
โ”‚
โ–ผ
[์ƒ์ฐจ๋ฆผ ์ž…๋ ฅ - ReadyState]
ํ•œ(HAN) ์ƒ์ฐจ๋ฆผ ์„ ํƒ (1~4)
โ”‚ ์˜ˆ์™ธ โ†’ ์žฌ์ž…๋ ฅ
โ–ผ
์ดˆ(CHO) ์ƒ์ฐจ๋ฆผ ์„ ํƒ (1~4)
โ”‚ ์˜ˆ์™ธ โ†’ ์žฌ์ž…๋ ฅ
โ–ผ
[๋ณด๋“œ ์ดˆ๊ธฐํ™”]
์ž…๋ ฅ๋œ ์ƒ์ฐจ๋ฆผ ๊ธฐ์ค€์œผ๋กœ ๊ธฐ๋ฌผ ๋ฐฐ์น˜
โ”‚
โ–ผ
[๊ฒŒ์ž„ ์ง„ํ–‰ - PlayingState] โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
ํ˜„์žฌ ํ„ด ์ถœ๋ ฅ + ๋ณด๋“œ ์ถœ๋ ฅ โ”‚
โ”‚ โ”‚
โ–ผ โ”‚
์ฐฉ์ˆ˜ ๋ช…๋ น์–ด ์ž…๋ ฅ ({์ถœ๋ฐœ์ขŒํ‘œ} {๋„์ฐฉ์ขŒํ‘œ}) โ”‚
โ”‚ ์˜ˆ์™ธ โ†’ ์žฌ์ž…๋ ฅ (ํ˜„์žฌ ํ„ด ์œ ์ง€) โ”‚
โ–ผ โ”‚
์ด๋™ ์œ ํšจ์„ฑ ๊ฒ€์ฆ โ”‚
โ”œโ”€ ์ถœ๋ฐœ ์ขŒํ‘œ์— ๊ธฐ๋ฌผ ์—†์Œ โ†’ ์˜ˆ์™ธ โ”‚
โ”œโ”€ ์ถœ๋ฐœ ์ขŒํ‘œ๊ฐ€ ์ƒ๋Œ€ ๊ธฐ๋ฌผ โ†’ ์˜ˆ์™ธ โ”‚
โ”œโ”€ ๋„์ฐฉ ์ขŒํ‘œ์— ์•„๊ตฐ ๊ธฐ๋ฌผ โ†’ ์˜ˆ์™ธ โ”‚
โ””โ”€ ๊ธฐ๋ฌผ ์ด๋™ ๊ทœ์น™ ์œ„๋ฐ˜ โ†’ ์˜ˆ์™ธ โ”‚
โ”‚ ์„ฑ๊ณต โ”‚
โ–ผ โ”‚
๊ธฐ๋ฌผ ์ด๋™ (๋„์ฐฉ ์ขŒํ‘œ์— ์ƒ๋Œ€ ๊ธฐ๋ฌผ ์žˆ์œผ๋ฉด ์ œ๊ฑฐ) โ”‚
โ”‚ โ”‚
โ–ผ โ”‚
ํ„ด ๊ต์ฒด (ํ•œ โ†” ์ดˆ) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

## 2๏ธโƒฃ ๊ตฌํ˜„ ๊ธฐ๋Šฅ ๋ชฉ๋ก

### โœ… 1์ฐจ ๊ตฌํ˜„ ๊ธฐ๋Šฅ ๋ชฉ๋ก

#### 1.1๋‹จ๊ณ„: ๋ณด๋“œ ์ดˆ๊ธฐํ™”

- [x] **1. [์ถœ๋ ฅ] ์ƒ์ฐจ๋ฆผ ์˜ˆ์‹œ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.**
- [x] **2. [์ž…๋ ฅ] ์ƒ์ฐจ๋ฆผ์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.**
- [x] [์ž…๋ ฅ] ํ•œ์˜ ์ƒ์ฐจ๋ฆผ์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.
- [x] [์˜ˆ์™ธ ์ฒ˜๋ฆฌ] ๋นˆ ์ž…๋ ฅ์ผ ๊ฒฝ์šฐ `IllegalArgumentException` ์„ ๋ฐœ์ƒ์‹œํ‚ค๊ณ , ์žฌ์ž…๋ ฅ์„ ๋ฐ›๋Š”๋‹ค.
- [x] [์˜ˆ์™ธ ์ฒ˜๋ฆฌ] 1~4 ์™ธ์˜ ๋ฌธ์ž๋ฅผ ์ž…๋ ฅํ•œ ๊ฒฝ์šฐ `IllegalArgumentException` ์„ ๋ฐœ์ƒ์‹œํ‚ค๊ณ , ์žฌ์ž…๋ ฅ์„ ๋ฐ›๋Š”๋‹ค.
- [x] [์ž…๋ ฅ] ์ดˆ์˜ ์ƒ์ฐจ๋ฆผ์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.
- [x] [์˜ˆ์™ธ ์ฒ˜๋ฆฌ] ๋นˆ ์ž…๋ ฅ์ผ ๊ฒฝ์šฐ `IllegalArgumentException` ์„ ๋ฐœ์ƒ์‹œํ‚ค๊ณ , ์žฌ์ž…๋ ฅ์„ ๋ฐ›๋Š”๋‹ค.
- [x] [์˜ˆ์™ธ ์ฒ˜๋ฆฌ] 1~4 ์™ธ์˜ ๋ฌธ์ž๋ฅผ ์ž…๋ ฅํ•œ ๊ฒฝ์šฐ `IllegalArgumentException` ์„ ๋ฐœ์ƒ์‹œํ‚ค๊ณ , ์žฌ์ž…๋ ฅ์„ ๋ฐ›๋Š”๋‹ค.
- [x] **3. [์ค‘๊ฐ„ ๊ณผ์ •] ์ž…๋ ฅ๋ฐ›์€ ์ƒ์ฐจ๋ฆผ์„ ๊ธฐ์ค€์œผ๋กœ ๊ธฐ๋ฌผ์„ ๋ฐฐ์น˜ํ•œ๋‹ค.**
- [x] **4. [์ถœ๋ ฅ] ํ˜„์žฌ ๋ณด๋“œ์˜ ๊ธฐ๋ฌผ ๋ฐฐ์น˜๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.**

#### 1.2๋‹จ๊ณ„: ๊ธฐ๋ฌผ ์ด๋™

- [x] **5. [์ถœ๋ ฅ] ์ฐฉ์ˆ˜ ๋ช…๋ น์–ด ํ˜•์‹๊ณผ ํ˜„์žฌ ์–ด๋А ํŒ€์˜ ํ„ด์ธ์ง€๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.**
- [x] **6. [์ž…๋ ฅ] ํ˜„์žฌ ํ„ด์˜ ์ง„ํ–‰์ž์—๊ฒŒ ์ฐฉ์ˆ˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. (ex. '{์ถœ๋ฐœ์ขŒํ‘œ} {๋„์ฐฉ์ขŒํ‘œ}' 'A0 B1')**
- [x] [์˜ˆ์™ธ ์ฒ˜๋ฆฌ] ๋นˆ ์ž…๋ ฅ์ผ ๊ฒฝ์šฐ `IllegalArgumentException` ์„ ๋ฐœ์ƒ์‹œํ‚ค๊ณ , ์žฌ์ž…๋ ฅ์„ ๋ฐ›๋Š”๋‹ค.
- [x] [์˜ˆ์™ธ ์ฒ˜๋ฆฌ] ์ž…๋ ฅ๋ฐ›์€ ๊ฐ’์ด ์ง€์ • ํ˜•์‹์ธ '{์ถœ๋ฐœ์ขŒํ‘œ} {๋„์ฐฉ์ขŒํ‘œ}'๊ฐ€ ์•„๋‹ ๊ฒฝ์šฐ ` IllegalArgumentException` ์„ ๋ฐœ์ƒ์‹œํ‚ค๊ณ , ์žฌ์ž…๋ ฅ์„ ๋ฐ›๋Š”๋‹ค.
- [x] [์˜ˆ์™ธ ์ฒ˜๋ฆฌ] ์ž…๋ ฅ๋ฐ›์€ column ๊ฐ’์ด A~I ๋ฒ”์œ„์˜ ๊ฐ’์ด ์•„๋‹Œ ๊ฒฝ์šฐ `IllegalArgumentException` ์„ ๋ฐœ์ƒ์‹œํ‚ค๊ณ , ์žฌ์ž…๋ ฅ์„ ๋ฐ›๋Š”๋‹ค.
- [x] [์˜ˆ์™ธ ์ฒ˜๋ฆฌ] ์ž…๋ ฅ๋ฐ›์€ row ๊ฐ’์ด 0~9 ๋ฒ”์œ„์˜ ๊ฐ’์ด ์•„๋‹Œ ๊ฒฝ์šฐ `IllegalArgumentException` ์„ ๋ฐœ์ƒ์‹œํ‚ค๊ณ , ์žฌ์ž…๋ ฅ์„ ๋ฐ›๋Š”๋‹ค.
- [x] **7. [์ค‘๊ฐ„ ๊ณผ์ •] ์‚ฌ์šฉ์ž๊ฐ€ ๋ช…๋ นํ•œ ์ฐฉ์ˆ˜๋ฅผ ์ˆ˜ํ–‰ํ•œ๋‹ค.**
- [x] [์˜ˆ์™ธ ์ฒ˜๋ฆฌ] ์•„๋ž˜์˜ ๊ฒฝ์šฐ ์™œ ์ด๋™์ด ๋ถˆ๊ฐ€๋Šฅํ•œ์ง€ ์ถœ๋ ฅํ•˜๊ณ , ํ•ด๋‹น ํ”Œ๋ ˆ์ด์–ด์˜ ํ„ด์œผ๋กœ ์ฒ˜์Œ๋ถ€ํ„ฐ ์žฌ์ž…๋ ฅ์„ ๋ฐ›๋Š”๋‹ค.
- [x] [์ค‘๊ฐ„ ๊ณผ์ •] ์ถœ๋ฐœ ์ขŒํ‘œ์— ๊ธฐ๋ฌผ์ด ์—†๋Š” ๊ฒฝ์šฐ
- [x] [์ค‘๊ฐ„ ๊ณผ์ •] ์ถœ๋ฐœ ์ขŒํ‘œ์— ์ƒ๋Œ€ ๊ธฐ๋ฌผ์ด ์žˆ๋Š” ๊ฒฝ์šฐ
- [x] [์ค‘๊ฐ„ ๊ณผ์ •] ๊ฐ ๊ธฐ๋ฌผ ๊ณ ์œ ์˜ ์ด๋™ ๊ทœ์น™์— ๋”ฐ๋ผ ์ด๋™์ด ๋ถˆ๊ฐ€๋Šฅํ•œ ๊ฒฝ์šฐ
- [x] [์ค‘๊ฐ„ ๊ณผ์ •] ๋„์ฐฉ ์ขŒํ‘œ์— ์•„๊ตฐ ๊ธฐ๋ฌผ์ด ์žˆ์„ ๊ฒฝ์šฐ
- [x] [์ค‘๊ฐ„ ๊ณผ์ •] ๋„์ฐฉ ์ขŒํ‘œ์— ์ƒ๋Œ€ ๊ธฐ๋ฌผ์ด ์žˆ์œผ๋ฉด ์—†์•ค๋‹ค.
- [x] [์ค‘๊ฐ„ ๊ณผ์ •] ์ถœ๋ฐœ ์ขŒํ‘œ์— ์žˆ๋˜ ๊ธฐ๋ฌผ์„ ๋„์ฐฉ ์ขŒํ‘œ๋กœ ์˜ฎ๊ธด๋‹ค.
- [x] [์ค‘๊ฐ„ ๊ณผ์ •] ํ„ด์„ ๋„˜๊ธด๋‹ค.

## 3๏ธโƒฃ ์ž…์ถœ๋ ฅ ์š”๊ตฌ ์‚ฌํ•ญ

### ์‹คํ–‰ ๊ฒฐ๊ณผ ์˜ˆ์‹œ

```
[ํ•œ(HAN) ์ง„์˜] ๋ฐฐ์น˜๋ฅผ ์„ ํƒํ•˜์„ธ์š”.
1. ๋งˆ-์ƒ-๋งˆ-์ƒ (Horse-Elephant-Horse-Elephant)
2. ๋งˆ-์ƒ-์ƒ-๋งˆ (Horse-Elephant-Elephant-Horse)
3. ์ƒ-๋งˆ-๋งˆ-์ƒ (Elephant-Horse-Horse-Elephant)
4. ์ƒ-๋งˆ-์ƒ-๋งˆ (Elephant-Horse-Elephant-Horse)
> 1

[์ดˆ(CHO) ์ง„์˜] ๋ฐฐ์น˜๋ฅผ ์„ ํƒํ•˜์„ธ์š”.
1. ๋งˆ-์ƒ-๋งˆ-์ƒ (Horse-Elephant-Horse-Elephant)
2. ๋งˆ-์ƒ-์ƒ-๋งˆ (Horse-Elephant-Elephant-Horse)
3. ์ƒ-๋งˆ-๋งˆ-์ƒ (Elephant-Horse-Horse-Elephant)
4. ์ƒ-๋งˆ-์ƒ-๋งˆ (Elephant-Horse-Elephant-Horse)
> 2

--------------------------------------
ํ˜„์žฌ ํ„ด: [์ดˆ(CHO) ์ง„์˜]

a b c d e f g h i
0 ํ•œ์ฐจ ํ•œ๋งˆ ํ•œ์ƒ ํ•œ์‚ฌ ... ํ•œ์‚ฌ ํ•œ๋งˆ ํ•œ์ƒ ํ•œ์ฐจ
1 ... ... ... ... ํ•œ๊ถ ... ... ... ...
2 ... ํ•œํฌ ... ... ... ... ... ํ•œํฌ ...
3 ํ•œ๋ณ‘ ... ํ•œ๋ณ‘ ... ํ•œ๋ณ‘ ... ํ•œ๋ณ‘ ... ํ•œ๋ณ‘
4 ... ... ... ... ... ... ... ... ...
5 ... ... ... ... ... ... ... ... ...
6 ์ดˆ์กธ ... ์ดˆ์กธ ... ์ดˆ์กธ ... ์ดˆ์กธ ... ์ดˆ์กธ
7 ... ์ดˆํฌ ... ... ... ... ... ์ดˆํฌ ...
8 ... ... ... ... ์ดˆ๊ถ ... ... ... ...
9 ์ดˆ์ฐจ ์ดˆ๋งˆ ์ดˆ์ƒ ์ดˆ์‚ฌ ... ์ดˆ์‚ฌ ์ดˆ์ƒ ์ดˆ๋งˆ ์ดˆ์ฐจ

[์ดˆ(CHO) ์ง„์˜] {์ถœ๋ฐœ ์ขŒํ‘œ} {๋„์ฐฉ ์ขŒํ‘œ} ํ˜•์‹์œผ๋กœ ์ž…๋ ฅํ•ด ์ˆ˜๋ฅผ ๋‘์„ธ์š”. (ex. e6 e5)
> ์˜๊ธฐ

[ERROR] ์ขŒํ‘œ ํ˜•์‹์ด ํ‹€๋ ธ์Šต๋‹ˆ๋‹ค!

--------------------------------------
ํ˜„์žฌ ํ„ด: [์ดˆ(CHO) ์ง„์˜]

a b c d e f g h i
0 ํ•œ์ฐจ ํ•œ๋งˆ ํ•œ์ƒ ํ•œ์‚ฌ ... ํ•œ์‚ฌ ํ•œ๋งˆ ํ•œ์ƒ ํ•œ์ฐจ
1 ... ... ... ... ํ•œ๊ถ ... ... ... ...
2 ... ํ•œํฌ ... ... ... ... ... ํ•œํฌ ...
3 ํ•œ๋ณ‘ ... ํ•œ๋ณ‘ ... ํ•œ๋ณ‘ ... ํ•œ๋ณ‘ ... ํ•œ๋ณ‘
4 ... ... ... ... ... ... ... ... ...
5 ... ... ... ... ... ... ... ... ...
6 ์ดˆ์กธ ... ์ดˆ์กธ ... ์ดˆ์กธ ... ์ดˆ์กธ ... ์ดˆ์กธ
7 ... ์ดˆํฌ ... ... ... ... ... ์ดˆํฌ ...
8 ... ... ... ... ์ดˆ๊ถ ... ... ... ...
9 ์ดˆ์ฐจ ์ดˆ๋งˆ ์ดˆ์ƒ ์ดˆ์‚ฌ ... ์ดˆ์‚ฌ ์ดˆ์ƒ ์ดˆ๋งˆ ์ดˆ์ฐจ

[์ดˆ(CHO) ์ง„์˜] {์ถœ๋ฐœ ์ขŒํ‘œ} {๋„์ฐฉ ์ขŒํ‘œ} ํ˜•์‹์œผ๋กœ ์ž…๋ ฅํ•ด ์ˆ˜๋ฅผ ๋‘์„ธ์š”. (ex. e6 e5)
>
```

---

## 4๏ธโƒฃ ์ปค๋ฐ‹ ์ปจ๋ฒค์…˜

Following convention : https://gist.github.com/stephenparish/9941e89d80e2bc58a153

```markdown
# basic structure
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>

# <type>
feat (feature)
fix (bug fix)
docs (documentation)
style (formatting, missing semi colons, โ€ฆ)
refactor
test (when adding missing tests)
chore (maintain)

# <scope>
console - I/O
domain - ํ•ต์‹ฌ ๋กœ์ง
validation - ์œ ํšจ์„ฑ๊ฒ€์‚ฌ
test - ํ…Œ์ŠคํŠธ์ฝ”๋“œ ์ถ”๊ฐ€
```
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'java'
id 'jacoco'
}

version '1.0-SNAPSHOT'
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import io.GameConsole;

public class Application {
public static void main(String[] args) {
GameConsole gameConsole = new GameConsole();
gameConsole.run();
}
}
74 changes: 74 additions & 0 deletions src/main/java/domain/board/Board.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package domain.board;

import domain.game.Turn;
import domain.movement.Movement;
import domain.movement.MovementFactory;
import domain.movement.MovementValidator;
import domain.movement.Paths;
import domain.piece.Piece;
import domain.setup.Arrangements;
import domain.setup.Coordinate;
import java.util.Optional;

public class Board {
private final Pieces pieces;

public Board(Pieces pieces) {
this.pieces = pieces;
}

public static Board of(Arrangements arrangements) {
return new Board(Pieces.of(arrangements));
}

public Board move(Coordinate coordinate, Turn turn) {
validateMove(coordinate, turn);
Position from = coordinate.from();
Position to = coordinate.to();
return new Board(pieces.move(from, to));
}

public Optional<Piece> pieceAt(Position position) {
return pieces.at(position);
}

public boolean isEmpty(Position position) {
return pieces.at(position).isEmpty();
}

public boolean hasAnyPiece(Position position) {
return !isEmpty(position);
}

public boolean hasFriendOf(Position position, Piece movingPiece) {
return pieces.at(position)
.map(movingPiece::isSameTeamAs)
.orElse(false);
}

public boolean hasEnemyOf(Position position, Piece movingPiece) {
return pieces.at(position)
.map(targetPiece -> !movingPiece.isSameTeamAs(targetPiece))
.orElse(false);
}

private void validateMove(Coordinate coordinate, Turn turn) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

private ๋ฉ”์„œ๋“œ๊ฐ€ ๊ฝค ํฌ๋„ค์š”.

Board๊ฐ€ ๊ฐ–๊ณ  ์žˆ๊ธฐ์— ์กฐ๊ธˆ ๋ฌด๊ฑฐ์šด ์ฑ…์ž„์ด์ง€ ์•Š๋‚˜ ์‹ถ์–ด๋ณด์—ฌ์š”

์งˆ๋ฌธ์ž…๋‹ˆ๋‹ค. Board์˜ ์—ญํ• ๊ณผ ์ฑ…์ž„์€ ์–ด๋–ป๊ฒŒ / ์–ด๋А ๋ฒ”์œ„๋กœ ์„ค๊ณ„ํ•˜์…จ๋‚˜์š”?

Position from = coordinate.from();
Position to = coordinate.to();

Piece piece = pieces.at(from)
.orElseThrow(() -> new IllegalArgumentException("[ERROR] ํ•ด๋‹น ์ขŒํ‘œ์— ๊ธฐ๋ฌผ์ด ์—†์Šต๋‹ˆ๋‹ค: " + from));

if (!turn.belongsTo(piece)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

์ด๊ณณ์—์„œ๋งŒ ์ด ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๋ฐ !๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ‘œํ˜„ํ•˜๋Š”๊ฒƒ๋ณด๋‹ค ๋ถ€์ •ํ‘œํ˜„์„ ํ™œ์šฉํ•ด๋ณด๋Š”๊ฒŒ ์–ด๋–จ๊นŒ์š”?

throw new IllegalArgumentException("[ERROR] ์ถœ๋ฐœ ์ขŒํ‘œ์˜ ๊ธฐ๋ฌผ์ด ์ƒ๋Œ€ ๊ธฐ๋ฌผ์ž…๋‹ˆ๋‹ค.");
}

Movement movement = MovementFactory.create(piece);
Paths paths = movement.candidatePaths(from);

MovementValidator validator = new MovementValidator(this);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

์–‘๋ฐฉํ–ฅ ์˜์กด์„ฑ์ด ์ƒ๊ธด๊ฒƒ ๊ฐ™๋„ค์š”?

if (!validator.isValid(piece, paths, to)) {
throw new IllegalArgumentException("[ERROR] ์œ ํšจํ•˜์ง€ ์•Š์€ ์›€์ง์ž„์ž…๋‹ˆ๋‹ค.");
}
}
}
33 changes: 33 additions & 0 deletions src/main/java/domain/board/Column.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package domain.board;

import java.util.Arrays;

public enum Column {
A,
B,
C,
D,
E,
F,
G,
H,
I;

public boolean canShift(int delta) {
int next = this.ordinal() + delta;
return next >= 0 && next < Column.values().length;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

์ƒ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ด์ฃผ์„ธ์š”

}

public Column shift(int delta) {
return Column.values()[this.ordinal() + delta];
}

public static Column toColumn(char character) {
char upperChar = Character.toUpperCase(character);

return Arrays.stream(values())
.filter(column -> column.name().charAt(0) == upperChar)
.findAny()
.orElseThrow(() -> new IllegalArgumentException("[ERROR] ์˜ฌ๋ฐ”๋ฅธ ์—ด ๊ฐ’์ด ์•„๋‹™๋‹ˆ๋‹ค."));
}
}
34 changes: 34 additions & 0 deletions src/main/java/domain/board/Pieces.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package domain.board;

import domain.piece.Piece;
import domain.setup.Arrangements;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

public class Pieces {
private final Map<Position, Piece> pieces;

public Pieces(Map<Position, Piece> pieces) {
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.

๋„ต, ๋ฐฉ์–ด์  ๋ณต์‚ฌ๊ฐ€ ๋ฐ˜๋“œ์‹œ ํ•„์š”ํ•œ ๊ณณ์ด๋ผ๊ณ  ์ƒ๊ฐ์ด ๋˜๋Š”๋ฐ ๋ˆ„๋ฝ์ด ๋˜์–ด์žˆ์—ˆ๋„ค์š”.
Key์™€ Value๋Š” ๋ถˆ๋ณ€์ด๋ฏ€๋กœ, new HashMap์œผ๋กœ ์–•์€ ๋ณต์‚ฌ๋ฅผ ์ˆ˜ํ–‰ํ•ด ๋ฐฉ์–ด์  ๋ณต์‚ฌ๋ฅผ ์ ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค.

this.pieces = new HashMap<>(pieces);
}

public static Pieces of(Arrangements arrangements) {
return new Pieces(PositionLayout.build(arrangements));
}

public Pieces move(Position from, Position to) {
Piece piece = pieces.get(from);
if (piece == null) {
throw new IllegalArgumentException("[ERROR] ํ•ด๋‹น ์œ„์น˜์— ๊ธฐ๋ฌผ์ด ์—†์Šต๋‹ˆ๋‹ค: " + from);
}
Map<Position, Piece> newMap = new HashMap<>(pieces);
newMap.remove(from);
newMap.put(to, piece);
return new Pieces(newMap);
}

public Optional<Piece> at(Position position) {
return Optional.ofNullable(pieces.get(position));
}
}
16 changes: 16 additions & 0 deletions src/main/java/domain/board/Position.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package domain.board;

import domain.movement.Delta;

public record Position(Column column, Row row) {
public boolean canShift(Delta delta) {
return column.canShift(delta.columnDelta().value()) && row.canShift(delta.rowDelta().value());
}

public Position shift(Delta delta) {
return new Position(
column.shift(delta.columnDelta().value()),
row.shift(delta.rowDelta().value())
);
}
}
Loading