You've already forked lazarus-ccr
fpchess: Patch from Brian Chalega da Silva, starts implementing move validation and fixes compilation with the latest Lazarus
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1549 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -5,7 +5,9 @@ unit chessgame;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, fpimage, dateutils;
|
Classes, SysUtils, fpimage, dateutils,
|
||||||
|
Forms, Controls, Graphics, Dialogs,
|
||||||
|
ExtCtrls, ComCtrls, StdCtrls, Buttons, Spin;
|
||||||
|
|
||||||
const
|
const
|
||||||
colA = 1;
|
colA = 1;
|
||||||
@ -25,6 +27,7 @@ const
|
|||||||
type
|
type
|
||||||
|
|
||||||
TPacketKind = (pkConnect, pkStartGameClientAsWhite, pkStartGameClientAsBlack, pkMove);
|
TPacketKind = (pkConnect, pkStartGameClientAsWhite, pkStartGameClientAsBlack, pkMove);
|
||||||
|
BitBoard = array[1..8] of array [1..8] of boolean;
|
||||||
|
|
||||||
{ TPacket }
|
{ TPacket }
|
||||||
|
|
||||||
@ -60,6 +63,7 @@ type
|
|||||||
TChessGame = class
|
TChessGame = class
|
||||||
public
|
public
|
||||||
Board: TChessBoard;
|
Board: TChessBoard;
|
||||||
|
msg : String;
|
||||||
CurrentPlayerIsWhite: Boolean;
|
CurrentPlayerIsWhite: Boolean;
|
||||||
Dragging: Boolean;
|
Dragging: Boolean;
|
||||||
DragStart, MouseMovePos: TPoint;
|
DragStart, MouseMovePos: TPoint;
|
||||||
@ -73,6 +77,13 @@ type
|
|||||||
function ClientToBoardCoords(AClientCoords: TPoint): TPoint;
|
function ClientToBoardCoords(AClientCoords: TPoint): TPoint;
|
||||||
function CheckStartMove(AFrom: TPoint): Boolean;
|
function CheckStartMove(AFrom: TPoint): Boolean;
|
||||||
function MovePiece(AFrom, ATo: TPoint): Boolean;
|
function MovePiece(AFrom, ATo: TPoint): Boolean;
|
||||||
|
function ValidateRookMove(AFrom, ATo: TPoint) : boolean;
|
||||||
|
function ValidateKnightMove(AFrom, ATo: TPoint) : boolean;
|
||||||
|
function ValidateBishopMove(AFrom, ATo: TPoint) : boolean;
|
||||||
|
function ValidateQueenMove(AFrom, ATo: TPoint) : boolean;
|
||||||
|
function ValidateKingMove(AFrom, ATo: TPoint) : boolean;
|
||||||
|
function ValidatePawnMove(AFrom, ATo: TPoint) : boolean;
|
||||||
|
|
||||||
procedure UpdateTimes();
|
procedure UpdateTimes();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -162,21 +173,671 @@ end;
|
|||||||
}
|
}
|
||||||
function TChessGame.MovePiece(AFrom, ATo: TPoint): Boolean;
|
function TChessGame.MovePiece(AFrom, ATo: TPoint): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
result := false;
|
||||||
|
//AFrom.x:=AFrom.x;
|
||||||
|
//AFrom.y:=AFrom.y+2;
|
||||||
|
//if not CheckStartMove(AFrom) then Exit;
|
||||||
|
|
||||||
if not CheckStartMove(AFrom) then Exit;
|
if ( (Board[AFrom.X][AFrom.Y]) in WhitePieces ) then begin
|
||||||
|
if Board[AFrom.X][AFrom.Y] = ctWRook then result:=(ValidateRookMove(AFrom,ATo));;
|
||||||
|
if Board[AFrom.X][AFrom.Y] = ctWKnight then result :=(ValidateKnightMove(AFrom,ATo));
|
||||||
|
if Board[AFrom.X][AFrom.Y] = ctWBishop then result :=(ValidateBishopMove(AFrom,ATo));
|
||||||
|
if Board[AFrom.X][AFrom.Y] = ctWQueen then result :=(ValidateQueenMove(AFrom,ATo));
|
||||||
|
if Board[AFrom.X][AFrom.Y] = ctWKing then result :=(ValidateKingMove(AFrom,ATo));
|
||||||
|
if Board[AFrom.X][AFrom.Y] = ctWPawn then result :=(ValidatePawnMove(AFrom,ATo));
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
if Board[AFrom.X][AFrom.Y] = ctBRook then result :=(ValidateRookMove(AFrom,ATo));
|
||||||
|
if Board[AFrom.X][AFrom.Y] = ctBKnight then result :=(ValidateKnightMove(AFrom,ATo));
|
||||||
|
if Board[AFrom.X][AFrom.Y] = ctBBishop then result :=(ValidateBishopMove(AFrom,ATo));
|
||||||
|
if Board[AFrom.X][AFrom.Y] = ctBQueen then result :=(ValidateQueenMove(AFrom,ATo));
|
||||||
|
if Board[AFrom.X][AFrom.Y] = ctBKing then result :=(ValidateKingMove(AFrom,ATo));
|
||||||
|
if Board[AFrom.X][AFrom.Y] = ctBPawn then result :=(ValidatePawnMove(AFrom,ATo));
|
||||||
|
end;
|
||||||
|
// ShowMessage('Resultado := ' + BoolToStr(result,true));
|
||||||
|
if (result) then begin
|
||||||
|
// col, row
|
||||||
|
Board[ATo.X][ATo.Y] := Board[AFrom.X][AFrom.Y];
|
||||||
|
Board[AFrom.X][AFrom.Y] := ctEmpty;
|
||||||
|
|
||||||
// Parameter checking
|
UpdateTimes();
|
||||||
if (AFrom.X < 1) or (AFrom.X > 8) or (ATo.X < 1) or (ATo.X > 8) then Exit;
|
CurrentPlayerIsWhite := not CurrentPlayerIsWhite;
|
||||||
if (AFrom.Y < 1) or (AFrom.Y > 8) or (ATo.Y < 1) or (ATo.Y > 8) then Exit;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
// col, row
|
//return true if the move of a Rook is valid.
|
||||||
Board[ATo.X][ATo.Y] := Board[AFrom.X][AFrom.Y];
|
function TChessGame.ValidateRookMove(AFrom, ATo: TPoint): boolean;
|
||||||
Board[AFrom.X][AFrom.Y] := ctEmpty;
|
var AttackedSquares : BitBoard;
|
||||||
|
i,j : Integer;
|
||||||
|
l : integer = 0;
|
||||||
|
haveCaptured: boolean = false; //already have captured a piece
|
||||||
|
willBeACapture : boolean = false;// the movement will be a capture
|
||||||
|
validMove : boolean = false; //if the piece in the 'to' square is not of the same color of the player
|
||||||
|
// mensagem : String;
|
||||||
|
begin
|
||||||
|
|
||||||
UpdateTimes();
|
for i:=1 to 8 do // initialize the bitboard of attacked pieces.
|
||||||
CurrentPlayerIsWhite := not CurrentPlayerIsWhite;
|
for j:=1 to 8 do
|
||||||
|
AttackedSquares[i][j]:= false;
|
||||||
|
// ShowMessage('vai passar pelo up');
|
||||||
|
|
||||||
|
//////////////////////////////////////UP////////////////////////////////////////
|
||||||
|
l := AFrom.y+1;
|
||||||
|
if (l<=8) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[AFrom.x][l] in BlackPieces);
|
||||||
|
validMove:= not (Board[AFrom.x][l] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[AFrom.x][l] in WhitePieces);
|
||||||
|
validMove:=not (Board[AFrom.x][l] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
l :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (l <= 8) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[AFrom.x][l] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
l := l+1;
|
||||||
|
if (l<=8) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[AFrom.x][l] in BlackPieces);
|
||||||
|
validMove:= not (Board[AFrom.x][l] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[AFrom.x][l] in WhitePieces);
|
||||||
|
validMove:=not (Board[AFrom.x][l] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END UP///////////////////////////////////////
|
||||||
|
///////////////////////////////////DOWN/////////////////////////////////////////
|
||||||
|
haveCaptured:=false;
|
||||||
|
l := AFrom.y-1;
|
||||||
|
if (l>=1) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[AFrom.x][l] in BlackPieces);
|
||||||
|
validMove:= not (Board[AFrom.x][l] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[AFrom.x][l] in WhitePieces);
|
||||||
|
validMove:=not (Board[AFrom.x][l] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
l :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (l >= 1) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[AFrom.x][l] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
l := l-1;
|
||||||
|
if (l>=1) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[AFrom.x][l] in BlackPieces);
|
||||||
|
validMove:= not (Board[AFrom.x][l] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[AFrom.x][l] in WhitePieces);
|
||||||
|
validMove:=not (Board[AFrom.x][l] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END DOWN/////////////////////////////////////
|
||||||
|
////////////////////////////////////RIGHT////////////////////////////////////////
|
||||||
|
haveCaptured:=false;
|
||||||
|
l := AFrom.x+1;
|
||||||
|
if (l<=8) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[l][AFrom.y] in BlackPieces);
|
||||||
|
validMove:= not (Board[l][AFrom.y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[l][AFrom.y] in WhitePieces);
|
||||||
|
validMove:=not (Board[l][AFrom.y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
l :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (l <= 8) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[l][AFrom.y] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
l := l+1;
|
||||||
|
if (l<=8) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[l][AFrom.y] in BlackPieces);
|
||||||
|
validMove:= not (Board[l][AFrom.y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[l][AFrom.y] in WhitePieces);
|
||||||
|
validMove:=not (Board[l][AFrom.y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END RIGHT////////////////////////////////////
|
||||||
|
///////////////////////////////////LEFT/////////////////////////////////////////
|
||||||
|
haveCaptured:=false;
|
||||||
|
l := AFrom.x-1;
|
||||||
|
if (l>=1) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[l][AFrom.y] in BlackPieces);
|
||||||
|
validMove:= not (Board[l][AFrom.y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[l][AFrom.y] in WhitePieces);
|
||||||
|
validMove:=not (Board[l][AFrom.y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
l :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (l >= 1) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[l][AFrom.y] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
l := l-1;
|
||||||
|
if (l>=1) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[l][AFrom.y] in BlackPieces);
|
||||||
|
validMove:= not (Board[l][AFrom.y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[l][AFrom.y] in WhitePieces);
|
||||||
|
validMove:=not (Board[l][AFrom.y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END LEFT/////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
{ for i:=1 to 8 do begin //To show the bitboard
|
||||||
|
for j:=1 to 8 do
|
||||||
|
mensagem := mensagem + BoolToStr(AttackedSquares[i][j],'1','0') + ' ';
|
||||||
|
mensagem := mensagem + #13;
|
||||||
|
end;
|
||||||
|
|
||||||
|
ShowMessage(mensagem);}
|
||||||
|
//result:=true;
|
||||||
|
result := (AttackedSquares[Ato.X][Ato.y]);
|
||||||
|
end;
|
||||||
|
function TChessGame.ValidateKnightMove(AFrom, ATo: TPoint): Boolean;
|
||||||
|
begin
|
||||||
|
result:=true;
|
||||||
|
end;
|
||||||
|
function TChessGame.ValidateBishopMove(AFrom, ATo: TPoint): Boolean;
|
||||||
|
var AttackedSquares : BitBoard;
|
||||||
|
i,j : Integer;
|
||||||
|
x,y : integer;
|
||||||
|
haveCaptured: boolean = false; //already have captured a piece
|
||||||
|
willBeACapture : boolean = false;// the movement will be a capture
|
||||||
|
validMove : boolean = false; //if the piece in the 'to' square is not of the same color of the player
|
||||||
|
mensagem : String;
|
||||||
|
begin
|
||||||
|
for i:=1 to 8 do // initialize the bitboard of attacked pieces.
|
||||||
|
for j:=1 to 8 do
|
||||||
|
AttackedSquares[i][j]:= false;
|
||||||
|
// ShowMessage('vai passar pelo up left');
|
||||||
|
//////////////////////////////////////UP LEFT///////////////////////////////////
|
||||||
|
y := AFrom.y+1;
|
||||||
|
x := AFrom.x-1;
|
||||||
|
if (x>=1) and (y<=8) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
y :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (x>=1) and (y <= 8) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[x][y] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
y := y+1;
|
||||||
|
x := x-1;
|
||||||
|
if (x>=1) and (y<=8) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END UP LEFT//////////////////////////////////
|
||||||
|
|
||||||
|
//////////////////////////////////////UP RIGHT//////////////////////////////////
|
||||||
|
y := AFrom.y+1;
|
||||||
|
x := AFrom.x+1;
|
||||||
|
willBeACapture:=false;
|
||||||
|
if (x<=8) and (y<=8) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
y :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (x<=8) and (y <= 8) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[x][y] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
y := y+1;
|
||||||
|
x := x+1;
|
||||||
|
if (x<=8) and (y<=8) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END UP RIGHT/////////////////////////////////
|
||||||
|
//////////////////////////////////////DOWN LEFT/////////////////////////////////
|
||||||
|
y := AFrom.y-1;
|
||||||
|
x := AFrom.x-1;
|
||||||
|
willBeACapture:=false;
|
||||||
|
if (x>=1) and (y>=1) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
y :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (x>=1) and (y >= 1) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[x][y] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
y := y-1;
|
||||||
|
x := x-1;
|
||||||
|
if (x>=1) and (y>=1) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END DOWN LEFT////////////////////////////////
|
||||||
|
//////////////////////////////////////DOWN RIGHT////////////////////////////////
|
||||||
|
y := AFrom.y-1;
|
||||||
|
x := AFrom.x+1;
|
||||||
|
willBeACapture:=false;
|
||||||
|
if (x<=8) and (y>=1) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
y :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (x<=8) and (y >= 1) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[x][y] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
y := y-1;
|
||||||
|
x := x+1;
|
||||||
|
if (x<=8) and (y>=1) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END DOWN RIGHT///////////////////////////////
|
||||||
|
|
||||||
|
{for i:=1 to 8 do begin //To show the bitboard
|
||||||
|
for j:=1 to 8 do
|
||||||
|
mensagem := mensagem + BoolToStr(AttackedSquares[i][j],'1','0') + ' ';
|
||||||
|
mensagem := mensagem + #13;
|
||||||
|
end;
|
||||||
|
|
||||||
|
ShowMessage(mensagem);}
|
||||||
|
|
||||||
|
result := (AttackedSquares[Ato.X][Ato.y]);
|
||||||
|
|
||||||
|
end;
|
||||||
|
function TChessGame.ValidateQueenMove(AFrom, ATo: TPoint): Boolean;
|
||||||
|
var AttackedSquares : BitBoard;
|
||||||
|
i,j : Integer;
|
||||||
|
x,y,l : integer; //l it's the same of the y or x, just an index.
|
||||||
|
haveCaptured: boolean = false; //already have captured a piece
|
||||||
|
willBeACapture : boolean = false;// the movement will be a capture
|
||||||
|
validMove : boolean = false; //if the piece in the 'to' square is not of the same color of the player
|
||||||
|
mensagem : String;
|
||||||
|
begin
|
||||||
|
|
||||||
|
for i:=1 to 8 do // initialize the bitboard of attacked pieces.
|
||||||
|
for j:=1 to 8 do
|
||||||
|
AttackedSquares[i][j]:= false;
|
||||||
|
// ShowMessage('vai passar pelo up');
|
||||||
|
|
||||||
|
//////////////////////////////////////UP////////////////////////////////////////
|
||||||
|
l := AFrom.y+1;
|
||||||
|
if (l<=8) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[AFrom.x][l] in BlackPieces);
|
||||||
|
validMove:= not (Board[AFrom.x][l] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[AFrom.x][l] in WhitePieces);
|
||||||
|
validMove:=not (Board[AFrom.x][l] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
l :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (l <= 8) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[AFrom.x][l] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
l := l+1;
|
||||||
|
if (l<=8) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[AFrom.x][l] in BlackPieces);
|
||||||
|
validMove:= not (Board[AFrom.x][l] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[AFrom.x][l] in WhitePieces);
|
||||||
|
validMove:=not (Board[AFrom.x][l] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END UP///////////////////////////////////////
|
||||||
|
///////////////////////////////////DOWN/////////////////////////////////////////
|
||||||
|
haveCaptured:=false;
|
||||||
|
l := AFrom.y-1;
|
||||||
|
if (l>=1) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[AFrom.x][l] in BlackPieces);
|
||||||
|
validMove:= not (Board[AFrom.x][l] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[AFrom.x][l] in WhitePieces);
|
||||||
|
validMove:=not (Board[AFrom.x][l] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
l :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (l >= 1) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[AFrom.x][l] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
l := l-1;
|
||||||
|
if (l>=1) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[AFrom.x][l] in BlackPieces);
|
||||||
|
validMove:= not (Board[AFrom.x][l] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[AFrom.x][l] in WhitePieces);
|
||||||
|
validMove:=not (Board[AFrom.x][l] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////DOWN/////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////////RIGHT////////////////////////////////////////
|
||||||
|
haveCaptured:=false;
|
||||||
|
l := AFrom.x+1;
|
||||||
|
if (l<=8) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[l][AFrom.y] in BlackPieces);
|
||||||
|
validMove:= not (Board[l][AFrom.y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[l][AFrom.y] in WhitePieces);
|
||||||
|
validMove:=not (Board[l][AFrom.y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
l :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (l <= 8) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[l][AFrom.y] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
l := l+1;
|
||||||
|
if (l<=8) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[l][AFrom.y] in BlackPieces);
|
||||||
|
validMove:= not (Board[l][AFrom.y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[l][AFrom.y] in WhitePieces);
|
||||||
|
validMove:=not (Board[l][AFrom.y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END RIGHT////////////////////////////////////
|
||||||
|
///////////////////////////////////LEFT/////////////////////////////////////////
|
||||||
|
haveCaptured:=false;
|
||||||
|
l := AFrom.x-1;
|
||||||
|
if (l>=1) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[l][AFrom.y] in BlackPieces);
|
||||||
|
validMove:= not (Board[l][AFrom.y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[l][AFrom.y] in WhitePieces);
|
||||||
|
validMove:=not (Board[l][AFrom.y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
l :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (l >= 1) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[l][AFrom.y] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
l := l-1;
|
||||||
|
if (l>=1) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[l][AFrom.y] in BlackPieces);
|
||||||
|
validMove:= not (Board[l][AFrom.y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[l][AFrom.y] in WhitePieces);
|
||||||
|
validMove:=not (Board[l][AFrom.y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END LEFT/////////////////////////////////////
|
||||||
|
//////////////////////////////////////UP LEFT///////////////////////////////////
|
||||||
|
y := AFrom.y+1;
|
||||||
|
x := AFrom.x-1;
|
||||||
|
if (x>=1) and (y<=8) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
y :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (x>=1) and (y <= 8) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[x][y] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
y := y+1;
|
||||||
|
x := x-1;
|
||||||
|
if (x>=1) and (y<=8) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END UP LEFT//////////////////////////////////
|
||||||
|
|
||||||
|
//////////////////////////////////////UP RIGHT//////////////////////////////////
|
||||||
|
y := AFrom.y+1;
|
||||||
|
x := AFrom.x+1;
|
||||||
|
willBeACapture:=false;
|
||||||
|
if (x<=8) and (y<=8) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
y :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (x<=8) and (y <= 8) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[x][y] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
y := y+1;
|
||||||
|
x := x+1;
|
||||||
|
if (x<=8) and (y<=8) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END UP RIGHT/////////////////////////////////
|
||||||
|
//////////////////////////////////////DOWN LEFT/////////////////////////////////
|
||||||
|
y := AFrom.y-1;
|
||||||
|
x := AFrom.x-1;
|
||||||
|
willBeACapture:=false;
|
||||||
|
if (x>=1) and (y>=1) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
y :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (x>=1) and (y >= 1) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[x][y] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
y := y-1;
|
||||||
|
x := x-1;
|
||||||
|
if (x>=1) and (y>=1) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END DOWN LEFT////////////////////////////////
|
||||||
|
//////////////////////////////////////DOWN RIGHT////////////////////////////////
|
||||||
|
y := AFrom.y-1;
|
||||||
|
x := AFrom.x+1;
|
||||||
|
willBeACapture:=false;
|
||||||
|
if (x<=8) and (y>=1) then begin
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
y :=0; // if it is in the border of the board, put 0 in l to skip the while below.
|
||||||
|
haveCaptured:=false;
|
||||||
|
while ( (x<=8) and (y >= 1) and (validMove) and (not haveCaptured)) do begin
|
||||||
|
AttackedSquares[x][y] := true;
|
||||||
|
if (willBeACapture) then
|
||||||
|
haveCaptured:=true;
|
||||||
|
y := y-1;
|
||||||
|
x := x+1;
|
||||||
|
if (x<=8) and (y>=1) then begin //again to not have an 'out of bounds' error
|
||||||
|
if (CurrentPlayerIsWhite) then begin
|
||||||
|
willBeACapture:= (Board[x][y] in BlackPieces);
|
||||||
|
validMove:= not (Board[x][y] in WhitePieces);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
willBeACapture:=(Board[x][y] in WhitePieces);
|
||||||
|
validMove:=not (Board[x][y] in BlackPieces)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
///////////////////////////////////END DOWN RIGHT///////////////////////////////
|
||||||
|
|
||||||
|
for i:=1 to 8 do begin //To show the bitboard
|
||||||
|
for j:=1 to 8 do
|
||||||
|
mensagem := mensagem + BoolToStr(AttackedSquares[i][j],'1','0') + ' ';
|
||||||
|
mensagem := mensagem + #13;
|
||||||
|
end;
|
||||||
|
|
||||||
|
//ShowMessage(mensagem);
|
||||||
|
result:= (AttackedSquares[Ato.X][Ato.y]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TChessGame.ValidateKingMove(AFrom, ATo: TPoint): Boolean;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TChessGame.ValidatePawnMove(AFrom, ATo: TPoint): Boolean;
|
||||||
|
begin
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ uses
|
|||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
Winsock,
|
Winsock,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, SysUtils;
|
Classes, SysUtils, Process;
|
||||||
|
|
||||||
function ChessGetLocalIP(): string;
|
function ChessGetLocalIP(): string;
|
||||||
|
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
<VersionInfo>
|
<VersionInfo>
|
||||||
<StringTable ProductVersion=""/>
|
<StringTable ProductVersion=""/>
|
||||||
</VersionInfo>
|
</VersionInfo>
|
||||||
|
<BuildModes Count="1">
|
||||||
|
<Item1 Name="default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
<PublishOptions>
|
<PublishOptions>
|
||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||||
@ -24,6 +27,7 @@
|
|||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<local>
|
||||||
<FormatVersion Value="1"/>
|
<FormatVersion Value="1"/>
|
||||||
|
<LaunchingApplication PathPlusParams="\usr\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
||||||
</local>
|
</local>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="2">
|
<RequiredPackages Count="2">
|
||||||
@ -70,7 +74,7 @@
|
|||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
<Version Value="9"/>
|
<Version Value="10"/>
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<Target>
|
<Target>
|
||||||
<Filename Value="fpchess"/>
|
<Filename Value="fpchess"/>
|
||||||
|
@ -10,7 +10,7 @@ uses
|
|||||||
Forms, lnetvisual, mainform, chessdrawer, chessgame, chessconfig,
|
Forms, lnetvisual, mainform, chessdrawer, chessgame, chessconfig,
|
||||||
chesstcputils;
|
chesstcputils;
|
||||||
|
|
||||||
{$R *.res}
|
//{$R *.res}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Application.Initialize;
|
Application.Initialize;
|
||||||
|
@ -3,22 +3,22 @@ object formChess: TformChess
|
|||||||
Height = 433
|
Height = 433
|
||||||
Top = 209
|
Top = 209
|
||||||
Width = 360
|
Width = 360
|
||||||
|
ActiveControl = notebookMain
|
||||||
Caption = 'FP Chess 0.1'
|
Caption = 'FP Chess 0.1'
|
||||||
ClientHeight = 433
|
ClientHeight = 433
|
||||||
ClientWidth = 360
|
ClientWidth = 360
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
LCLVersion = '0.9.29'
|
LCLVersion = '0.9.31'
|
||||||
object notebookMain: TUntabbedNotebook
|
object notebookMain: TNotebook
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 433
|
Height = 433
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 360
|
Width = 360
|
||||||
PageIndex = 4
|
PageIndex = 0
|
||||||
Align = alClient
|
Align = alClient
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
TabStop = True
|
TabStop = True
|
||||||
object pageStart: TUNBPage
|
object pageStart: TPage
|
||||||
OnBeforeShow = pageBeforeShow
|
|
||||||
ClientWidth = 360
|
ClientWidth = 360
|
||||||
ClientHeight = 433
|
ClientHeight = 433
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
@ -43,37 +43,53 @@ object formChess: TformChess
|
|||||||
ParentColor = False
|
ParentColor = False
|
||||||
WordWrap = True
|
WordWrap = True
|
||||||
end
|
end
|
||||||
|
object Label6: TLabel
|
||||||
|
Left = 28
|
||||||
|
Height = 18
|
||||||
|
Top = 104
|
||||||
|
Width = 56
|
||||||
|
Caption = 'Start as:'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object Label7: TLabel
|
||||||
|
Left = 80
|
||||||
|
Height = 18
|
||||||
|
Top = 163
|
||||||
|
Width = 152
|
||||||
|
Caption = 'minutes for each player'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
object btnSinglePlayer: TBitBtn
|
object btnSinglePlayer: TBitBtn
|
||||||
Left = 64
|
Left = 24
|
||||||
Height = 30
|
Height = 30
|
||||||
Top = 200
|
Top = 200
|
||||||
Width = 224
|
Width = 304
|
||||||
Caption = 'Play Against the Computer'
|
Caption = 'Play Against the Computer'
|
||||||
Enabled = False
|
Enabled = False
|
||||||
OnClick = HandleMainScreenButton
|
OnClick = HandleMainScreenButton
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object btnDirectComm: TBitBtn
|
object btnDirectComm: TBitBtn
|
||||||
Left = 64
|
Left = 24
|
||||||
Height = 30
|
Height = 30
|
||||||
Top = 288
|
Top = 280
|
||||||
Width = 224
|
Width = 304
|
||||||
Caption = 'Play with a friend through a direct connection'
|
Caption = 'Play with a friend through a direct connection'
|
||||||
Enabled = False
|
Enabled = False
|
||||||
OnClick = HandleMainScreenButton
|
OnClick = HandleMainScreenButton
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object BitBtn3: TBitBtn
|
object BitBtn3: TBitBtn
|
||||||
Left = 62
|
Left = 24
|
||||||
Height = 30
|
Height = 30
|
||||||
Top = 376
|
Top = 360
|
||||||
Width = 224
|
Width = 304
|
||||||
Caption = 'Quit'
|
Caption = 'Quit'
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
object editPlayerName: TLabeledEdit
|
object editPlayerName: TLabeledEdit
|
||||||
Left = 88
|
Left = 88
|
||||||
Height = 21
|
Height = 25
|
||||||
Top = 72
|
Top = 72
|
||||||
Width = 120
|
Width = 120
|
||||||
EditLabel.AnchorSideLeft.Control = editPlayerName
|
EditLabel.AnchorSideLeft.Control = editPlayerName
|
||||||
@ -81,29 +97,21 @@ object formChess: TformChess
|
|||||||
EditLabel.AnchorSideTop.Side = asrCenter
|
EditLabel.AnchorSideTop.Side = asrCenter
|
||||||
EditLabel.AnchorSideRight.Control = editPlayerName
|
EditLabel.AnchorSideRight.Control = editPlayerName
|
||||||
EditLabel.AnchorSideBottom.Control = editPlayerName
|
EditLabel.AnchorSideBottom.Control = editPlayerName
|
||||||
EditLabel.Left = 24
|
EditLabel.Left = 2
|
||||||
EditLabel.Height = 14
|
EditLabel.Height = 18
|
||||||
EditLabel.Top = 75
|
EditLabel.Top = 75
|
||||||
EditLabel.Width = 61
|
EditLabel.Width = 83
|
||||||
EditLabel.Caption = 'Player Name'
|
EditLabel.Caption = 'Player Name'
|
||||||
EditLabel.ParentColor = False
|
EditLabel.ParentColor = False
|
||||||
LabelPosition = lpLeft
|
LabelPosition = lpLeft
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
object Label6: TLabel
|
|
||||||
Left = 28
|
|
||||||
Height = 14
|
|
||||||
Top = 104
|
|
||||||
Width = 43
|
|
||||||
Caption = 'Start as:'
|
|
||||||
ParentColor = False
|
|
||||||
end
|
|
||||||
object comboStartColor: TComboBox
|
object comboStartColor: TComboBox
|
||||||
Left = 88
|
Left = 88
|
||||||
Height = 21
|
Height = 27
|
||||||
Top = 104
|
Top = 104
|
||||||
Width = 120
|
Width = 120
|
||||||
ItemHeight = 13
|
ItemHeight = 0
|
||||||
ItemIndex = 0
|
ItemIndex = 0
|
||||||
Items.Strings = (
|
Items.Strings = (
|
||||||
'White'
|
'White'
|
||||||
@ -114,9 +122,9 @@ object formChess: TformChess
|
|||||||
end
|
end
|
||||||
object checkTimer: TCheckBox
|
object checkTimer: TCheckBox
|
||||||
Left = 24
|
Left = 24
|
||||||
Height = 17
|
Height = 21
|
||||||
Top = 136
|
Top = 136
|
||||||
Width = 163
|
Width = 220
|
||||||
Caption = 'Set a time limit for each Player'
|
Caption = 'Set a time limit for each Player'
|
||||||
Checked = True
|
Checked = True
|
||||||
State = cbChecked
|
State = cbChecked
|
||||||
@ -124,43 +132,34 @@ object formChess: TformChess
|
|||||||
end
|
end
|
||||||
object spinPlayerTime: TSpinEdit
|
object spinPlayerTime: TSpinEdit
|
||||||
Left = 21
|
Left = 21
|
||||||
Height = 21
|
Height = 25
|
||||||
Top = 160
|
Top = 160
|
||||||
Width = 50
|
Width = 50
|
||||||
TabOrder = 6
|
TabOrder = 6
|
||||||
Value = 30
|
Value = 30
|
||||||
end
|
end
|
||||||
object Label7: TLabel
|
|
||||||
Left = 80
|
|
||||||
Height = 14
|
|
||||||
Top = 163
|
|
||||||
Width = 114
|
|
||||||
Caption = 'minutes for each player'
|
|
||||||
ParentColor = False
|
|
||||||
end
|
|
||||||
object btnHotSeat: TBitBtn
|
object btnHotSeat: TBitBtn
|
||||||
Left = 64
|
Left = 24
|
||||||
Height = 30
|
Height = 30
|
||||||
Top = 240
|
Top = 240
|
||||||
Width = 224
|
Width = 304
|
||||||
Caption = 'Play with a friend in the same Computer'
|
Caption = 'Play with a friend in the same Computer'
|
||||||
OnClick = HandleMainScreenButton
|
OnClick = HandleMainScreenButton
|
||||||
TabOrder = 7
|
TabOrder = 7
|
||||||
end
|
end
|
||||||
object btnWebservice: TBitBtn
|
object btnWebservice: TBitBtn
|
||||||
Left = 64
|
Left = 24
|
||||||
Height = 30
|
Height = 30
|
||||||
Top = 328
|
Top = 320
|
||||||
Width = 224
|
Width = 304
|
||||||
Caption = 'Play with a friend through the chess Webservice'
|
Caption = 'Play with a friend through the chess Webservice'
|
||||||
OnClick = HandleMainScreenButton
|
OnClick = HandleMainScreenButton
|
||||||
TabOrder = 8
|
TabOrder = 8
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object pageConfigConnection: TUNBPage
|
object pageConfigConnection: TPage
|
||||||
OnBeforeShow = pageBeforeShow
|
ClientWidth = 712
|
||||||
ClientWidth = 360
|
ClientHeight = 810
|
||||||
ClientHeight = 433
|
|
||||||
object Label3: TLabel
|
object Label3: TLabel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 32
|
Height = 32
|
||||||
@ -222,10 +221,9 @@ object formChess: TformChess
|
|||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object pageConnecting: TUNBPage
|
object pageConnecting: TPage
|
||||||
OnBeforeShow = pageBeforeShow
|
ClientWidth = 712
|
||||||
ClientWidth = 360
|
ClientHeight = 810
|
||||||
ClientHeight = 433
|
|
||||||
object Label4: TLabel
|
object Label4: TLabel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 32
|
Height = 32
|
||||||
@ -246,10 +244,9 @@ object formChess: TformChess
|
|||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object pageGame: TUNBPage
|
object pageGame: TPage
|
||||||
OnBeforeShow = pageBeforeShow
|
ClientWidth = 712
|
||||||
ClientWidth = 360
|
ClientHeight = 810
|
||||||
ClientHeight = 433
|
|
||||||
object Label5: TLabel
|
object Label5: TLabel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 32
|
Height = 32
|
||||||
@ -271,29 +268,9 @@ object formChess: TformChess
|
|||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object pageWebservice: TUNBPage
|
object pageWebservice: TPage
|
||||||
ClientWidth = 360
|
ClientWidth = 712
|
||||||
ClientHeight = 433
|
ClientHeight = 810
|
||||||
object editWebserviceURL: TLabeledEdit
|
|
||||||
Left = 72
|
|
||||||
Height = 21
|
|
||||||
Top = 72
|
|
||||||
Width = 280
|
|
||||||
EditLabel.AnchorSideLeft.Control = editPlayerName
|
|
||||||
EditLabel.AnchorSideTop.Control = editPlayerName
|
|
||||||
EditLabel.AnchorSideTop.Side = asrCenter
|
|
||||||
EditLabel.AnchorSideRight.Control = editPlayerName
|
|
||||||
EditLabel.AnchorSideBottom.Control = editPlayerName
|
|
||||||
EditLabel.Left = 24
|
|
||||||
EditLabel.Height = 14
|
|
||||||
EditLabel.Top = 75
|
|
||||||
EditLabel.Width = 61
|
|
||||||
EditLabel.Caption = 'Player Name'
|
|
||||||
EditLabel.ParentColor = False
|
|
||||||
LabelPosition = lpLeft
|
|
||||||
TabOrder = 0
|
|
||||||
Text = 'http://www.bobswart.nl/cgi-bin/ChessISAPIServer.dll/wsdl/IDelphiChess'
|
|
||||||
end
|
|
||||||
object Label8: TLabel
|
object Label8: TLabel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 32
|
Height = 32
|
||||||
@ -306,6 +283,26 @@ object formChess: TformChess
|
|||||||
ParentColor = False
|
ParentColor = False
|
||||||
ParentFont = False
|
ParentFont = False
|
||||||
end
|
end
|
||||||
|
object editWebserviceURL: TLabeledEdit
|
||||||
|
Left = 72
|
||||||
|
Height = 22
|
||||||
|
Top = 72
|
||||||
|
Width = 280
|
||||||
|
EditLabel.AnchorSideLeft.Control = editPlayerName
|
||||||
|
EditLabel.AnchorSideTop.Control = editPlayerName
|
||||||
|
EditLabel.AnchorSideTop.Side = asrCenter
|
||||||
|
EditLabel.AnchorSideRight.Control = editPlayerName
|
||||||
|
EditLabel.AnchorSideBottom.Control = editPlayerName
|
||||||
|
EditLabel.Left = 6
|
||||||
|
EditLabel.Height = 15
|
||||||
|
EditLabel.Top = 75
|
||||||
|
EditLabel.Width = 75
|
||||||
|
EditLabel.Caption = 'Player Name'
|
||||||
|
EditLabel.ParentColor = False
|
||||||
|
LabelPosition = lpLeft
|
||||||
|
TabOrder = 0
|
||||||
|
Text = 'http://www.bobswart.nl/cgi-bin/ChessISAPIServer.dll/wsdl/IDelphiChess'
|
||||||
|
end
|
||||||
object Button1: TButton
|
object Button1: TButton
|
||||||
Left = 35
|
Left = 35
|
||||||
Height = 25
|
Height = 25
|
||||||
|
@ -48,19 +48,19 @@ type
|
|||||||
editRemoteID: TLabeledEdit;
|
editRemoteID: TLabeledEdit;
|
||||||
editLocalIP: TLabeledEdit;
|
editLocalIP: TLabeledEdit;
|
||||||
editPlayerName: TLabeledEdit;
|
editPlayerName: TLabeledEdit;
|
||||||
pageStart: TUNBPage;
|
pageStart: TPage;
|
||||||
pageConfigConnection: TUNBPage;
|
pageConfigConnection: TPage;
|
||||||
notebookMain: TUntabbedNotebook;
|
notebookMain: TNotebook;
|
||||||
pageConnecting: TUNBPage;
|
pageConnecting: TPage;
|
||||||
ProgressBar1: TProgressBar;
|
ProgressBar1: TProgressBar;
|
||||||
pageGame: TUNBPage;
|
pageGame: TPage;
|
||||||
spinPlayerTime: TSpinEdit;
|
spinPlayerTime: TSpinEdit;
|
||||||
timerChessTimer: TTimer;
|
timerChessTimer: TTimer;
|
||||||
pageWebservice: TUNBPage;
|
pageWebservice: TPage;
|
||||||
procedure btnConnectClick(Sender: TObject);
|
procedure btnConnectClick(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure HandleMainScreenButton(Sender: TObject);
|
procedure HandleMainScreenButton(Sender: TObject);
|
||||||
procedure pageBeforeShow(Sender: TObject; ANewPage: TUNBPage; ANewIndex: Integer);
|
procedure pageBeforeShow(Sender: TObject; ANewPage: TPage; ANewIndex: Integer);
|
||||||
procedure timerChessTimerTimer(Sender: TObject);
|
procedure timerChessTimerTimer(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
@ -100,7 +100,7 @@ begin
|
|||||||
else if Sender = btnDirectComm then notebookMain.PageIndex := INT_PAGE_CONFIGCONNECTION;
|
else if Sender = btnDirectComm then notebookMain.PageIndex := INT_PAGE_CONFIGCONNECTION;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TformChess.pageBeforeShow(Sender: TObject; ANewPage: TUNBPage; ANewIndex: Integer);
|
procedure TformChess.pageBeforeShow(Sender: TObject; ANewPage: TPage; ANewIndex: Integer);
|
||||||
begin
|
begin
|
||||||
if ANewIndex = INT_PAGE_CONFIGCONNECTION then
|
if ANewIndex = INT_PAGE_CONFIGCONNECTION then
|
||||||
begin
|
begin
|
||||||
|
Reference in New Issue
Block a user