Skip to content

Commit

Permalink
Fix castling rule
Browse files Browse the repository at this point in the history
  • Loading branch information
rchastain committed Feb 11, 2020
1 parent 78e197e commit e8698b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion source/eschecs.pas
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ procedure TMainForm.OnMoveDone(const AHistory: string; const ASound: boolean);
if (AHistory <> '') and not FChess960 then
begin
FOpeningName := GetOpening(AHistory);
WindowTitle := FOpeningName;
//WindowTitle := FOpeningName;
end;
FWaitingForUserMove := not (FGame.state in [csCheckmate, csStalemate, csDraw]);
end;
Expand Down
14 changes: 7 additions & 7 deletions source/position.pas
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,16 @@ function TChessPosition.IsCheck(const AColor: TPieceColorStrict): boolean;

function TChessPosition.IsCastlingCheck(const ACastling: TCastling): boolean;
var
x, y, dx: integer;
x, y, dx, xdest: integer;
c: TPieceColorStrict;
x1, x2, y1, y2: integer;
i: integer;
begin
case ACastling of
caWH: begin y := 1; dx := -1; c := pcWhite; end;
caWA: begin y := 1; dx := 1; c := pcWhite; end;
caBH: begin y := 8; dx := -1; c := pcBlack; end;
caBA: begin y := 8; dx := 1; c := pcBlack; end;
caWH: begin y := 1; dx := -1; xdest := 7; c := pcWhite; end;
caWA: begin y := 1; dx := 1; xdest := 3; c := pcWhite; end;
caBH: begin y := 8; dx := -1; xdest := 7; c := pcBlack; end;
caBA: begin y := 8; dx := 1; xdest := 3; c := pcBlack; end;
end;
x := FData.FCastling[ACastling];
repeat
Expand All @@ -298,8 +298,8 @@ function TChessPosition.IsCastlingCheck(const ACastling: TCastling): boolean;
begin
StrToMove(FList[i], x1, y1, x2, y2);
if (y2 = y)
and (x2 > Min(x, FData.FCastling[ACastling]))
and (x2 < Max(x, FData.FCastling[ACastling])) then
and (x2 >= Min(x, {FData.FCastling[ACastling]}xdest))
and (x2 <= Max(x, {FData.FCastling[ACastling]}xdest)) then
result := TRUE
else
Inc(i);
Expand Down
2 changes: 1 addition & 1 deletion source/version.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

const
CVersion = '5.0.5';
CVersion = '5.0.6';
CDefaultTitle = 'Eschecs';
{$IF DEFINED(CPU64) AND DEFINED(WINDOWS)}
COsType = 'win64';
Expand Down

0 comments on commit e8698b3

Please sign in to comment.