This commit is contained in:
2022-01-29 10:07:53 -06:00
parent 499e480851
commit f79a1312c7
4 changed files with 190 additions and 161 deletions

View File

@@ -39,11 +39,11 @@ namespace Shogi.Domain
}
/// <summary>
/// Move a piece from a board tile to another board tile.
/// Move a piece from a board tile to another board tile ignorant of check or check-mate.
/// </summary>
/// <param name="fromNotation">The position of the piece being moved expressed in board notation.</param>
/// <param name="toNotation">The target position expressed in board notation.</param>
/// <returns>A <see cref="MoveResult" /> describing the success or failure of the simulation.</returns>
/// <returns>A <see cref="MoveResult" /> describing the success or failure of the move.</returns>
public MoveResult Move(string fromNotation, string toNotation, bool isPromotion = false)
{
var from = ShogiBoardState.FromBoardNotation(fromNotation);
@@ -105,7 +105,7 @@ namespace Shogi.Domain
}
/// <summary>
/// Move a piece from the hand to the board.
/// Move a piece from the hand to the board ignorant if check or check-mate.
/// </summary>
/// <param name="pieceInHand"></param>
/// <param name="to">The target position expressed in board notation.</param>
@@ -184,7 +184,7 @@ namespace Shogi.Domain
return isCheck;
}
public bool EvaluateCheckAfterMove(Vector2 from, Vector2 to, WhichPlayer whichPlayer)
public bool IsPlayerInCheckAfterMove(Vector2 from, Vector2 to, WhichPlayer whichPlayer)
{
if (whichPlayer == board.InCheck) return true; // If we already know the player is in check, don't bother.
@@ -265,7 +265,7 @@ namespace Shogi.Domain
var simulationResult = simulationBoard.Move(fromNotation, toNotation, false);
if (simulationResult.Success)
{
if (!EvaluateCheckAfterMove(from, position, board.InCheck.Value))
if (!IsPlayerInCheckAfterMove(from, position, board.InCheck.Value))
{
isCheckmate = false;
}