You've already forked lazarus-ccr
fpchess: Improves some coordinates
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1876 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -114,6 +114,7 @@ type
|
|||||||
procedure StartNewGame(APlayAsWhite: Integer; AUseTimer: Boolean; APlayerTime: Integer); overload;
|
procedure StartNewGame(APlayAsWhite: Integer; AUseTimer: Boolean; APlayerTime: Integer); overload;
|
||||||
function ClientToBoardCoords(AClientCoords: TPoint): TPoint;
|
function ClientToBoardCoords(AClientCoords: TPoint): TPoint;
|
||||||
function BoardPosToChessCoords(APos: TPoint): string;
|
function BoardPosToChessCoords(APos: TPoint): string;
|
||||||
|
function ColumnNumToLetter(ACol: Integer): string;
|
||||||
function CheckStartMove(AFrom: TPoint): Boolean;
|
function CheckStartMove(AFrom: TPoint): Boolean;
|
||||||
function CheckEndMove(ATo: TPoint): Boolean;
|
function CheckEndMove(ATo: TPoint): Boolean;
|
||||||
function FindKing(): TPoint;
|
function FindKing(): TPoint;
|
||||||
@@ -722,10 +723,15 @@ function TChessGame.BoardPosToChessCoords(APos: TPoint): string;
|
|||||||
var
|
var
|
||||||
lStr: string;
|
lStr: string;
|
||||||
begin
|
begin
|
||||||
lStr := Char(APos.X + 96);
|
lStr := ColumnNumToLetter(APos.X);
|
||||||
Result := Format('%s%d', [lStr, APos.Y]);
|
Result := Format('%s%d', [lStr, APos.Y]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TChessGame.ColumnNumToLetter(ACol: Integer): string;
|
||||||
|
begin
|
||||||
|
Result := Char(ACol + 96);
|
||||||
|
end;
|
||||||
|
|
||||||
// Check if we are moving to either an empty space or to an enemy piece
|
// Check if we are moving to either an empty space or to an enemy piece
|
||||||
function TChessGame.CheckEndMove(ATo: TPoint): Boolean;
|
function TChessGame.CheckEndMove(ATo: TPoint): Boolean;
|
||||||
begin
|
begin
|
||||||
|
@@ -143,13 +143,14 @@ end;
|
|||||||
|
|
||||||
procedure TformChess.UpdateCaptions;
|
procedure TformChess.UpdateCaptions;
|
||||||
var
|
var
|
||||||
lStr: string;
|
lStr, lStr2: string;
|
||||||
begin
|
begin
|
||||||
if vChessGame.IsWhitePlayerTurn then lStr := 'White playing'
|
if vChessGame.IsWhitePlayerTurn then lStr := 'White playing'
|
||||||
else lStr := 'Black playing';
|
else lStr := 'Black playing';
|
||||||
|
|
||||||
lStr := lStr + Format(' X: %d Y: %d',
|
lStr2 := vChessGame.BoardPosToChessCoords(vChessGame.MouseMovePos);
|
||||||
[vChessGame.MouseMovePos.X, vChessGame.MouseMovePos.Y]);
|
lStr := lStr + Format(' X: %d Y: %d = %s',
|
||||||
|
[vChessGame.MouseMovePos.X, vChessGame.MouseMovePos.Y, lStr2]);
|
||||||
|
|
||||||
formChess.labelPos.Caption := lStr;
|
formChess.labelPos.Caption := lStr;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user