DO-31 Style: 변수 이름 일관적으로 수정, 코드 및 주석 정리

This commit is contained in:
fiore 2025-03-18 20:35:12 +09:00
parent aaa280341d
commit 9aef630eb0
4 changed files with 14 additions and 25 deletions

View File

@ -24,15 +24,15 @@
private protected readonly int[,] DirectionPairs = { { 0, 4 }, { 1, 5 }, { 2, 6 }, { 3, 7 } }; private protected readonly int[,] DirectionPairs = { { 0, 4 }, { 1, 5 }, { 2, 6 }, { 3, 7 } };
// 15*15 보드 사이즈 // 15*15 보드 사이즈
private protected int _boardSize = Constants.BoardSize; private protected int BoardSize = Constants.BoardSize;
/// <summary> /// <summary>
/// 좌표가 보드 범위 내에 있는지 확인 /// 좌표가 보드 범위 내에 있는지 확인
/// </summary> /// </summary>
private protected bool IsInBounds(int row, int col) private protected bool IsInBounds(int row, int col)
{ {
var inBoardSizeRow = row >= 0 && row < _boardSize; var inBoardSizeRow = row >= 0 && row < BoardSize;
var inBoardSizeCol = col >= 0 && col < _boardSize; var inBoardSizeCol = col >= 0 && col < BoardSize;
return inBoardSizeRow && inBoardSizeCol; return inBoardSizeRow && inBoardSizeCol;
} }
@ -44,6 +44,6 @@
{ {
if (!IsInBounds(row, col)) return false; if (!IsInBounds(row, col)) return false;
return board[row, col] == Enums.PlayerType.None; return board[row, col] == Space;
} }
} }

View File

@ -1,21 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
/// <summary>
/// 렌주 규칙의 모든 금수 규칙(3-3, 4-4, 장목)을 검사하는 통합 클래스
/// </summary>
public class RenjuForbiddenMoveDetector public class RenjuForbiddenMoveDetector
{ {
private RenjuRuleChecker _ruleChecker; // 렌주 룰 금수 감지기 생성
private RenjuRuleChecker _ruleChecker = new RenjuRuleChecker();
/// <summary>
/// 렌주 금수 감지기 생성자
/// </summary>
public RenjuForbiddenMoveDetector()
{
// 감지기 초기화
_ruleChecker = new RenjuRuleChecker();
}
/// <summary> /// <summary>
/// 렌주 룰로 금수 리스트를 반환하는 함수 /// 렌주 룰로 금수 리스트를 반환하는 함수
@ -24,9 +14,6 @@ public class RenjuForbiddenMoveDetector
/// <returns>금수 좌표를 담은 리스트</returns> /// <returns>금수 좌표를 담은 리스트</returns>
public List<Vector2Int> RenjuForbiddenMove(Enums.PlayerType[,] board) public List<Vector2Int> RenjuForbiddenMove(Enums.PlayerType[,] board)
{ {
var doubleThreeList = _ruleChecker.GetForbiddenMoves(board); return _ruleChecker.GetForbiddenMoves(board);
return doubleThreeList;
} }
} }

View File

@ -74,7 +74,6 @@
/// <param name="startRow">시작 행</param> /// <param name="startRow">시작 행</param>
/// <param name="startCol">시작 열</param> /// <param name="startCol">시작 열</param>
/// <param name="dirIndex">방향 인덱스</param> /// <param name="dirIndex">방향 인덱스</param>
/// <param name="playerType">검사할 플레이어 타입</param>
/// <returns>해당 방향의 연속된 돌 개수</returns> /// <returns>해당 방향의 연속된 돌 개수</returns>
private int CountInDirection(Enums.PlayerType[,] board, int startRow, int startCol, int dirIndex) private int CountInDirection(Enums.PlayerType[,] board, int startRow, int startCol, int dirIndex)
{ {
@ -82,7 +81,7 @@
int dRow = Directions[dirIndex, 0]; int dRow = Directions[dirIndex, 0];
int dCol = Directions[dirIndex, 1]; int dCol = Directions[dirIndex, 1];
for (int i = 1; i < _boardSize; i++) for (int i = 1; i < BoardSize; i++)
{ {
int newRow = startRow + dRow * i; int newRow = startRow + dRow * i;
int newCol = startCol + dCol * i; int newCol = startCol + dCol * i;

View File

@ -1,6 +1,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
/// <summary>
/// 렌주 규칙의 모든 금수 규칙(3-3, 4-4, 장목)을 검사하는 통합 클래스
/// </summary>
public class RenjuRuleChecker: ForbiddenDetectorBase public class RenjuRuleChecker: ForbiddenDetectorBase
{ {
private RenjuOverlineDetector _overlineDetactor = new(); private RenjuOverlineDetector _overlineDetactor = new();
@ -10,9 +13,9 @@ public class RenjuRuleChecker: ForbiddenDetectorBase
public List<Vector2Int> GetForbiddenMoves(Enums.PlayerType[,] board) public List<Vector2Int> GetForbiddenMoves(Enums.PlayerType[,] board)
{ {
List<Vector2Int> forbiddenMoves = new(); List<Vector2Int> forbiddenMoves = new();
for (int row = 0; row < _boardSize; row++) for (int row = 0; row < BoardSize; row++)
{ {
for (int col = 0; col < _boardSize; col++) for (int col = 0; col < BoardSize; col++)
{ {
// ** 비어 있지 않으면 검사할 필요 없음 ** // ** 비어 있지 않으면 검사할 필요 없음 **
if (!IsEmptyPosition(board, row, col)) continue; if (!IsEmptyPosition(board, row, col)) continue;