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

[전남대 Android_최영빈] 미션 제출합니다. #32

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
20db24e
Update README.md
yb0x00 Jun 5, 2024
cdad999
Refactor: Add initializeBoard function
yb0x00 Jun 8, 2024
4071641
feat: Add placeStone function
yb0x00 Jun 8, 2024
8f1b3ff
feat: Add isPositionEmpty function
yb0x00 Jun 8, 2024
7b588f0
Refactor: Add showToast function
yb0x00 Jun 8, 2024
87a3ee4
feat: Add checkHorizontal function
yb0x00 Jun 8, 2024
d69cb49
feat: Add checkVertical function
yb0x00 Jun 8, 2024
d1ddd25
feat: Add checkDiagonal function
yb0x00 Jun 8, 2024
36466a5
feat: Add checkWin function
yb0x00 Jun 8, 2024
f6faf58
feat: Add checkDirection function
yb0x00 Jun 8, 2024
d6336e9
Revert "feat: Add checkDirection function"
yb0x00 Jun 8, 2024
0496956
Revert "feat: Add checkWin function"
yb0x00 Jun 8, 2024
3803db9
Revert "feat: Add checkDiagonal function"
yb0x00 Jun 8, 2024
c861142
Revert "feat: Add checkVertical function"
yb0x00 Jun 8, 2024
84d0f62
Revert "feat: Add checkHorizontal function"
yb0x00 Jun 8, 2024
31030a1
merge conflict
yb0x00 Jun 8, 2024
63805af
feat: Add checkVertical
yb0x00 Jun 8, 2024
7106d3c
Refactor: Change checkVertical function to private
yb0x00 Jun 8, 2024
f6b2052
Refafctor: Remove unnecessary semicolons
yb0x00 Jun 8, 2024
1e3eaa5
feat: Add checkHorizontal functioin
yb0x00 Jun 8, 2024
8e7a531
feat: Add checkDiagonal function
yb0x00 Jun 8, 2024
72d0bbb
feat: Add checkState function
yb0x00 Jun 8, 2024
75864aa
Refactor: Remove unnecessary parameters from checkVertical function
yb0x00 Jun 8, 2024
e2ec5f8
Refactor: Change checkVertical function parameters
yb0x00 Jun 8, 2024
f974756
Refactor: Change checkVertical function
yb0x00 Jun 8, 2024
0dd7604
feat: Add displayResult function
yb0x00 Jun 8, 2024
e2e8ec9
Refafctor: Add game-ending functionality to the displayResult function
yb0x00 Jun 8, 2024
bc25ee4
Refactor: Change functions to public for test code
yb0x00 Jun 8, 2024
519f120
Revert "Refactor: Change functions to public for test code"
yb0x00 Jun 8, 2024
c448235
feat: Create Test Code
yb0x00 Jun 8, 2024
2efe6bf
Refactor: Create Referee class
yb0x00 Jun 9, 2024
e14ac8a
feat: Create Referee Test Code
yb0x00 Jun 9, 2024
674eae0
Refactor: Improve Error Handling in Referee Class
yb0x00 Jun 9, 2024
0e48b54
Update README.md
yb0x00 Jun 9, 2024
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
Revert "feat: Add checkDiagonal function"
This reverts commit d1ddd25.
  • Loading branch information
yb0x00 committed Jun 8, 2024
commit 3803db917f22515d53b99f725268575933e0ab58
16 changes: 0 additions & 16 deletions app/src/main/java/nextstep/omok/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -81,20 +81,4 @@ class MainActivity : AppCompatActivity() {
return (topCount + bottomCount) >= 4 // stone 포함시 5 이상
}

private fun checkDiagonal(position: Int): Boolean {
val row = position / boardSize
val column = position % boardSize
val stone = boardState[position] ?: return false

// 왼쪽 위에서 오른쪽 아래 방향 대각선
val leftTopCount = (1..minOf(row, column)).takeWhile { boardState[(row - it) * boardSize + (column - it)] == stone }.count()
val rightBottomCount = (1..minOf(boardSize - row - 1, boardSize - column - 1)).takeWhile { boardState[(row + it) * boardSize + (column + it)] == stone }.count()

// 오른쪽 위에서 왼쪽 아래 방향 대각선
val rightTopCount = (1..minOf(row, boardSize - column - 1)).takeWhile { boardState[(row - it) * boardSize + (column + it)] == stone }.count()
val leftBottomCount = (1..minOf(boardSize - row - 1, column)).takeWhile { boardState[(row + it) * boardSize + (column - it)] == stone }.count()

return (leftTopCount + rightBottomCount) >= 4 || (rightTopCount + leftBottomCount) >= 4 // stone 포함시 5 이상
}

}