public void Move(Cell src, Cell dst) { Console.WriteLine($"move from {src} to {dst}"); //get piece var piece = Board.ContainsKey(src) ? Board[src] : null; if (piece == null) { Console.WriteLine($"no piece at {src}"); } else { //is move valid? var validationOutput = MoveValidator.IsMoveValid(ActivePlayer, piece, src, dst, Board); if (!validationOutput.Valid) { Console.WriteLine($"piece at {src} cannot move to {dst}, {validationOutput.InvalidMessage}"); } else { //execute move MoveExecutor.ExecuteMove(validationOutput, piece, src, dst, Board, Captured); //toggle player ActivePlayer = ActivePlayer == EPlayer.White ? EPlayer.Black : EPlayer.White; if (Captured.Count(x => x.Player == EPlayer.White && x is King) == 1) { Winner = EPlayer.Black; } else if (Captured.Count(x => x.Player == EPlayer.White && x is King) == 1) { Winner = EPlayer.White; } } } BoardPresenter.Print(Board); }
public void Test1() { var moveValidator = new MoveValidator(); Assert.True(moveValidator.IsMoveValid()); }