From ea1c64023d69d7c6a4b2db78bfc3d4fb94b04adf Mon Sep 17 00:00:00 2001 From: fiore Date: Mon, 17 Mar 2025 10:21:26 +0900 Subject: [PATCH] =?UTF-8?q?DO-31=20Test:=20=EB=A0=8C=EC=A3=BC=EB=A3=B0=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Script/Game/GameLogic.cs | 49 ++++++++++++++++++- .../Renju/RenjuForbiddenMoveDetector.cs | 2 +- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/Assets/Script/Game/GameLogic.cs b/Assets/Script/Game/GameLogic.cs index ab4a325..8ff638f 100644 --- a/Assets/Script/Game/GameLogic.cs +++ b/Assets/Script/Game/GameLogic.cs @@ -13,7 +13,16 @@ public class GameLogic : MonoBehaviour //마지막 배치된 좌표 public int lastRow; public int lastCol; - + + #region Renju Members + // 렌주룰 금수 검사기 + private RenjuForbiddenMoveDetector _forbiddenDetector; + + // 현재 금수 위치 목록 + private List<(Vector2Int position, ForbiddenType type)> _forbiddenMoves = new List<(Vector2Int, ForbiddenType)>(); + + #endregion + public GameLogic(StoneController stoneController, Enums.GameType gameType) { //보드 초기화 @@ -23,7 +32,10 @@ public class GameLogic : MonoBehaviour selectedCol = -1; lastRow = -1; lastCol = -1; - + + // 금수 감지기 초기화 + _forbiddenDetector = new RenjuForbiddenMoveDetector(); + currentTurn = Enums.PlayerType.PlayerA; SetState(currentTurn); @@ -32,6 +44,10 @@ public class GameLogic : MonoBehaviour private void SetState(Enums.PlayerType player) { currentTurn = player; + + // 턴이 변경될 때마다 금수 위치 업데이트 + UpdateForbiddenMoves(); + _stoneController.OnStoneClickedDelegate = (row, col) => { if (_board[row, col] == Enums.PlayerType.None) @@ -93,4 +109,33 @@ public class GameLogic : MonoBehaviour { _stoneController.SetStoneState(state, row, col); } + + + #region Renju Rule Detector + + // 금수 위치 업데이트 및 표시 + private void UpdateForbiddenMoves() + { + // TODO: 이전 금수 표시 제거 + + + // 흑돌 차례에만 금수 규칙 적용 + if (currentTurn == Enums.PlayerType.PlayerA) + { + // 모든 금수의 위치 찾기 + _forbiddenMoves = _forbiddenDetector.FindAllForbiddenMoves(_board); + foreach (var forbiddenMove in _forbiddenMoves) + { + Vector2Int pos = forbiddenMove.position; + SetStoneNewState(Enums.StoneState.Blocked, pos.x, pos.y); + } + } + else + { + // 백돌 차례면 금수 목록 비우기 + _forbiddenMoves.Clear(); + } + } + + #endregion } diff --git a/Assets/Script/Renju/RenjuForbiddenMoveDetector.cs b/Assets/Script/Renju/RenjuForbiddenMoveDetector.cs index 557ed90..a764aa4 100644 --- a/Assets/Script/Renju/RenjuForbiddenMoveDetector.cs +++ b/Assets/Script/Renju/RenjuForbiddenMoveDetector.cs @@ -25,7 +25,7 @@ public class RenjuForbiddenMoveDetector } /// - /// 모든 금수 위치를 찾아 반환 + /// 모든 금수 위치를 찾아 반환하는 함수 /// /// 현재 보드 상태 /// 금수 위치 목록 (각 위치별 금수 타입 정보 포함)