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; 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

View File

@@ -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;