From ed9e8664a807f7508abbe143212868eec4af4690 Mon Sep 17 00:00:00 2001 From: fiore Date: Wed, 19 Mar 2025 17:10:53 +0900 Subject: [PATCH] =?UTF-8?q?DO-31=20Refactor:=20=EC=A4=91=EB=B3=B5=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - RenjuRuleChecker.cs 삭제 - RenjuForbiddenMoveDetector.cs로 통합 --- .../Renju/RenjuForbiddenMoveDetector.cs | 42 +++++++++++++-- Assets/Script/Renju/RenjuRuleChecker.cs | 51 ------------------- Assets/Script/Renju/RenjuRuleChecker.cs.meta | 3 -- 3 files changed, 39 insertions(+), 57 deletions(-) delete mode 100644 Assets/Script/Renju/RenjuRuleChecker.cs delete mode 100644 Assets/Script/Renju/RenjuRuleChecker.cs.meta 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