Subversion Repositories jumper

Compare Revisions

Ignore whitespace Rev 24 → Rev 25

/trunk/Constants.pas
16,6 → 16,11
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%%)';
LNG_REMAINING = 'Remaining stones: %d (%f%%)'; // Jumping stone not counted!
LNG_TIME_SECONDS = 'Time: %d seconds';
LNG_POINTS_PER_MINUTE = '%d points per minute';
LNG_GOAL_RED = 'Red stone in target field (%d points)';
/trunk/LevelFunctions.pas
6,18 → 6,24
SysUtils, Dialogs, Functions, ExtCtrls, Classes, Math;
 
type
TFieldType = (ftUndefined, ftFullSpace, ftEmpty, ftRed, ftYellow, ftGreen);
 
TFieldState = (fsUndefined, fsLocked, fsAvailable, fsOccupied);
 
TGameMode = (gmUndefined, gmNormal, gmDiagonal);
 
TLevelError = (leUndefined, leNone, leInvalidElement, leEmptyBoard,
leRowInvalidLength, leUnsupportedVersion, leUnsupportedMode);
 
TGoalStatus = (gsUndefined, gsNoGoal, gsMultipleStonesRemaining,
gsLastStoneInGoalRed, gsLastStoneInGoalYellow,
gsLastStoneInGoalGreen, gsLastStoneOutsideGoal);
 
TCoord = record
X: integer;
Y: integer;
end;
 
TFieldType = (ftUndefined, ftFullSpace, ftEmpty, ftRed, ftYellow, ftGreen);
 
TGameMode = (gmUndefined, gmNormal, gmDiagonal);
 
TLevelError = (leUndefined, leNone, leInvalidElement, leEmptyBoard, leRowInvalidLength,
leUnsupportedVersion, leUnsupportedMode);
 
TField = record
Indent: integer;
FieldType: TFieldType;
26,15 → 32,12
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);
42,6 → 45,7
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;
72,11 → 76,14
 
implementation
 
uses
Constants;
 
function FieldTypeWorth(t: TFieldType): integer;
begin
if t = ftGreen then result := 10
else if t = ftYellow then result := 20
else if t = ftRed then result := 30
if t = ftGreen then result := WORTH_GREEN
else if t = ftYellow then result := WORTH_YELLOW
else if t = ftRed then result := WORTH_RED
else result := 0;
end;
 
96,6 → 103,28
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;
210,6 → 239,11
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';
LNG_STONES_REMOVED = '%d of %d stones removed'; // Jumping stone not counted
begin
Statistics.Panels.Items[1].Text := Format(LNG_STONES_REMOVED, [LevelRemovedStones, LevelTotalStones-1]);
end;
509,25 → 509,8
end;
 
function TMainForm.GoalStatus: TGoalStatus;
var
ft: TFieldType;
begin
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;
result := PlaygroundMatrix.GoalStatus(LevelTotalStones - LevelRemovedStones);
end;
 
procedure TMainForm.FormCreate(Sender: TObject);