Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
8134675
docs: ๊ธฐ๋Šฅ ๊ตฌํ˜„ ๋ชฉ๋ก ์ž‘์„ฑ
haeseonlee Mar 25, 2026
9e207cc
feat: ์œ„์น˜ ๊ฐ์ฒด ์ƒ์„ฑ
haeseonlee Mar 25, 2026
965e09c
feat: ๊ธฐ๋ฌผ ๊ฐ์ฒด ์ƒ์„ฑ
haeseonlee Mar 25, 2026
77bd1c9
feat: 9*10 ๊ตฌ์กฐ์˜ ์žฅ๊ธฐํŒ ์ƒ์„ฑ
haeseonlee Mar 25, 2026
12c1e87
docs: ๊ธฐ๋Šฅ ๊ตฌํ˜„ ๋ชฉ๋ก ์ˆ˜์ •
haeseonlee Mar 25, 2026
d2d50c1
feat: ๊ธฐ๋ฌผ ๊ตฌํ˜„์ฒด(๊ถ,์‚ฌ,๋งˆ,์ƒ,์ฐจ,ํฌ,์กธ(๋ณ‘)) ์ƒ์„ฑ
haeseonlee Mar 25, 2026
712d8b1
feat: ์žฅ๊ธฐํŒ๊ณผ ๊ธฐ๋ฌผ ์œ„์น˜ ์ดˆ๊ธฐํ™”
haeseonlee Mar 25, 2026
f7496ac
test: ๊ธฐ๋ฌผ์ด ์˜ฌ๋ฐ”๋ฅธ ์œ„์น˜์— ์ดˆ๊ธฐํ™” ๋˜์—ˆ๋Š”์ง€ ํ…Œ์ŠคํŠธ
haeseonlee Mar 26, 2026
7e37375
test: ์กธ ์œ„์น˜ ํ…Œ์ŠคํŠธ ์ค‘๋ณต ์ œ๊ฑฐ ๋ฆฌํŒฉํ„ฐ๋ง
haeseonlee Mar 26, 2026
a0c8431
docs: ๊ธฐ๋ฌผ ์ด๋™ ์ „๋žต ๊ตฌํ˜„ ๋ชฉ๋ก ์ž‘์„ฑ
haeseonlee Mar 26, 2026
d93b2ba
docs: ์ขŒํ‘œ ๊ธฐ๋ณธ ์ด๋™ ์ „๋žต ๊ตฌํ˜„ ๋ชฉ๋ก ์ž‘์„ฑ
haeseonlee Mar 26, 2026
493cf17
feat: ๊ธฐ๋ฌผ ์ขŒํ‘œ ๊ธฐ๋ณธ ์ด๋™ ์ „๋žต ๊ตฌํ˜„
haeseonlee Mar 27, 2026
48991a6
feat: ๊ธฐ๋ฌผ ์ด๋™ ์ „๋žต ๊ตฌํ˜„
haeseonlee Mar 27, 2026
0fc7501
feat: ๋งˆ ๊ธฐ๋ฌผ ์ด๋™ ์ „๋žต ๊ตฌํ˜„
haeseonlee Mar 27, 2026
4aa9b33
test: ๋งˆ ๊ธฐ๋ฌผ ์ด๋™ ๊ธฐ๋Šฅ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
36115aa
test: ๋งˆ ๊ธฐ๋ฌผ ์ด๋™ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
b9728d8
test: ๋งˆ๊ฐ€ ๋ชฉ์ ์ง€์— ๊ฐˆ ์ˆ˜ ์žˆ๋Š”์ง€ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
468a8a8
test: ๊ถ, ์‚ฌ๊ฐ€ ๊ทœ์น™๋Œ€๋กœ ์ด๋™ํ•˜๋Š”์ง€ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
9b9a2cd
feat: ๊ถ, ์‚ฌ๊ฐ€ ๊ทœ์น™๋Œ€๋กœ ์ด๋™ ๊ตฌํ˜„
haeseonlee Mar 27, 2026
7f5f6b1
refactor: ํŒŒ๋ผ๋ฏธํ„ฐ๋ช… ๋ณ€๊ฒฝ ๋ฆฌํŒฉํ„ฐ๋ง
haeseonlee Mar 27, 2026
111c277
feat: ๊ถ ์ด๋™ ๊ฐ€๋Šฅ ํ™•์ธ ์—ฌ๋ถ€ ๊ตฌํ˜„
haeseonlee Mar 27, 2026
41ec251
test: ๊ถ ์ด๋™ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
096de15
test: ์‚ฌ ์ด๋™ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
40cc4e6
feat: ์‚ฌ ์ด๋™ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ ๊ตฌํ˜„
haeseonlee Mar 27, 2026
0e76ae1
feat: ์กธ ์ด๋™ ์ „๋žต ๊ธฐ๋Šฅ ๊ตฌํ˜„
haeseonlee Mar 27, 2026
896a27d
feat: ์กธ ์ด๋™ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ ๊ตฌํ˜„
haeseonlee Mar 27, 2026
2b22d01
test: ์กธ ์ด๋™ ๊ธฐ๋Šฅ ๊ตฌํ˜„ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
6905939
test: ์กธ ์ด๋™ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
056f501
feat: ์ƒ ์ด๋™ ์ „๋žต ๊ธฐ๋Šฅ ๊ตฌํ˜„
haeseonlee Mar 27, 2026
630fda9
feat: ์ƒ ์ด๋™ ์ „๋žต ๊ธฐ๋Šฅ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
dcf8b75
feat: ์ƒ ์ด๋™ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ ๊ตฌํ˜„
haeseonlee Mar 27, 2026
ff92e86
test: ์ƒ ์ด๋™ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
e16f42b
test: ์ฐจ ์ด๋™ ๊ธฐ๋Šฅ ๊ตฌํ˜„
haeseonlee Mar 27, 2026
5dde166
test: ์ฐจ ์ด๋™ ๊ธฐ๋Šฅ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
10fb620
test: ์ฐจ ์ด๋™ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ ๊ตฌํ˜„
haeseonlee Mar 27, 2026
f67b4c8
test: ์ฐจ ์ด๋™ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
c09e0e5
refactor: Piece ๋ฐ˜ํ™˜ ๋ฉ”์„œ๋“œ PieceProvider์— ์œ„์ž„
haeseonlee Mar 27, 2026
ad3cf23
feat: ํฌ ์ด๋™ ์ „๋žต ๊ธฐ๋Šฅ ๊ตฌํ˜„
haeseonlee Mar 27, 2026
96a1c59
test: ํฌ ์ด๋™ ์ „๋žต ๊ธฐ๋Šฅ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
d4392b7
feat: ํฌ ์ด๋™ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ ๊ตฌํ˜„
haeseonlee Mar 27, 2026
fa51506
test: ํฌ ์ด๋™ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ ํ…Œ์ŠคํŠธ
haeseonlee Mar 27, 2026
e2d86d2
docs: ๊ธฐ๋ฌผ ์ด๋™ ์ „๋žต ์ฒดํฌ๋ฆฌ์ŠคํŠธ ์ˆ˜์ •
haeseonlee Mar 27, 2026
c0527fe
docs: ๋ถˆํ•„์š”ํ•œ ํŒจํ‚ค์ง€ ์ œ๊ฑฐ ๋ฐ ํ…Œ์ŠคํŠธ ํด๋ž˜์Šค ํŒจํ‚ค์ง€ ๋ถ„๋ฆฌ
haeseonlee Mar 27, 2026
64e239e
refactor: ๋ถˆํ•„์š”ํ•œ ์ฃผ์„ ์ œ๊ฑฐ
kcnsmoothie Mar 28, 2026
61a8b11
feat: ์ด๋™ ๊ธฐ๋ฌผ ๋ฐ ์ขŒํ‘œ ์ž…๋ ฅ ๊ธฐ๋Šฅ๊ตฌํ˜„
kcnsmoothie Mar 30, 2026
48c8d39
feat: ๋ณด๋“œ ์ถœ๋ ฅ ๊ธฐ๋Šฅ ๊ตฌํ˜„
kcnsmoothie Mar 30, 2026
11db410
refactor: ์œ„์น˜ ๋„๋ฉ”์ธ ํŒจํ‚ค์ง€ ๋ณ€๊ฒฝ
kcnsmoothie Mar 30, 2026
7d09660
feat: ๊ธฐ๋ฌผ์„ ์›€์ง์ด๋Š” ๊ธฐ๋Šฅ ๊ตฌํ˜„
kcnsmoothie Mar 30, 2026
7aaadb1
refactor: ์ž…๋ ฅ ๋ฉ”์‹œ์ง€ ๊ตฌ์ฒดํ™”
kcnsmoothie Mar 30, 2026
97661c6
feat: ๊ธฐ๋ฌผ ๊ฐ์ฒด ์ถœ๋ ฅ์šฉ dto ์ƒ์„ฑ
kcnsmoothie Mar 30, 2026
cfb8b7a
refacor: ์žฅ๊ธฐํŒ ์ƒ์„ฑ ์‹œ์ ์— ์ดˆ๊ธฐํ™”ํ•˜๋„๋ก ์ˆ˜์ •
kcnsmoothie Mar 30, 2026
c57b6f5
refacor: ๊ฐ€๋…์„ฑ์„ ์œ„ํ•ด ์ขŒํ‘œ๋ช… ๋ณ€๊ฒฝ
kcnsmoothie Mar 31, 2026
9b606ac
refacor: ๊ฐ€๋…์„ฑ์„ ์œ„ํ•œ ๋ณ€์ˆ˜๋ช… ๋ณ€๊ฒฝ
kcnsmoothie Apr 1, 2026
c3f9985
feat: ์ž˜๋ชป๋œ ์ž…๋ ฅ์ผ ๊ฒฝ์šฐ ์˜ˆ์™ธ ๋ฉ”์‹œ์ง€๋ฅผ ๋˜์ง€๋Š” ๊ธฐ๋Šฅ ๊ตฌํ˜„
kcnsmoothie Apr 1, 2026
c1a1757
feat: ๊ธฐ๋ฌผ์ด ์ด๋™ํ•  ์ˆ˜ ์—†์„ ๋•Œ ์˜ˆ์™ธ ๋ฉ”์‹œ์ง€๋ฅผ ๋˜์ง€๋Š” ๊ธฐ๋Šฅ ๊ตฌํ˜„
kcnsmoothie Apr 1, 2026
1f65867
feat: ํ˜„์žฌ ์ขŒํ‘œ์™€ ๋ชฉํ‘œ ์ขŒํ‘œ ๋ณ€์ˆ˜๋ช… ๋ณ€๊ฒฝ
kcnsmoothie Apr 1, 2026
6ea82e9
refactor: ์žฌ์‚ฌ์šฉ๋˜๋Š” ์žฅ๊ธฐ ํ–‰,์—ด ํฌ๊ธฐ๋ฅผ ์ƒ์ˆ˜ํ™”
kcnsmoothie Apr 1, 2026
1c04fbb
feat: ํ–‰, ์—ด ๋ฒˆํ˜ธ ํ‘œ์‹œ ๊ตฌํ˜„
kcnsmoothie Apr 1, 2026
80dc8b0
refactor: PieceProvider๋ฅผ ๋ฐ›๋„๋ก ์ˆ˜์ •
kcnsmoothie Apr 1, 2026
08384f8
refactor: ์ขŒํ‘œ๋ฅผ record๋กœ ๋ณ€๊ฒฝ
kcnsmoothie Apr 2, 2026
6e50fb8
refactor: ๊ธฐ๋ฌผ๋ณ„ ์ด๋™ ์ „๋žต์„ Piece ๋ถ€๋ชจ ํด๋ž˜์Šค๋กœ ์ด๋™
kcnsmoothie Apr 2, 2026
5cb1905
feat: ๋นˆ ๊ธฐ๋ฌผ์— ์ฃผ์ž…ํ•  ๋นˆ ์ „๋žต ์ƒ์„ฑ
kcnsmoothie Apr 2, 2026
4900b7c
refactor: PieceProvider๋ฅผ ํ†ตํ•ด ํฌ์ธ์ง€ ๊ฒ€์‚ฌํ•˜๋„๋ก ์ˆ˜์ •
kcnsmoothie Apr 2, 2026
be25672
refactor: ๊ฐ€๋ณ€ ๋ฆฌ์ŠคํŠธ ์ฃผ์ž… ์ œ๊ฑฐ ๋ฐ stream ํ™œ์šฉ
kcnsmoothie Apr 2, 2026
63bde1a
feat: ํฌ์ธ์ง€ ๊ฒ€์‚ฌํ•˜๋Š” ๊ธฐ๋Šฅ ๊ตฌํ˜„
kcnsmoothie Apr 2, 2026
faa43c4
fix: ๋ถˆํ•„์š”ํ•œ ๊ฒ€์ฆ ๋ฉ”์„œ๋“œ ์ œ๊ฑฐ
kcnsmoothie Apr 2, 2026
1131fdc
refactor: ๊ธฐ๋ฌผ์˜ ์ขŒํ‘œ๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๋ฉ”์„œ๋“œ ๋ณ€๊ฒฝ
kcnsmoothie Apr 2, 2026
e293429
refactor: ์žฅ๊ธฐํŒ์ด ์žฅ๊ธฐํŒ ์ดˆ๊ธฐํ™”๋œ ๊ธฐ๋ฌผ ๋ฐฐ์น˜๋ฅผ ์ฃผ์ž…๋ฐ›๋„๋ก ๋ณ€๊ฒฝ
kcnsmoothie 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
39 changes: 38 additions & 1 deletion README.md
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์ •์ƒ์ ์œผ๋กœ ์‹คํ–‰๋˜๋‚˜์š”?

PR ๋ณธ๋ฌธ์— ํ•ด๋‹น ๋ถ€๋ถ„์€ ์ฒดํฌํ•˜์…จ๋Š”๋ฐ
Application ์‹คํ–‰๊ณผ ์ž…์ถœ๋ ฅ์ด ๊ตฌํ˜„๋˜์ง€ ์•Š์•„์„œ ๊ตฌํ˜„ ํ›„ ๋‹ค์‹œ ์š”์ฒญํ•ด์ฃผ์„ธ์š”! โ˜บ๏ธ

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.

๊ตฌํ˜„ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค!

Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
# java-janggi

์žฅ๊ธฐ ๋ฏธ์…˜ ์ €์žฅ์†Œ
# ๊ธฐ๋Šฅ ๊ตฌํ˜„ ๋ชฉ๋ก

## ์žฅ๊ธฐํŒ ์ƒ์„ฑ
- [x] 9 * 10 ๊ตฌ์กฐ์˜ ์žฅ๊ธฐํŒ์„ ์ƒ์„ฑํ•œ๋‹ค.

## ๊ธฐ๋ฌผ ์ƒ์„ฑ
- [x] ๊ธฐ๋ฌผ์„ ์ƒ์„ฑํ•œ๋‹ค.
- [x] ๊ถ, ์‚ฌ, ๋งˆ, ์ƒ, ์ฐจ, ํฌ, ์กธ(๋ณ‘)
- [x] None(์žฅ๊ธฐํŒ์— ๊ธฐ๋ฌผ์ด ์˜ฌ๋ผ๊ฐ€์žˆ์ง€ ์•Š์€ ์ƒํƒœ)์˜ ๊ธฐ๋ฌผ

## ๋ณด๋“œ ์ดˆ๊ธฐํ™”
- [x] ๊ฒŒ์ž„ ์‹œ์ž‘์‹œ ์žฅ๊ธฐํŒ๊ณผ ๊ธฐ๋ฌผ์„ ์˜ฌ๋ฐ”๋ฅธ ์œ„์น˜์— ์ดˆ๊ธฐํ™”ํ•œ๋‹ค.
- [x] ์˜ค๋ฅธ์ƒ(๋งˆ์ƒ๋งˆ์ƒ) ๊ตฌ์กฐ๋กœ ์ดˆ๊ธฐํ™”ํ•œ๋‹ค.
- [x] ๊ธฐ๋ฌผ์ด ์˜ฌ๋ฐ”๋ฅธ ์œ„์น˜์— ๋†“์—ฌ์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.

## ์ขŒํ‘œ ๊ธฐ๋ณธ ์ด๋™ ์ „๋žต
- [x] ๊ธฐ๋ณธ์ ์œผ๋กœ ์ขŒํ‘œ๋Š” ์•ž,๋’ค,์ขŒ,์šฐ,์šฐ์ƒ,์ขŒ์ƒ,์šฐํ•˜,์ขŒํ•˜๋กœ ์›€์ง์ผ ์ˆ˜ ์žˆ๋‹ค.
- [x] ์•ž์œผ๋กœ ์ด๋™ํ•˜๋ฉด (-1,0)๋งŒํผ ์ด๋™ํ•œ๋‹ค.
- [x] ๋’ค๋กœ ์ด๋™ํ•˜๋ฉด (1,0)๋งŒํผ ์ด๋™ํ•œ๋‹ค.
- [x] ์ขŒ๋กœ ์ด๋™ํ•˜๋ฉด (0,-1)๋งŒํผ ์ด๋™ํ•œ๋‹ค.
- [x] ์šฐ๋กœ ์ด๋™ํ•˜๋ฉด (0,1)๋งŒํผ ์ด๋™ํ•œ๋‹ค.
- [x] ์šฐ์ƒ์œผ๋กœ ์ด๋™ํ•˜๋ฉด (-1,1)๋งŒํผ ์ด๋™ํ•œ๋‹ค.
- [x] ์ขŒ์ƒ์œผ๋กœ ์ด๋™ํ•˜๋ฉด (-1,-1)๋งŒํผ ์ด๋™ํ•œ๋‹ค.
- [x] ์šฐํ•˜๋กœ ์ด๋™ํ•˜๋ฉด (1,1)๋งŒํผ ์ด๋™ํ•œ๋‹ค.
- [x] ์ขŒํ•˜๋กœ ์ด๋™ํ•˜๋ฉด (1,-1)๋งŒํผ ์ด๋™ํ•œ๋‹ค.

## ๊ธฐ๋ฌผ ์ด๋™ ์ „๋žต
- [x] ๊ธฐ๋ฌผ ์ด๋™ ์ „๋žต์„ ์ƒ์„ฑํ•œ๋‹ค.
- [x] ๊ถ,์‚ฌ : ๋ฐฉํ–ฅ์— ๊ด€๊ณ„ ์—†์ด ํ•œ ์นธ์”ฉ ์ด๋™ํ•  ์ˆ˜ ์žˆ๋‹ค.
- [x] ๋งˆ : ๋ฐฉํ–ฅ์— ๊ด€๊ณ„ ์—†์ด ์ง์ง„ ํ›„ ๋Œ€๊ฐ์„ ์œผ๋กœ ํ•œ ์นธ ์ด๋™ํ•  ์ˆ˜ ์žˆ๋‹ค.
- [x] ์ด๋™ํ•˜๋Š” ๊ฒฝ๋กœ์— ๊ธฐ๋ฌผ์ด ์กด์žฌํ•ด์„œ๋Š” ์•ˆ๋œ๋‹ค.
- [x] ์ƒ : ๋ฐฉํ–ฅ์— ๊ด€๊ณ„ ์—†์ด ์ง์ง„ ํ›„ ๋Œ€๊ฐ์„ ์œผ๋กœ ๋‘ ์นธ ์ด๋™ํ•  ์ˆ˜ ์žˆ๋‹ค.
- [x] ์ด๋™ํ•˜๋Š” ๊ฒฝ๋กœ์— ๊ธฐ๋ฌผ์ด ์กด์žฌํ•ด์„œ๋Š” ์•ˆ๋œ๋‹ค.
- [x] ์ฐจ : ๋ฐฉํ–ฅ์— ๊ด€๊ณ„ ์—†์ด ์›ํ•˜๋Š”๋งŒํผ ์ด๋™ํ•  ์ˆ˜ ์žˆ๋‹ค.
- [x] ์กธ : ์ขŒ,์šฐ,์•ž์œผ๋กœ ํ•œ ์นธ์”ฉ ์ด๋™ํ•  ์ˆ˜ ์žˆ๋‹ค.
- [x] ๋’ค๋กœ๋Š” ๊ฐˆ ์ˆ˜ ์—†๋‹ค.
- [x] ํฌ : ์•ž์— ๊ธฐ๋ฌผ์ด ํ•œ ๊ฐœ ์กด์žฌํ•  ๋•Œ ์›ํ•˜๋Š” ๊ณณ์œผ๋กœ ๋›ฐ์–ด๋„˜์„ ์ˆ˜ ์žˆ๋‹ค.
- [x] ํฌ๋ผ๋ฆฌ๋Š” ๋›ฐ์–ด๋„˜์„ ์ˆ˜ ์—†๋‹ค.
10 changes: 10 additions & 0 deletions src/main/java/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import controller.JanggiController;
import view.InputView;
import view.OutputView;

public class Application {
public static void main(String[] args) {
JanggiController janggiController = new JanggiController(new InputView(), new OutputView());
janggiController.run();
}
}
58 changes: 58 additions & 0 deletions src/main/java/controller/JanggiController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package controller;

import domain.JanggiBoard;
import domain.JanggiBoardInitializer;
import domain.piece.Piece;
import domain.position.Position;
import view.InputView;
import view.OutputView;

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

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

public void run() {
JanggiBoard janggiBoard = new JanggiBoard(new JanggiBoardInitializer());
while (true) {
try {
outputView.printBoard(janggiBoard);
Position from = inputMovePosition();
Position to = inputTargetPosition();
Piece currentPiece = janggiBoard.getPiece(from);
boolean movePiece = currentPiece.canMove(from, to, janggiBoard);
if (!movePiece) {
throw new IllegalArgumentException("[ERROR] ํ•ด๋‹น ์œ„์น˜๋กœ ์ด๋™ํ•  ์ˆ˜ ์—†๋Š” ๊ธฐ๋ฌผ์ž…๋‹ˆ๋‹ค.");
}
janggiBoard.move(from, to, currentPiece);
outputView.printBoard(janggiBoard);
} catch (IllegalArgumentException e) {
outputView.printErrorMessage(e);
}
}
}

private Position inputMovePosition() {
String inputMovePosition = inputView.inputMovePiece();
String[] parts = inputMovePosition.split(",");

int row = Integer.parseInt(parts[0].trim());
int column = Integer.parseInt(parts[1].trim());

return new Position(row, column);
}

private Position inputTargetPosition() {
String inputTargetPosition = inputView.inputTargetPosition();
String[] parts = inputTargetPosition.split(",");

int row = Integer.parseInt(parts[0].trim());
int column = Integer.parseInt(parts[1].trim());

return new Position(row, column);
}
}
17 changes: 17 additions & 0 deletions src/main/java/domain/Index.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package domain;

public enum Index {

BOARD_ROWS(10),
BOARD_COLUMNS(9);

private final int index;

Index(int index) {
this.index = index;
}

public int getIndex() {
return index;
}
}
46 changes: 46 additions & 0 deletions src/main/java/domain/JanggiBoard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package domain;

import static domain.Index.BOARD_COLUMNS;
import static domain.Index.BOARD_ROWS;

import domain.piece.*;

import domain.position.Position;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;

public class JanggiBoard implements PieceProvider {

private final Map<Position, Piece> janggiBoard;

public JanggiBoard(JanggiBoardInitializer initializer) {
this.janggiBoard = initializer.init();
}

public Map<Position, Piece> getJanggiBoard() {
return Collections.unmodifiableMap(janggiBoard);
}

public void move(Position from, Position to, Piece currentPiece) {
janggiBoard.put(to, currentPiece);
janggiBoard.put(from, new Blank());
}

@Override
public boolean isBlank(Position position) {
Piece piece = janggiBoard.get(position);
return piece instanceof Blank;
}

@Override
public boolean isCannon(Position position) {
Piece piece = janggiBoard.get(position);
return piece instanceof Cannon;
}

@Override
public Piece getPiece(Position position) {
return janggiBoard.get(position);
}
}
60 changes: 60 additions & 0 deletions src/main/java/domain/JanggiBoardInitializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package domain;

import static domain.Index.BOARD_COLUMNS;
import static domain.Index.BOARD_ROWS;

import domain.piece.Blank;
import domain.piece.Cannon;
import domain.piece.Car;
import domain.piece.Elephant;
import domain.piece.Guard;
import domain.piece.Horse;
import domain.piece.King;
import domain.piece.Pawn;
import domain.piece.Piece;
import domain.position.Position;
import java.util.HashMap;
import java.util.Map;

public class JanggiBoardInitializer {
public Map<Position, Piece> init() {
Map<Position, Piece> boardSetting = new HashMap<>();

for (int row = 0; row < BOARD_ROWS.getIndex(); row++) {
for (int col = 0; col < BOARD_COLUMNS.getIndex(); col++) {
boardSetting.put(new Position(row, col), new Blank());
}
}

setupTeamPieces(boardSetting, Team.HAN, 0, 1, 2, 3); // ํ•œ๋‚˜๋ผ ๊ธฐ๋ฌผ ๋ฐฐ์น˜ (0~3ํ–‰ ์œ„์ฃผ)
setupTeamPieces(boardSetting, Team.CHO, 9, 8, 7, 6); // ์ดˆ๋‚˜๋ผ ๊ธฐ๋ฌผ ๋ฐฐ์น˜ (9~6ํ–‰ ์œ„์ฃผ)

return boardSetting;
}

private void setupTeamPieces(Map<Position, Piece> boardSetting, Team team, int baseRow, int kingRow, int cannonRow,
int pawnRow) {
// ์ฐจ
boardSetting.put(new Position(baseRow, 0), new Car(team));
boardSetting.put(new Position(baseRow, 8), new Car(team));
// ๋งˆ
boardSetting.put(new Position(baseRow, 1), new Horse(team));
boardSetting.put(new Position(baseRow, 6), new Horse(team));
// ์ƒ
boardSetting.put(new Position(baseRow, 2), new Elephant(team));
boardSetting.put(new Position(baseRow, 7), new Elephant(team));
// ์‚ฌ
boardSetting.put(new Position(baseRow, 3), new Guard(team));
boardSetting.put(new Position(baseRow, 5), new Guard(team));
// ๊ถ
boardSetting.put(new Position(kingRow, 4), new King(team));
// ํฌ
boardSetting.put(new Position(cannonRow, 1), new Cannon(team));
boardSetting.put(new Position(cannonRow, 7), new Cannon(team));
// ์กธ/๋ณ‘
for (int col = 0; col < 9; col += 2) {
boardSetting.put(new Position(pawnRow, col), new Pawn(team));
}
}

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

import domain.piece.Blank;
import domain.piece.Piece;
import domain.position.Position;

public class JanggiGame {
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 void play(Position from, Position to, PieceProvider janggiBoard) {
Piece piece = janggiBoard.getPiece(from);
validateBlank(piece);
piece.canMove(from, to, janggiBoard);
}

private void validateBlank(Piece piece) {
if (piece instanceof Blank) {
throw new IllegalArgumentException("ํ•ด๋‹น ์œ„์น˜์— ๊ธฐ๋ฌผ์ด ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.");
}
}
}
10 changes: 10 additions & 0 deletions src/main/java/domain/PieceProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package domain;

import domain.piece.Piece;
import domain.position.Position;

public interface PieceProvider {
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.

๊ธฐ๋ฌผ ์ค‘ ๋งˆ(Horse)๊ฐ™์€ ๊ฒฝ์šฐ ์ง์„ ์œผ๋กœ ํ•œ ์นธ, ๋Œ€๊ฐ์„ ์œผ๋กœ ํ•œ ์นธ ์›€์ง์ด๋Š” ์ด๋™ ๋ฐฉ์‹์„ ๊ฐ€์ง‘๋‹ˆ๋‹ค. ๋งˆ์˜ ์ด๋™ ๊ฒฝ๋กœ์—์„œ๋Š” ์ค‘๊ฐ„ ์ขŒํ‘œ์™€ ๋ชฉ์ ์ง€ ์ขŒํ‘œ๋ฅผ ์ง€๋‚˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ, ๋งˆ๋Š” ์ค‘๊ฐ„ ์ขŒํ‘œ์— ๊ธฐ๋ฌผ์ด ์žˆ์œผ๋ฉด ์•ˆ๋œ๋‹ค๋Š” ์ œ์•ฝ ์กฐ๊ฑด์„ ๊ฐ€์ง‘๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ ์ด๋™ ์ค‘

  1. ์ค‘๊ฐ„ ์ขŒํ‘œ๋ฅผ ๊ณ„์‚ฐํ•œ๋‹ค.
  2. ์ค‘๊ฐ„ ์ขŒํ‘œ์— ๊ธฐ๋ฌผ์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.

๋ผ๋Š” ๊ณผ์ •์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

์ด๋•Œ ์ง์ ‘ ์žฅ๊ธฐํŒ(JanggiBoard)์—์„œ ๊ธฐ๋ฌผ์„ ๊ฐ€์ ธ์˜ค๋ฉด ๊ธฐ๋ฌผ์ด ์žฅ๊ธฐํŒ์„ ์ง์ ‘ ์•Œ๊ฒŒ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์บก์Аํ™”๋ฅผ ๊นจ๋œจ๋ฆฐ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค. ์บก์Аํ™”๋ฅผ ์ง€์ผœ์ฃผ๊ธฐ ์œ„ํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ ์ธํ„ฐํŽ˜์ด์Šค๋กœ

  1. ํ•ด๋‹น ์ขŒํ‘œ๊ฐ€ ๋น„์–ด์žˆ๋Š”์ง€
  2. (๋ชฉ์ ์ง€ ์ขŒํ‘œ์ผ ๊ฒฝ์šฐ๋ฅผ ๊ณ ๋ คํ•˜์—ฌ) ํ•ด๋‹น ์ขŒํ‘œ์— ์–ด๋–ค ๊ธฐ๋ฌผ์ด ์žˆ๋Š”์ง€

ํ™•์ธํ•˜๊ณ  ๋ฐ˜ํ™˜ํ•˜๋„๋ก ํ–ˆ์Šต๋‹ˆ๋‹ค.

boolean isBlank(Position position);
boolean isCannon(Position position);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

piece ์ž์ฒด๊ฐ€ isCannon ์ธ์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š”๊ฒƒ์€ ์–ด๋– ์‹ ๊ฐ€์š”?

piece.isCannon() ์ฒ˜๋Ÿผ ํ˜ธ์ถœํ•  ์ˆ˜ ์žˆ๊ฒŒ์š”

Piece getPiece(Position position);
}
7 changes: 7 additions & 0 deletions src/main/java/domain/Team.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package domain;

public enum Team {
CHO,
HAN,
NONE
}
14 changes: 14 additions & 0 deletions src/main/java/domain/dto/JanggiBoardDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package domain.dto;

import domain.JanggiBoard;
import java.util.List;

public record JanggiBoardDTO(List<PieceDTO> janggiBoardDto) {
public static JanggiBoardDTO from(JanggiBoard janggiBoard) {
List<PieceDTO> pieceDtos = janggiBoard.getJanggiBoard().entrySet().stream()
.map(entry -> PieceDTO.from(entry.getKey(), entry.getValue()))
.toList();

return new JanggiBoardDTO(pieceDtos);
}
}
11 changes: 11 additions & 0 deletions src/main/java/domain/dto/PieceDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package domain.dto;

import domain.Team;
import domain.piece.Piece;
import domain.position.Position;

public record PieceDTO(int row, int col, Team team) {
public static PieceDTO from(Position position, Piece piece) {
return new PieceDTO(position.row(), position.col(), piece.getTeam());
}
}
18 changes: 18 additions & 0 deletions src/main/java/domain/piece/Blank.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package domain.piece;

import domain.PieceProvider;
import domain.Team;
import domain.position.Position;
import domain.strategy.NoStrategy;

public class Blank extends Piece {

public Blank() {
super(Team.NONE, new NoStrategy());
}

@Override
public boolean canMove(Position from, Position to, PieceProvider pieceProvider) {
return false;
}
}
27 changes: 27 additions & 0 deletions src/main/java/domain/piece/Cannon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package domain.piece;

import domain.PieceProvider;
import domain.position.Position;
import domain.Team;
import domain.strategy.CannonStrategy;

import domain.strategy.Strategy;
import java.util.List;

public class Cannon extends Piece {

public Cannon(Team team) {
super(team, new CannonStrategy());
}

@Override
public boolean canMove(Position from, Position to, PieceProvider pieceProvider) {
List<Position> moveCandidates = moveStrategy.getMoveCandidates(from, pieceProvider);
for (Position candidatePosition : moveCandidates) {
if (candidatePosition.equals(to)) {
return true;
}
}
return false;
}
}
28 changes: 28 additions & 0 deletions src/main/java/domain/piece/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package domain.piece;

import domain.PieceProvider;
import domain.position.Position;
import domain.Team;
import domain.strategy.CarStrategy;
import domain.strategy.Strategy;

import java.util.List;

public class Car extends Piece {

public Car(Team team) {
super(team, new CarStrategy());
}

@Override
public boolean canMove(Position from, Position to, PieceProvider pieceProvider) {
List<Position> moveCandidates = moveStrategy.getMoveCandidates(from, pieceProvider);

for (Position candidatePosition : moveCandidates) {
if (candidatePosition.equals(to)) {
return true;
}
}
return false;
}
}
Loading