diff --git a/README.md b/README.md index 08a8c8a..64ee9ac 100644 --- a/README.md +++ b/README.md @@ -1 +1,40 @@ -# android-omok-precourse \ No newline at end of file +# android-omok-precourse + +## 1. 기능 목록 +--- +### 1. 리소스 파일 추가 +- [x] 로고 리소스 파일 추가하기 +- [x] 폰트 리소스 파일 추가하기 +- [x] 커스텀 버튼 드로우블 제작하기 +- [x] 커스텀 컬러 추가하기 + +### 2. 모델 구현 +- [x] 게임 모델 구현 +- [x] 플레이어 모델 구현 + +### 3. 뷰 구성 +- [x] 메인 화면 뷰 구성하기 +- [x] 오목판 뷰 구성하기 +- [x] 승리 시 팝업 뷰 구성 + +### 4. 기능 구현 +- [x] 메인 화면에서 오목판으로 화면 전환 기능 추가 +- [x] 게임 초기화 기능 추가 +- [x] 오목판에 돌 놓기 기능 추가 +- [x] 플레이어 전환 기능 추가 +- [x] 승리 조건 확인 기능 추가 +- [x] 승리 시 팝업 표시 기능 추가 + + +### 5. 단위 테스트 추가 +- [x] 단위 테스트 추가 +--- + +## 2. 스크린샷 +

+ + + + +

+ diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 41a5486..3ea3dae 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -60,4 +60,4 @@ dependencies { androidTestImplementation("io.kotest:kotest-runner-junit5:5.8.0") androidTestImplementation("de.mannodermaus.junit5:android-test-core:1.3.0") androidTestRuntimeOnly("de.mannodermaus.junit5:android-test-runner:1.3.0") -} +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 250f3db..d1c706e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,6 +12,9 @@ android:supportsRtl="true" android:theme="@style/Theme.Omok" tools:targetApi="31"> + @@ -23,4 +26,4 @@ - + \ No newline at end of file diff --git a/app/src/main/java/nextstep/omok/BoardActivity.kt b/app/src/main/java/nextstep/omok/BoardActivity.kt new file mode 100644 index 0000000..8dd8711 --- /dev/null +++ b/app/src/main/java/nextstep/omok/BoardActivity.kt @@ -0,0 +1,88 @@ +package nextstep.omok + +import android.content.Intent +import android.os.Bundle +import android.view.View +import android.widget.Button +import android.widget.ImageView +import android.widget.TextView +import androidx.activity.enableEdgeToEdge +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat + +class BoardActivity : AppCompatActivity() { + private lateinit var turnImage: ImageView + private lateinit var newGame: TextView + private lateinit var gameBoardFragment: GameBoardFragment + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_board) + + turnImage = findViewById(R.id.turnImage) + newGame = findViewById(R.id.newGameButton) + + // 프래그먼트 추가 + if (savedInstanceState==null){ + gameBoardFragment = GameBoardFragment() + supportFragmentManager.beginTransaction() + .add(R.id.fragment_container, gameBoardFragment) + .commit() + } else { + gameBoardFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) as GameBoardFragment + } + + GameModel.resetGame() + updateTurnImage() + + newGame.setOnClickListener { + resetGame() + } + + } + + // 턴 이미지 업데이트 + fun updateTurnImage() { + turnImage.setImageResource(GameModel.getCurrentPlayerStoneResId()) + } + + // 새 게임 버튼 클릭시 게임 초기화 + fun resetGame() { + GameModel.resetGame() + gameBoardFragment.resetBoard() + updateTurnImage() + } + + // 승리 다이얼로그 표시 + fun showWinDialog() { + val dialogView = layoutInflater.inflate(R.layout.popup_victory , null) + // 다이얼로그 생성 및 표시 + val dialog = androidx.appcompat.app.AlertDialog.Builder(this).setView(dialogView).create() + dialog.show() + + setWinnerImage(dialog) + + dialog.findViewById