Subversion Repositories jumper

Compare Revisions

Regard whitespace Rev 25 → Rev 24

/trunk/LevelFunctions.pas
6,24 → 6,18
SysUtils, Dialogs, Functions, ExtCtrls, Classes, Math;
 
type
TCoord = record
X: integer;
Y: integer;
end;
 
TFieldType = (ftUndefined, ftFullSpace, ftEmpty, ftRed, ftYellow, ftGreen);
 
TFieldState = (fsUndefined, fsLocked, fsAvailable, fsOccupied);
 
TGameMode = (gmUndefined, gmNormal, gmDiagonal);
 
TLevelError = (leUndefined, leNone, leInvalidElement, leEmptyBoard,
leRowInvalidLength, leUnsupportedVersion, leUnsupportedMode);
TLevelError = (leUndefined, leNone, leInvalidElement, leEmptyBoard, leRowInvalidLength,
leUnsupportedVersion, leUnsupportedMode);
 
TGoalStatus = (gsUndefined, gsNoGoal, gsMultipleStonesRemaining,
gsLastStoneInGoalRed, gsLastStoneInGoalYellow,
gsLastStoneInGoalGreen, gsLastStoneOutsideGoal);
 
TCoord = record
X: integer;
Y: integer;
end;
 
TField = record
Indent: integer;
FieldType: TFieldType;
32,12 → 26,15
Stone: TImage;
end;
 
TGoalStatus = (gsUndefined, gsNoGoal, gsMultipleStonesRemaining, gsLastStoneInGoalRed, gsLastStoneInGoalYellow, gsLastStoneInGoalGreen, gsLastStoneOutsideGoal);
 
TFieldState = (fsUndefined, fsLocked, fsAvailable, fsOccupied);
 
TPlayGroundMatrix = record
Fields: array of array of TField;
public
procedure InitFieldArray(width, height: integer);
function MatrixHasGoal: boolean;
function GoalStatus(StonesRemaining: integer): TGoalStatus;
function GoalFieldType: TFieldType;
function MatrixWorth: integer;
procedure ClearMatrix(FreeVCL: boolean);
45,7 → 42,6
class function FieldState(t: TFieldType): TFieldState; overload; static;
function FieldState(f: TField): TFieldState; overload;
function FieldState(x, y: integer): TFieldState; overload;
function FieldState(c: TCoord): TFieldState; overload;
function CanJump(SourceX, SourceY, DestX, DestY: integer; DiagonalOK: boolean): boolean; overload;
function CanJump(Source, Dest: TCoord; DiagonalOK: boolean): boolean; overload;
function CanJump(SourceX, SourceY: integer; DiagonalOK: boolean): boolean; overload;
76,14 → 72,11
 
implementation
 
uses
Constants;
 
function FieldTypeWorth(t: TFieldType): integer;
begin
if t = ftGreen then result := WORTH_GREEN
else if t = ftYellow then result := WORTH_YELLOW
else if t = ftRed then result := WORTH_RED
if t = ftGreen then result := 10
else if t = ftYellow then result := 20
else if t = ftRed then result := 30
else result := 0;
end;
 
103,28 → 96,6
end;
end;
 
function TPlayGroundMatrix.GoalStatus(StonesRemaining: integer): TGoalStatus;
var
ft: TFieldType;
begin
if not MatrixHasGoal then
result := gsNoGoal
else if StonesRemaining > 1 then
Result := gsMultipleStonesRemaining
else
begin
ft := GoalFieldType;
if ft = ftRed then
result := gsLastStoneInGoalRed
else if ft = ftYellow then
result := gsLastStoneInGoalYellow
else if ft = ftGreen then
result := gsLastStoneInGoalGreen
else
result := gsUndefined;
end;
end;
 
function TPlayGroundMatrix.GoalFieldType: TFieldType;
var
x, y: integer;
239,11 → 210,6
result := x + y * Width;
end;
 
function TPlayGroundMatrix.FieldState(c: TCoord): TFieldState;
begin
result := FieldState(c.X, c.Y);
end;
 
function TPlayGroundMatrix.CoordToIndex(coord: TCoord): integer;
begin
result := CoordToIndex(coord.X, coord.Y);
/trunk/Main.pas
219,7 → 219,7
 
procedure TMainForm.RefreshStonesRemoved;
resourcestring
LNG_STONES_REMOVED = '%d of %d stones removed'; // Jumping stone not counted
LNG_STONES_REMOVED = '%d of %d stones removed';
begin
Statistics.Panels.Items[1].Text := Format(LNG_STONES_REMOVED, [LevelRemovedStones, LevelTotalStones-1]);
end;
509,9 → 509,26
end;
 
function TMainForm.GoalStatus: TGoalStatus;
var
ft: TFieldType;
begin
result := PlaygroundMatrix.GoalStatus(LevelTotalStones - LevelRemovedStones);
if not PlaygroundMatrix.MatrixHasGoal then
result := gsNoGoal
else if LevelRemovedStones < LevelTotalStones-1 then
Result := gsMultipleStonesRemaining
else
begin
ft := PlaygroundMatrix.GoalFieldType;
if ft = ftRed then
result := gsLastStoneInGoalRed
else if ft = ftYellow then
result := gsLastStoneInGoalYellow
else if ft = ftGreen then
result := gsLastStoneInGoalGreen
else
result := gsUndefined;
end;
end;
 
procedure TMainForm.FormCreate(Sender: TObject);
begin
/trunk/Constants.pas
16,11 → 16,6
MET_OUTER_MARGIN = 8;
MET_SHAPE_MARGIN = 3;
 
// Field type worth
WORTH_RED = 30;
WORTH_YELLOW = 20;
WORTH_GREEN = 10;
 
// Resourcennamen
RES_JUMP = 'Jump';
RES_UNDO = 'Undo';
/trunk/Finish.pas
55,7 → 55,7
function TFinishForm.Execute(LevelName: String; Score, StonesTotal, StonesRemoved, Seconds: Integer; GoalStatus: TGoalStatus; JumpHistory: TStringList): Integer;
resourcestring
LNG_SCORE = 'Score: %d';
LNG_REMAINING = 'Remaining stones: %d (%f%%)'; // Jumping stone not counted!
LNG_REMAINING = 'Remaining stones: %d (%f%%)';
LNG_TIME_SECONDS = 'Time: %d seconds';
LNG_POINTS_PER_MINUTE = '%d points per minute';
LNG_GOAL_RED = 'Red stone in target field (%d points)';