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:
sekelsenmat
2011-08-30 15:17:58 +00:00
parent f3267c88d3
commit 0caf78ba9d
2 changed files with 11 additions and 4 deletions

View File

@@ -114,6 +114,7 @@ type
procedure StartNewGame(APlayAsWhite: Integer; AUseTimer: Boolean; APlayerTime: Integer); overload;
function ClientToBoardCoords(AClientCoords: TPoint): TPoint;
function BoardPosToChessCoords(APos: TPoint): string;
function ColumnNumToLetter(ACol: Integer): string;
function CheckStartMove(AFrom: TPoint): Boolean;
function CheckEndMove(ATo: TPoint): Boolean;
function FindKing(): TPoint;
@@ -722,10 +723,15 @@ function TChessGame.BoardPosToChessCoords(APos: TPoint): string;
var
lStr: string;
begin
lStr := Char(APos.X + 96);
lStr := ColumnNumToLetter(APos.X);
Result := Format('%s%d', [lStr, APos.Y]);
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
function TChessGame.CheckEndMove(ATo: TPoint): Boolean;
begin

View File

@@ -143,13 +143,14 @@ end;
procedure TformChess.UpdateCaptions;
var
lStr: string;
lStr, lStr2: string;
begin
if vChessGame.IsWhitePlayerTurn then lStr := 'White playing'
else lStr := 'Black playing';
lStr := lStr + Format(' X: %d Y: %d',
[vChessGame.MouseMovePos.X, vChessGame.MouseMovePos.Y]);
lStr2 := vChessGame.BoardPosToChessCoords(vChessGame.MouseMovePos);
lStr := lStr + Format(' X: %d Y: %d = %s',
[vChessGame.MouseMovePos.X, vChessGame.MouseMovePos.Y, lStr2]);
formChess.labelPos.Caption := lStr;