DO-41 [Feat] 무승부 코드 추가
빈칸이 없이 채우면 무승부
This commit is contained in:
parent
693246223f
commit
a418cb1a3e
@ -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()
|
||||
|
@ -31,10 +31,10 @@ public class GameManager : Singleton<GameManager>
|
||||
|
||||
//게임 씬에서 확인하기 위한 임시 코드
|
||||
// _canvas = canvas.GetComponent<Canvas>();
|
||||
// _stoneController = GameObject.FindObjectOfType<StoneController>();
|
||||
// _stoneController.InitStones();
|
||||
// var fioTimer = FindObjectOfType<FioTimer>();
|
||||
// _gameLogic = new GameLogic(_stoneController, _gameType, fioTimer);
|
||||
_stoneController = GameObject.FindObjectOfType<StoneController>();
|
||||
_stoneController.InitStones();
|
||||
var fioTimer = FindObjectOfType<FioTimer>();
|
||||
_gameLogic = new GameLogic(_stoneController, _gameType, fioTimer);
|
||||
}
|
||||
|
||||
private void InitPanels()
|
||||
|
Loading…
x
Reference in New Issue
Block a user