From a418cb1a3e89c5c78bc11ec885b9b67c99723266 Mon Sep 17 00:00:00 2001 From: Lim0_C Date: Wed, 19 Mar 2025 17:49:34 +0900 Subject: [PATCH] =?UTF-8?q?DO-41=20[Feat]=20=EB=AC=B4=EC=8A=B9=EB=B6=80=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 빈칸이 없이 채우면 무승부 --- Assets/Script/Game/GameLogic.cs | 35 ++++++++++++++++++++++++++++++- Assets/Script/Game/GameManager.cs | 8 +++---- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/Assets/Script/Game/GameLogic.cs b/Assets/Script/Game/GameLogic.cs index 94c54f0..764c7c5 100644 --- a/Assets/Script/Game/GameLogic.cs +++ b/Assets/Script/Game/GameLogic.cs @@ -25,7 +25,15 @@ public abstract class BasePlayerState else { //TODO: 무승부 확인 - HandleNextTurn(gameLogic); + if (gameLogic.CheckGameDraw(gameLogic.GetBoard())) + { + GameManager.Instance.panelManager.OpenConfirmPanel($"Game Over: Draw",() =>{}); + gameLogic.EndGame(); + } + else + { + HandleNextTurn(gameLogic); + } } } @@ -376,6 +384,31 @@ public class GameLogic : MonoBehaviour return (count, openEnds); } + public Enums.PlayerType[,] GetBoard() + { + return _board; + } + + public bool CheckGameDraw(Enums.PlayerType[,] board) + { + List<(int, int)> validMoves = new List<(int, int)>(); + int size = board.GetLength(0); + for (int row = 0; row < size; row++) + { + for (int col = 0; col < size; col++) + { + if (board[row, col] == Enums.PlayerType.None) + { + validMoves.Add((row, col)); + } + } + } + + if (validMoves.Count == 0) return true; + + return false; + } + #region Renju Rule Detector // 금수 위치 업데이트 및 표시 private void UpdateForbiddenMoves() diff --git a/Assets/Script/Game/GameManager.cs b/Assets/Script/Game/GameManager.cs index 628fb66..c6ec223 100644 --- a/Assets/Script/Game/GameManager.cs +++ b/Assets/Script/Game/GameManager.cs @@ -31,10 +31,10 @@ public class GameManager : Singleton //게임 씬에서 확인하기 위한 임시 코드 // _canvas = canvas.GetComponent(); - // _stoneController = GameObject.FindObjectOfType(); - // _stoneController.InitStones(); - // var fioTimer = FindObjectOfType(); - // _gameLogic = new GameLogic(_stoneController, _gameType, fioTimer); + _stoneController = GameObject.FindObjectOfType(); + _stoneController.InitStones(); + var fioTimer = FindObjectOfType(); + _gameLogic = new GameLogic(_stoneController, _gameType, fioTimer); } private void InitPanels()