protected bool CanMoveAndCapture(int X, int Y) { if (!ChessPlayingField.CheckRanges(X, Y)) { return(false); } return(CurPlField.CheckEmpty(Y, X) || !IsSameColourAs(CurPlField[Y, X])); }
protected bool CanCapture(int Y, int X) { return(ChessPlayingField.CheckRanges(Y, X) && !CurPlField.CheckEmpty(Y, X) && !IsSameColourAs(CurPlField[Y, X])); }
protected bool CanMove(int X, int Y) { return(ChessPlayingField.CheckRanges(Y, X) && CurPlField.CheckEmpty(Y, X)); }
public override void CalculateAvailableMoves(int Y, int X) { var result = new List <ChessMove>(); for (int i = X - 1; i >= 0; i--) { if (CurPlField.CheckEmpty(Y, i)) { result.Add(new ChessMove(X, Y, i, Y)); } else { if (!IsSameColourAs(CurPlField[Y, i])) { result.Add(new ChessMove(X, Y, i, Y)); } break; } } for (int i = X + 1; i <= 7; i++) { if (CurPlField.CheckEmpty(Y, i)) { result.Add(new ChessMove(X, Y, i, Y)); } else { if (!IsSameColourAs(CurPlField[Y, i])) { result.Add(new ChessMove(X, Y, i, Y)); } break; } } for (int i = Y - 1; i >= 0; i--) { if (CurPlField.CheckEmpty(i, X)) { result.Add(new ChessMove(X, Y, X, i)); } else { if (!IsSameColourAs(CurPlField[i, X])) { result.Add(new ChessMove(X, Y, X, i)); } break; } } for (int i = Y + 1; i <= 7; i++) { if (CurPlField.CheckEmpty(i, X)) { result.Add(new ChessMove(X, Y, X, i)); } else { if (!IsSameColourAs(CurPlField[i, X])) { result.Add(new ChessMove(X, Y, X, i)); } break; } } for (int i = 1; (X - i >= 0) && (Y - i >= 0); i++) { if (CurPlField.CheckEmpty(Y - i, X - i)) { result.Add(new ChessMove(X, Y, X - i, Y - i)); } else { if (!IsSameColourAs(CurPlField[Y - i, X - i])) { result.Add(new ChessMove(X, Y, X - i, Y - i)); } break; } } for (int i = 1; (X + i <= 7) && (Y + i <= 7); i++) { if (CurPlField.CheckEmpty(Y + i, X + i)) { result.Add(new ChessMove(X, Y, X + i, Y + i)); } else { if (!IsSameColourAs(CurPlField[Y + i, X + i])) { result.Add(new ChessMove(X, Y, X + i, Y + i)); } break; } } for (int i = 1; (X + i <= 7) && (Y - i >= 0); i++) { if (CurPlField.CheckEmpty(Y - i, X + i)) { result.Add(new ChessMove(X, Y, X + i, Y - i)); } else { if (!IsSameColourAs(CurPlField[Y - i, X + i])) { result.Add(new ChessMove(X, Y, X + i, Y - i)); } break; } } for (int i = 1; (X - i >= 0) && (Y + i <= 7); i++) { if (CurPlField.CheckEmpty(Y + i, X - i)) { result.Add(new ChessMove(X, Y, X - i, Y + i)); } else { if (!IsSameColourAs(CurPlField[Y + i, X - i])) { result.Add(new ChessMove(X, Y, X - i, Y + i)); } break; } } AvailableMoves = result; }