Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[둘리] 1, 2단계 오목 제출합니다. #26

Merged
merged 18 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
fe3ce07
docs: 오목 기능 목록 작성
tmdgh1592 Mar 14, 2023
ca4182c
feat: 1부터 15 위치를 가진 오목알 클래스 구현
tmdgh1592 Mar 14, 2023
e13e7da
feat: 중복 오목알 처리를 위한 오목알 일급 컬렉션 구현
tmdgh1592 Mar 14, 2023
fa5e2b9
docs: .gitkeep 파일 제거
tmdgh1592 Mar 14, 2023
0c398fd
feat: 오목알을 놓은 플레이어가 게임에서 이겼는지 확인하는 기능 구현
tmdgh1592 Mar 14, 2023
190d007
feat: 사용자가 오목알을 놓았을 때 상태를 반환하는 기능 구현
tmdgh1592 Mar 14, 2023
9d0c276
feat: 오목판에 돌을 올려놓는 기능 구현
tmdgh1592 Mar 15, 2023
606cfcf
feat: 플레이어의 오목알을 놓는 턴을 바꾸는 기능 구현
tmdgh1592 Mar 15, 2023
f96746e
refactor: 돌을 놓으면 새로운 상태를 가진 플레이어 반환하는 기능 구현
tmdgh1592 Mar 15, 2023
e5e8ce4
feat: 플레이어가 놓은 마지막 돌을 리턴하는 기능 구현
tmdgh1592 Mar 15, 2023
c472a31
refactor: 오목알을 놓을 수 있는지 확인하는 함수를 Players 클래스로 이동
tmdgh1592 Mar 15, 2023
f4f1b15
feat: 오목 게임 진행하는 기능 구현
tmdgh1592 Mar 15, 2023
28bb0cd
feat: 오목 게임 입력, 출력 화면 구현
tmdgh1592 Mar 15, 2023
f37f93b
feat: 오목 컨트롤러 구현
tmdgh1592 Mar 15, 2023
b1fcb5b
refactor: 도메인 패키지 분리
tmdgh1592 Mar 15, 2023
11b2666
fix: 중간에 오목알을 뒀을 때 승리 판정하지 않는 오류 수정
tmdgh1592 Mar 16, 2023
a0166e0
feat: 렌주룰 기능 추가 (미완성)
tmdgh1592 Mar 16, 2023
7eb0bc9
feat: 렌주룰 적용 (완성)
tmdgh1592 Mar 16, 2023
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
refactor: 돌을 놓으면 새로운 상태를 가진 플레이어 반환하는 기능 구현
  • Loading branch information
tmdgh1592 committed Mar 15, 2023
commit f96746e307833bb259081e480a52b159d3b180ef
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [x] 사용자는 특정 위치에 내 돌이 있는지 확인한다.
- [ ] 사용자는 마지막 돌의 위치를 알고 있다.
- [ ] 게임의 진행 여부는 `PlayerState`가 결정한다.
- [x] 오목알을 놓으면 상대방의 차례가 된다.

### Input
- [ ] 오목알을 놓을 위치를 입력받는다.
Expand Down
11 changes: 5 additions & 6 deletions src/main/kotlin/player/Board.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ import BoardState
import Position.Companion.POSITION_RANGE
import Stone

class Board(blackPlayer: Player, whitePlayer: Player) {
private val players: Players = Players(blackPlayer, whitePlayer)
class Board(private val players: Players) {
constructor(blackPlayer: Player, whitePlayer: Player) : this(Players(blackPlayer, whitePlayer))

private fun canPlace(stone: Stone): Boolean = allPlayers().none { it.isPlaced(stone) }

private fun allPlayers(): List<Player> = players.toList()

fun putStone(turn: Turn, stone: Stone): Boolean {
fun putStone(turn: Turn, stone: Stone): Player? {
if (canPlace(stone)) {
players.putStone(turn, stone)
return true
return players.putStone(turn, stone)
}
return false
return null
}

private fun makeEmptyBoard(): List<MutableList<BoardState>> =
Expand Down
4 changes: 1 addition & 3 deletions src/main/kotlin/player/Players.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ class Players private constructor(private val players: Map<Turn, Player>) {

fun toList(): List<Player> = players.values.toList()

fun putStone(turn: Turn, stone: Stone) {
players[turn]?.putStone(stone)
}
fun putStone(turn: Turn, stone: Stone): Player? = players[turn]?.putStone(stone)
}