public void BishopShouldBeIncorrectMove() { ChessFigure figure = ChessFigure.ConstructByType(FigureType.BISHOP, "C1"); Assert.AreEqual(false, figure.Move("C3")); }
public void RookShouldBeIncorrectMove() { ChessFigure figure = ChessFigure.ConstructByType(FigureType.ROOK, "E2"); Assert.AreEqual(false, figure.Move("C5")); }
public void KnightShouldBeIncorrectMove() { ChessFigure figure = ChessFigure.ConstructByType(FigureType.KNIGHT, "B1"); Assert.AreEqual(false, figure.Move("C5")); }
public void QueenShouldBeIncorrectMove() { ChessFigure figure = ChessFigure.ConstructByType(FigureType.QUEEN, "D1"); Assert.AreEqual(false, figure.Move("E3")); }
public void FigureMoveToInvalidCoord(string coord) { ChessFigure figure = ChessFigure.ConstructByType(FigureType.ROOK, "E2"); Assert.Throws <ArgumentOutOfRangeException>(() => figure.Move(coord)); }
public void KingShouldBeIncorrectMove() { ChessFigure figure = new ChessFigure(ChessFigure.Type.KING, "E1"); Assert.AreEqual(false, figure.Move("E8")); }
public void QueenShouldBeCorrectMoveDiagonal() { ChessFigure figure = ChessFigure.ConstructByType(FigureType.QUEEN, "D1"); Assert.AreEqual(true, figure.Move("H5")); }
public void PawnShouldBeIncorrectMove() { ChessFigure figure = new ChessFigure(ChessFigure.Type.PAWN, "E2"); Assert.AreEqual(false, figure.Move("C5")); }
public void KingShouldBeCorrectMove() { ChessFigure figure = new ChessFigure(ChessFigure.Type.KING, "E1"); Assert.AreEqual(true, figure.Move("E2")); }
public void BishopShouldBeIncorrectMove() { ChessFigure figure = new ChessFigure(ChessFigure.Type.BISHOP, "C1"); Assert.AreEqual(false, figure.Move("C3")); }
public void PawnShouldBeCorrectMove2() { ChessFigure figure = new ChessFigure(ChessFigure.Type.PAWN, "E4"); Assert.AreEqual(true, figure.Move("E5")); }
public void KnightShouldBeIncorrectMove() { ChessFigure figure = new ChessFigure(ChessFigure.Type.KNIGHT, "B1"); Assert.AreEqual(false, figure.Move("C5")); }
public void QueenShouldBeIncorrectMove() { ChessFigure figure = new ChessFigure(ChessFigure.Type.QUEEN, "D1"); Assert.AreEqual(false, figure.Move("E3")); }
public void QueenShouldBeCorrectMoveDiagonal() { ChessFigure figure = new ChessFigure(ChessFigure.Type.QUEEN, "D1"); Assert.AreEqual(true, figure.Move("H5")); }
public void PawnShouldBeCorrectMove1() { ChessFigure figure = ChessFigure.ConstructByType(FigureType.PAWN, "E2"); Assert.AreEqual(true, figure.Move("E4")); }
public void KingShouldBeIncorrectMove() { ChessFigure figure = ChessFigure.ConstructByType(FigureType.KING, "E1"); Assert.AreEqual(false, figure.Move("E8")); }
private void buttonMove_Click(object sender, EventArgs e) { ChessFigure figureToMove = GetFigure(); if (figureToMove == null) { if (comboFrom.Text.Contains("Give In")) { MessageBox.Show("You lose!"); GameBegins(); return; } if (comboFrom.Text.Contains("Draw")) { DialogResult result = MessageBox.Show("Other player, do you want to draw?", "Draw proposal", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { MessageBox.Show("Draw!"); GameBegins(); } return; } ChessKing king = Game.CurrentPlayer.Figures.OfType <ChessKing>().First(); List <ChessRook> rooks = Game.CurrentPlayer.Figures.OfType <ChessRook>().ToList(); ChessRook rook = null; if (comboFrom.Text == "Long Roque") { rook = rooks.First(r => r.CurrentField.Column == 'A'); } if (comboFrom.Text == "Short Roque") { rook = rooks.First(r => r.CurrentField.Column == 'H'); } if (rook == null) { return; } rook.MakeRoque(Game.Board, king, Game.CurrentMoveNumber); } else { char[] columnAndRow = comboTo.Text.ToCharArray(); ChessField field = Game.Board.GetField(int.Parse(columnAndRow[1].ToString()), columnAndRow[0]); ChessPlayer enemy = Game.CurrentPlayer.Color == ChessColor.WHITE ? Game.BlackPlayer : Game.WhitePlayer; figureToMove.Move(field, enemy, Game.Board, Game.CurrentMoveNumber, Game.CurrentPlayer.Figures); } bool check = Check(); bool mate = CheckMate(); Game.ChangePlayer(); DrawFigures(); PrepareFigures(); if (mate) { MessageBox.Show("MATE!"); GameBegins(); } else if (check) { MessageBox.Show("CHECK!"); } }
public void RookShouldBeCorrectMove() { ChessFigure figure = new ChessFigure(ChessFigure.Type.ROOK, "E2"); Assert.AreEqual(true, figure.Move("C2")); }