This commit is contained in:
2021-12-29 16:27:43 -06:00
parent a2f3abb94e
commit 9ec91615a3
5 changed files with 157 additions and 102 deletions

View File

@@ -31,25 +31,21 @@
public MoveResult CanMove(string from, string to, bool isPromotion)
{
// TODO: ShogiBoardState.FromBoardNotation should not throw an execption in this query method.
var fromVector = ShogiBoardState.FromBoardNotation(from);
var toVector = ShogiBoardState.FromBoardNotation(to);
var simulator = new StandardRules(new ShogiBoardState(board));
return simulator.Move(fromVector, toVector, isPromotion);
return simulator.Move(from, to, isPromotion);
}
public MoveResult CanMove(WhichPiece pieceInHand, string to)
{
var toVector = ShogiBoardState.FromBoardNotation(to);
var simulator = new StandardRules(new ShogiBoardState(board));
return simulator.Move(pieceInHand, toVector);
return simulator.Move(pieceInHand, to);
}
public void Move(string from, string to, bool isPromotion)
{
var fromVector = ShogiBoardState.FromBoardNotation(from);
var toVector = ShogiBoardState.FromBoardNotation(to);
var moveResult = rules.Move(fromVector, toVector, isPromotion);
var moveResult = rules.Move(from, to, isPromotion);
if (!moveResult.Success)
{
throw new InvalidOperationException(moveResult.Reason);