public ValidateChessPieceMoveRequest( ChessPieceKind chessPieceKind, ChessboardPositionDto currentPosition, ChessboardPositionDto targetPosition) { ChessPieceKind = chessPieceKind; CurrentPosition = currentPosition; TargetPosition = targetPosition; }
public static string ChessPieceKindToFEN(ChessPieceKind kind) { switch (kind) { case ChessPieceKind.None: return(""); case ChessPieceKind.Pawn: return("p"); case ChessPieceKind.Knight: return("n"); case ChessPieceKind.Bishop: return("b"); case ChessPieceKind.Rook: return("r"); case ChessPieceKind.Queen: return("q"); case ChessPieceKind.King: return("k"); } throw new ArgumentException($"Unable to translate {kind} into a FEN abbreviation."); }
public async Task <GetChessPiecePossibleMovesResponse> GetAvailableMoves( int currentX, int currentY, ChessPieceKind chessPieceKind) { var request = new GetChessPiecePossibleMovesRequest( new ChessboardPositionDto(currentX, currentY), chessPieceKind); return(await mediator.Send(request)); }
public ChessboardState TestPieceMoveValidation(ChessPieceKind chessPieceKind, ChessboardState initialState) { var currentPosition = initialState.GetCurrentPosition(); var request = new GetChessPiecePossibleMovesRequest(currentPosition, chessPieceKind); var result = HandleRequest(request); Assert.That(result.CurrentPosition, Is.EqualTo(currentPosition)); return(ChessboardState.CreateFromMoves(result.CurrentPosition, result.PossibleMoves)); }
public ValidateChessPieceMoveResponse TestPieceMoves( ChessPieceKind chessPieceKind, ChessboardState chessboardState) { var currentPosition = chessboardState.GetCurrentPosition(); var targetPosition = chessboardState.GetTargetPosition(); var request = new ValidateChessPieceMoveRequest(chessPieceKind, currentPosition, targetPosition); var result = HandleRequest(request); return(result); }
public void PutPiece_Should_PutThePieceOnTheBoard(ChessPieceKind kindOfPiece, ChessColor pieceColor, string square) { // Arrange SUT board = new SUT(); ChessPiece piece = new ChessPiece(kindOfPiece, pieceColor); // Act board.PutPiece(piece, new ChessSquare(square)); // Assert Assert.IsTrue(piece == board.GetPieceAt(new ChessSquare(square))); }
public void RemovePieceAt_Should_RemoveThePiece(string square, ChessPieceKind expectedPiece, ChessColor expectedColor) { // Arrange SUT board = new SUT(); ChessPiece actualPiece; // Act actualPiece = board.RemovePieceAt(new ChessSquare(square)); // Assert Assert.AreEqual(expectedPiece, actualPiece.Kind); Assert.AreEqual(expectedColor, actualPiece.Color); }
private Ellipse createChessPieceShape(ChessPieceKind kind) { var newShape = new Ellipse { Height = chessPieceSize, Width = chessPieceSize, Stroke = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)), Fill = kind == ChessPieceKind.BlackChessPiece ? blackChessBrush : writeChessBrush, Visibility = Visibility.Hidden }; chessboardCanvas.Children.Add(newShape); return(newShape); }
public bool PlaceChessPiece(int x, int y) { if (!CanPlaceChessPiece(x, y)) { throw new InvalidOperationException("非法落子"); } positions[x, y] = NextMoveKind; ChessPieceInfo chessPiece = new ChessPieceInfo { X = x, Y = y, Kind = NextMoveKind }; previousMove = chessPiece; bool isWin = calcResult(chessPiece); if (isWin) { Result = previousMove.Kind; } NextMoveKind = NextMoveKind == ChessPieceKind.BlackChessPiece ? ChessPieceKind.WriteChessPiece : ChessPieceKind.BlackChessPiece; OnChessPlaced(chessPiece, isWin); return(isWin); }
public void ChessPieceToFEN_Should_ReturnCorrectFENPiece(ChessPieceKind pieceKind, ChessColor pieceColor, string expectedFEN) { // Assert Assert.AreEqual(expectedFEN, SUT.ChessPieceToFEN(new ChessPiece(pieceKind, pieceColor))); }
private PieceMoveTestDataBuilder(ChessPieceKind chessPiece) { this.chessPiece = chessPiece; }
public static IInitialChessboardStateStep ForChessPiece(ChessPieceKind chessPiece) { return(new PieceMoveTestDataBuilder(chessPiece)); }
public static IValidatedMoveStep ForChessPiece(ChessPieceKind chessPiece) { return(new ValidateMoveTestDataBuilder(chessPiece)); }
public ChessPieceInfo(ChessPieceKind id, string label, string unicode) { this.Id = id; this.Label = label; this.Unicode = unicode; }
public Node(Position previousPlacedPosition, ChessPieceKind previousChessPieceKind) { PreviousPlacedPosition = previousPlacedPosition; PreviousChessPieceKind = previousChessPieceKind; }
private void PctBxKnight_Click(object sender, EventArgs e) { ChoosePiece = ChessPieceKind.Knight; DialogResult = DialogResult.OK; }
private void PctBxBishop_Click(object sender, EventArgs e) { ChoosePiece = ChessPieceKind.Bishop; DialogResult = DialogResult.OK; }
private void PctBxRook_Click(object sender, EventArgs e) { ChoosePiece = ChessPieceKind.Rook; DialogResult = DialogResult.OK; }
public ChessPiece(ChessPieceKind kind, ChessColor color) { this.Kind = kind; this.Color = color; }