diff --git a/Assets/Script/Renju/RenjuForbiddenMoveDetector.cs b/Assets/Script/Renju/RenjuForbiddenMoveDetector.cs index 35446af..fce9c13 100644 --- a/Assets/Script/Renju/RenjuForbiddenMoveDetector.cs +++ b/Assets/Script/Renju/RenjuForbiddenMoveDetector.cs @@ -2,10 +2,12 @@ using UnityEngine; -public class RenjuForbiddenMoveDetector +public class RenjuForbiddenMoveDetector : ForbiddenDetectorBase { // 렌주 룰 금수 감지기 생성 - private RenjuRuleChecker _ruleChecker = new RenjuRuleChecker(); + private RenjuOverlineDetector _overlineDetactor = new(); + private RenjuDoubleFourDetector _doubleFourDetactor = new(); + private RenjuDoubleThreeDetector _doubleThreeDetector = new(); /// /// 렌주 룰로 금수 리스트를 반환하는 함수 @@ -15,6 +17,40 @@ public class RenjuForbiddenMoveDetector public List RenjuForbiddenMove(Enums.PlayerType[,] board) { var tempBoard = (Enums.PlayerType[,])board.Clone(); - return _ruleChecker.GetForbiddenMoves(tempBoard); + + List forbiddenMoves = new(); + for (int row = 0; row < BoardSize; row++) + { + for (int col = 0; col < BoardSize; col++) + { + // ** 비어 있지 않으면 검사할 필요 없음 ** + if (!IsEmptyPosition(tempBoard, row, col)) continue; + + // 장목 검사 + if (_overlineDetactor.IsOverline(tempBoard, row, col)) + { + Debug.Log("장목 금수 좌표 X축 : " + row + ", Y축 : " + col); + forbiddenMoves.Add(new Vector2Int(row, col)); + continue; + } + + // 4-4 검사 + if (_doubleFourDetactor.IsDoubleFour(tempBoard, row, col)) + { + Debug.Log("사사 금수 좌표 X축 : " + row + ", Y축 : " + col); + forbiddenMoves.Add(new Vector2Int(row, col)); + continue; + } + + // 3-3 검사 + if (_doubleThreeDetector.IsDoubleThree(tempBoard, row, col)) + { + Debug.Log("삼삼 금수 좌표 X축 : " + row + ", Y축 : " + col); + forbiddenMoves.Add(new Vector2Int(row, col)); + } + } + } + + return forbiddenMoves; } } \ No newline at end of file diff --git a/Assets/Script/Renju/RenjuRuleChecker.cs b/Assets/Script/Renju/RenjuRuleChecker.cs deleted file mode 100644 index 8cdf082..0000000 --- a/Assets/Script/Renju/RenjuRuleChecker.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; - -/// -/// 렌주 규칙의 모든 금수 규칙(3-3, 4-4, 장목)을 검사하는 통합 클래스 -/// -public class RenjuRuleChecker: ForbiddenDetectorBase -{ - private RenjuOverlineDetector _overlineDetactor = new(); - private RenjuDoubleFourDetector _doubleFourDetactor = new(); - private RenjuDoubleThreeDetector _doubleThreeDetector = new(); - - public List GetForbiddenMoves(Enums.PlayerType[,] board) - { - List forbiddenMoves = new(); - for (int row = 0; row < BoardSize; row++) - { - for (int col = 0; col < BoardSize; col++) - { - // ** 비어 있지 않으면 검사할 필요 없음 ** - if (!IsEmptyPosition(board, row, col)) continue; - - // 장목 검사 - if (_overlineDetactor.IsOverline(board, row, col)) - { - Debug.Log("장목 금수 좌표 X축 : " + row + ", Y축 : " + col); - forbiddenMoves.Add(new Vector2Int(row, col)); - continue; - } - - // 4-4 검사 - if (_doubleFourDetactor.IsDoubleFour(board, row, col)) - { - Debug.Log("사사 금수 좌표 X축 : " + row + ", Y축 : " + col); - forbiddenMoves.Add(new Vector2Int(row, col)); - continue; - } - - // 3-3 검사 - if (_doubleThreeDetector.IsDoubleThree(board, row, col)) - { - Debug.Log("삼삼 금수 좌표 X축 : " + row + ", Y축 : " + col); - forbiddenMoves.Add(new Vector2Int(row, col)); - } - } - } - - return forbiddenMoves; - } -} - diff --git a/Assets/Script/Renju/RenjuRuleChecker.cs.meta b/Assets/Script/Renju/RenjuRuleChecker.cs.meta deleted file mode 100644 index a982a5d..0000000 --- a/Assets/Script/Renju/RenjuRuleChecker.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 083e8b9070ed407b8744d4cacd0d53dc -timeCreated: 1742256498 \ No newline at end of file