-
Notifications
You must be signed in to change notification settings - Fork 75
[아크] 1, 2단계 오목 제출합니다. #3
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
흑, 백의 차례를 객체로 표현한 점이 참신하네요 :)
테스트 코드들의 가독성도 좋았습니다.
몇 가지 피드백을 남겨두었으니 확인 후 다시 요청해주세요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
피드백 잘 반영해주셨네요 👍️
33과 같은 규칙을 별도 객체로 분리한 부분과 오목판을 동적으로 만드는 부분이 인상적이었습니다.
이번 피드백은 다음 단계에서 반영해주시면 됩니다.
다음 단계도 힘내세요!
private val inputView: InputView = InputView(), | ||
private val outputView: OutputView = OutputView(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
생성자로 주입받는 걸로는 충분하지 않습니다.
InputView, OutputView 구현체에 직접적인 의존성이 있기 때문에 interface로 선언하여 느슨하게 결합해주셔야 합니다.
private fun StoneState.name(): String = when (this) { | ||
BlackStoneState -> "흑" | ||
WhiteStoneState -> "백" | ||
else -> "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재는 간단해서 이 정도로도 충분하지만 여러 데이터를 합쳐야 하는 복잡한 객체인 경우에는 StoneStateModel
과 같이 별도의 클래스를 선언해주는게 좋습니다.
object OmokMap { | ||
fun makeMap(omokBoard: OmokBoard): List<List<String>> { | ||
val omokMap = MutableList(omokBoard.ySize) { MutableList(omokBoard.xSize) { "" } } | ||
omokBoard.keys.forEach { point -> | ||
omokMap[point.y.value - 1][point.x.value - 1] = getString(omokBoard[point], point.y.value - 1, point.x.value - 1) | ||
} | ||
return omokMap | ||
} | ||
|
||
private fun getString(stoneState: StoneState, x: Int, y: Int): String = | ||
getFix(x, y).format(getStone(stoneState, x, y)) | ||
|
||
private fun getFix(x: Int, y: Int): String = when { | ||
x == X_MIN_INDEX && y == Y_MIN_INDEX -> " %s─" | ||
x == X_MIN_INDEX && y == Y_MAX_INDEX -> "─%s " | ||
x == X_MAX_INDEX && y == Y_MIN_INDEX -> " %s─" | ||
x == X_MAX_INDEX && y == Y_MAX_INDEX -> "─%s " | ||
x == X_MIN_INDEX -> "─%s─" | ||
x == X_MAX_INDEX -> "─%s─" | ||
y == Y_MIN_INDEX -> " %s─" | ||
y == Y_MAX_INDEX -> "─%s " | ||
else -> "─%s─" | ||
} | ||
|
||
private fun getStone(stoneState: StoneState, x: Int, y: Int): String = when { | ||
stoneState == BlackStoneState -> "●" | ||
stoneState == WhiteStoneState -> "○" | ||
x == X_MAX_INDEX && y == Y_MIN_INDEX -> "┌" | ||
x == X_MAX_INDEX && y == Y_MAX_INDEX -> "┐" | ||
x == X_MIN_INDEX && y == Y_MIN_INDEX -> "└" | ||
x == X_MIN_INDEX && y == Y_MAX_INDEX -> "┘" | ||
x == X_MAX_INDEX -> "┬" | ||
x == X_MIN_INDEX -> "┴" | ||
y == Y_MIN_INDEX -> "├" | ||
y == Y_MAX_INDEX -> "┤" | ||
else -> "┼" | ||
} | ||
|
||
private const val X_MIN_INDEX = 0 | ||
private const val X_MAX_INDEX = X_MAX_RANGE - X_MIN_RANGE | ||
private const val Y_MIN_INDEX = 0 | ||
private const val Y_MAX_INDEX = Y_MAX_RANGE - Y_MIN_RANGE | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오목판 자체를 동적으로 변경할 수 있게 만들어주셨군요 👍️
package omok.domain.omokRule | ||
|
||
object WhiteWinRule : OmokRule(WHITE_STONE, BLACK_STONE) { | ||
override fun validate(board: List<List<Int>>, position: Pair<Int, Int>): Boolean = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
각 Int가 어떤 역할인지 알 수 있도록 Pair를 반환하고 넘기기보다는 별도의 객체로 선언해주세요.
* docs (README): 기능 구현 목록 작성 * feat (XCoordinate): X의 좌표 구현 * feat (YCoordinate): Y의 좌표 구현 * refactor (Coordinate): 매직 넘버 수정 * docs (README): 기능 구현 목록 수정 * feat (StoneState): 돌의 상태 기능 구현 * feat (XLine): X 좌표를 저장 할 수 있다. * feat (YLine): Y 좌표를 저장 할 수 있다. * feat (OmokBoard): 오목 판을 구현한다. * feat (OmokGame): 플레이어들이 오목을 플레이 할 수 있다. * refactor (OmokPoint): x,y를 하나의 클래스로 구현 * refactor (Test): 테스트 케이스 수정 * feat (InputView): 좌표 입력 받는 기능 구현 * feat (OutputView):현재 오목 상태를 출력한다. * refactor (OmokController): 오목게임을 실행 할 수 있도록 변경 * refactor (OmokBoard): 같은 역할 클래스 합침 * refactor (OmokBoard): 상태 패턴적용 * feat (OmokBoard): 33룰 적용 * refactor (OmokRule): 33룰 적용 * feat (OmokRule): 44룰 적용 * refactor (StoneState): 돌 상태 패턴 적용 * refactor (OmokRule): 승리 조건 테스트 케이스 추가 * refactor (OmokBoard): 오목돌 의존성 변경 * refactor (OmokBoard): 게임 진행상황 상태 패턴 적용 * refactor (OmokBoard): 검은돌 금수 적용 * style (Omok): 코딩 컨벤션 적용 * refactor (OmokRule): 규칙 변경 * refactor (OmokBoard): 추상화된 라인 제거 후 보드로 통합 * refactor (OmokBoard): 예외 메세지 추가 * refactor (XCoordinate): x좌표 숫자로 저장되도록 변경 * refactor (StoneState): 뷰영역 역할 도메인에서 제거 * refactor (OmokBoard): 보드의 크기 보드 객체가 가지고 있도록 변경 * refactor (OmokRule): 규칙 구조 변경 * refactor (OmokRule): 어뎁터 패턴 외부로 추출 * refactor (OmokController): 주입식 의존성으로 변경 * refactor (OmokRule): 룰 규칙 상태 개선 * refactor (OutputView): 화면 출력 적응형으로 개선 * refactor (Constants): 상수 구조 개선 * refactor (OmokBoard): OmokBoard 생성구조 개선 * style (Omok): 코드 스타일 맞추기 * refactor (OmokBoard): 보드 관련 테스트 케이스 개선 * refactor (StoneState): 돌 동일성 케이스 추가 * refactor (OmokRuleTest): 테스트 케이스 가독성 개선 * refactor (InputView): 함수명 변경
* docs (README): 기능 구현 목록 작성 * feat (XCoordinate): X의 좌표 구현 * feat (YCoordinate): Y의 좌표 구현 * refactor (Coordinate): 매직 넘버 수정 * docs (README): 기능 구현 목록 수정 * feat (StoneState): 돌의 상태 기능 구현 * feat (XLine): X 좌표를 저장 할 수 있다. * feat (YLine): Y 좌표를 저장 할 수 있다. * feat (OmokBoard): 오목 판을 구현한다. * feat (OmokGame): 플레이어들이 오목을 플레이 할 수 있다. * refactor (OmokPoint): x,y를 하나의 클래스로 구현 * refactor (Test): 테스트 케이스 수정 * feat (InputView): 좌표 입력 받는 기능 구현 * feat (OutputView):현재 오목 상태를 출력한다. * refactor (OmokController): 오목게임을 실행 할 수 있도록 변경 * refactor (OmokBoard): 같은 역할 클래스 합침 * refactor (OmokBoard): 상태 패턴적용 * feat (OmokBoard): 33룰 적용 * refactor (OmokRule): 33룰 적용 * feat (OmokRule): 44룰 적용 * refactor (StoneState): 돌 상태 패턴 적용 * refactor (OmokRule): 승리 조건 테스트 케이스 추가 * refactor (OmokBoard): 오목돌 의존성 변경 * refactor (OmokBoard): 게임 진행상황 상태 패턴 적용 * refactor (OmokBoard): 검은돌 금수 적용 * style (Omok): 코딩 컨벤션 적용 * refactor (OmokRule): 규칙 변경 * refactor (OmokBoard): 추상화된 라인 제거 후 보드로 통합 * refactor (OmokBoard): 예외 메세지 추가 * refactor (XCoordinate): x좌표 숫자로 저장되도록 변경 * refactor (StoneState): 뷰영역 역할 도메인에서 제거 * refactor (OmokBoard): 보드의 크기 보드 객체가 가지고 있도록 변경 * refactor (OmokRule): 규칙 구조 변경 * refactor (OmokRule): 어뎁터 패턴 외부로 추출 * refactor (OmokController): 주입식 의존성으로 변경 * refactor (OmokRule): 룰 규칙 상태 개선 * refactor (OutputView): 화면 출력 적응형으로 개선 * refactor (Constants): 상수 구조 개선 * refactor (OmokBoard): OmokBoard 생성구조 개선 * style (Omok): 코드 스타일 맞추기 * refactor (OmokBoard): 보드 관련 테스트 케이스 개선 * refactor (StoneState): 돌 동일성 케이스 추가 * refactor (OmokRuleTest): 테스트 케이스 가독성 개선 * refactor (InputView): 함수명 변경
안녕하세요! 리뷰어님! 오목 리뷰동안 잘 부탁드립니다!