public void DoCastling(Point startSquare, Point endSquare) { Figures figure = GetFigures(startSquare.X, startSquare.Y); if (endSquare.Y == 2) { MoveFigure(startSquare, endSquare); (figure as King).Moved = true; (GetFigures(endSquare.X, 0) as Rook).Moved = true; MoveFigure(new Point(endSquare.X, 0), new Point(endSquare.X, 3)); RemoveEnPassant(figure); } if (endSquare.Y == 6) { MoveFigure(startSquare, endSquare); (figure as King).Moved = true; (GetFigures(endSquare.X, 7) as Rook).Moved = true; MoveFigure(new Point(endSquare.X, 7), new Point(endSquare.X, 5)); RemoveEnPassant(figure); } }
public void MoveFigure(Point startP, Point endP) { Figures fig = GetFigures(startP.X, startP.Y); figures[startP.X, startP.Y] = null; figures[endP.X, endP.Y] = fig; form.MoveFigure(startP, endP); }
public void RemoveEnPassant(Figures figures) { if (figures.IsWhite) { LPawnEnPassant = null; } else { DPawnEnPassant = null; } }
public void AddEnPassant(Figures figures) { if (figures.IsWhite) { LPawnEnPassant = figures; } else { DPawnEnPassant = figures; } }
public void DoEnPassant(Point startSquare, Point endSquare) { Figures figure = GetFigures(startSquare.X, startSquare.Y); if (figure.IsWhite) { MoveFigure(new Point(endSquare.X + 1, endSquare.Y), new Point(endSquare.X, endSquare.Y)); MoveFigure(startSquare, endSquare); RemoveEnPassant(figure); } else { MoveFigure(new Point(endSquare.X - 1, endSquare.Y), new Point(endSquare.X, endSquare.Y)); MoveFigure(startSquare, endSquare); RemoveEnPassant(figure); } }
public bool MakeMove(Point startSquare, Point endSquare) { Figures figure = figures[startSquare.X, startSquare.Y]; if (figure.Moves.Contains(endSquare)) { figure.Move(this, startSquare, endSquare); if (figure.Type == FigureTypes.Rook) { (figure as Rook).Moved = true; } if (figure.Type == FigureTypes.King) { (figure as King).Moved = true; } if (figure.Type == FigureTypes.Pawn && Math.Abs(startSquare.X - endSquare.X) == 2) { AddEnPassant(figure); } else { RemoveEnPassant(figure); } if (figure.Type == FigureTypes.Pawn && endSquare.X % 7 == 0) { form.RemovePosibleMoves(figure.Moves); Figures f = CreateFigure(form.ChooseReplacement(), figure.IsWhite); figures[endSquare.X, endSquare.Y] = f; form.SetImage(endSquare.X, endSquare.Y, f); } return(true); } return(false); }
public void SetFigure(Figures figure, Point position) { figures[position.X, position.Y] = figure; form.SetImage(position.X, position.Y, figure); }