yep
This commit is contained in:
@@ -43,16 +43,24 @@
|
||||
|
||||
public void Move(string from, string to, bool isPromotion)
|
||||
{
|
||||
var fromVector = ShogiBoardState.FromBoardNotation(from);
|
||||
var toVector = ShogiBoardState.FromBoardNotation(to);
|
||||
var moveResult = rules.Move(from, to, isPromotion);
|
||||
var tempBoard = new ShogiBoardState(board);
|
||||
var simulation = new StandardRules(tempBoard);
|
||||
var moveResult = simulation.Move(from, to, isPromotion);
|
||||
if (!moveResult.Success)
|
||||
{
|
||||
throw new InvalidOperationException(moveResult.Reason);
|
||||
}
|
||||
|
||||
var fromVector = ShogiBoardState.FromBoardNotation(from);
|
||||
var toVector = ShogiBoardState.FromBoardNotation(to);
|
||||
var otherPlayer = board.WhoseTurn == WhichPlayer.Player1 ? WhichPlayer.Player2 : WhichPlayer.Player1;
|
||||
if (rules.EvaluateCheckAfterMove(fromVector, toVector, otherPlayer))
|
||||
if (simulation.IsPlayerInCheckAfterMove(fromVector, toVector, board.WhoseTurn))
|
||||
{
|
||||
throw new InvalidOperationException("Illegal move. This move places you in check.");
|
||||
}
|
||||
|
||||
rules.Move(from, to, isPromotion);
|
||||
if (rules.IsPlayerInCheckAfterMove(fromVector, toVector, otherPlayer))
|
||||
{
|
||||
board.InCheck = otherPlayer;
|
||||
board.IsCheckmate = rules.EvaluateCheckmate();
|
||||
@@ -64,6 +72,10 @@
|
||||
board.WhoseTurn = otherPlayer;
|
||||
}
|
||||
|
||||
public void Move(WhichPiece pieceInHand, string to)
|
||||
{
|
||||
|
||||
}
|
||||
///// <summary>
|
||||
///// Attempts a given move. Returns false if the move is illegal.
|
||||
///// </summary>
|
||||
|
||||
Reference in New Issue
Block a user