DO-31 Refactor: 중복되는 클래스 통합
- RenjuRuleChecker.cs 삭제 - RenjuForbiddenMoveDetector.cs로 통합
This commit is contained in:
parent
5695f2c95d
commit
ed9e8664a8
@ -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();
|
||||
|
||||
/// <summary>
|
||||
/// 렌주 룰로 금수 리스트를 반환하는 함수
|
||||
@ -15,6 +17,40 @@ public class RenjuForbiddenMoveDetector
|
||||
public List<Vector2Int> RenjuForbiddenMove(Enums.PlayerType[,] board)
|
||||
{
|
||||
var tempBoard = (Enums.PlayerType[,])board.Clone();
|
||||
return _ruleChecker.GetForbiddenMoves(tempBoard);
|
||||
|
||||
List<Vector2Int> 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;
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 렌주 규칙의 모든 금수 규칙(3-3, 4-4, 장목)을 검사하는 통합 클래스
|
||||
/// </summary>
|
||||
public class RenjuRuleChecker: ForbiddenDetectorBase
|
||||
{
|
||||
private RenjuOverlineDetector _overlineDetactor = new();
|
||||
private RenjuDoubleFourDetector _doubleFourDetactor = new();
|
||||
private RenjuDoubleThreeDetector _doubleThreeDetector = new();
|
||||
|
||||
public List<Vector2Int> GetForbiddenMoves(Enums.PlayerType[,] board)
|
||||
{
|
||||
List<Vector2Int> 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;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 083e8b9070ed407b8744d4cacd0d53dc
|
||||
timeCreated: 1742256498
|
Loading…
x
Reference in New Issue
Block a user