Subversion Repositories jumper

Compare Revisions

No changes between revisions

Regard whitespace Rev 7 → Rev 8

/trunk/Constants.pas
19,7 → 19,8
// Resourcennamen
RES_JUMP = 'Jump';
RES_UNDO = 'Undo';
RES_FINISH = 'Finish';
RES_WIN1 = 'Win1';
RES_WIN2 = 'Win2';
RES_LOSE = 'Lose';
RES_EMPTY = 'EmptyField';
RES_GREEN = 'GreenStone';
57,6 → 58,10
LNG_TIME_SECONDS = 'Time: %d seconds';
LNG_POINTS_PER_MINUTE = '%d points per minute';
LNG_ENTER_NAME = 'Please enter your name to get added to the high score lists.';
LNG_GOAL_RED = 'Red stone in target field (%d points)';
LNG_GOAL_YELLOW = 'Yellow stone in target field (%d points)';
LNG_GOAL_GREEN = 'Green stone in target field (%d points)';
LNG_GOAL_MISSED = 'No stone in target field (%d points)';
 
implementation
 
/trunk/ExtraResources.RES
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/ExtraResources.rc
3,7 → 3,8
RedStone BITMAP Private\Resource\RedStone.bmp
EmptyField BITMAP Private\Resource\EmptyField.bmp
 
Finish WAVE Private\Resource\Finish.wav
Win1 WAVE Private\Resource\Win1.wav
Win2 WAVE Private\Resource\Win2.wav
Lose WAVE Private\Resource\Lose.wav
Jump WAVE Private\Resource\Jump.wav
Undo WAVE Private\Resource\Undo.wav
/trunk/Finish.dfm
4,7 → 4,7
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Caption = 'Level finished'
ClientHeight = 290
ClientHeight = 306
ClientWidth = 274
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
90,7 → 90,7
end
object JumpHistoryLink: TLabel
Left = 8
Top = 200
Top = 216
Width = 232
Height = 13
Cursor = crHandPoint
106,7 → 106,7
end
object SaveBtn: TButton
Left = 128
Top = 256
Top = 272
Width = 137
Height = 25
Caption = 'OK'
116,7 → 116,7
end
object CancelBtn: TButton
Left = 8
Top = 256
Top = 272
Width = 89
Height = 25
Cancel = True
135,7 → 135,7
Left = 8
Top = 112
Width = 257
Height = 81
Height = 98
TabStop = False
Color = clBtnFace
ReadOnly = True
143,7 → 143,7
end
object ReplayCheckBox: TCheckBox
Left = 8
Top = 224
Top = 240
Width = 145
Height = 17
Caption = 'Play the same level again'
/trunk/Finish.pas
4,7 → 4,7
 
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, MMSystem, Math, ExtCtrls, Registry;
Dialogs, StdCtrls, MMSystem, Math, ExtCtrls, Registry, Main;
 
type
TFinishForm = class(TForm)
29,12 → 29,12
FStonesRemoved: integer;
FSeconds: integer;
FHistory: TStringList;
procedure Calculate;
FGoalStatus: TGoalStatus;
procedure SaveToJournal(PlayerName: String; Score, StonesTotal, StonesRemoved, Seconds: Integer);
procedure LoadSettings;
public
procedure SaveSettings;
function Execute(LevelName: String; Score, StonesTotal, StonesRemoved, Seconds: Integer; JumpHistory: TStringList): Integer;
function Execute(LevelName: String; Score, StonesTotal, StonesRemoved, Seconds: Integer; GoalStatus: TGoalStatus; JumpHistory: TStringList): Integer;
end;
 
var
43,7 → 43,7
implementation
 
uses
History, Constants;
History, Constants, LevelFunctions;
 
{$R *.dfm}
 
52,26 → 52,49
Close;
end;
 
procedure TFinishForm.Calculate;
function TFinishForm.Execute(LevelName: String; Score, StonesTotal, StonesRemoved, Seconds: Integer; GoalStatus: TGoalStatus; JumpHistory: TStringList): Integer;
var
ExtraPoints: Integer;
begin
PerformanceMemo.Lines.Clear;
PerformanceMemo.Lines.Add(Format(LNG_SCORE, [FScore]));
PerformanceMemo.Lines.Add(Format(LNG_REMAINING, [FStonesTotal - FStonesRemoved,
RoundTo(((FStonesTotal - FStonesRemoved) / FStonesTotal * 100), -2)]));
PerformanceMemo.Lines.Add(Format(LNG_TIME_SECONDS, [FSeconds]));
PerformanceMemo.Lines.Add(Format(LNG_POINTS_PER_MINUTE, [Round(FScore / FSeconds * 60)]));
end;
 
function TFinishForm.Execute(LevelName: String; Score, StonesTotal, StonesRemoved, Seconds: Integer; JumpHistory: TStringList): Integer;
begin
FLevel := LevelName;
FScore := Score;
FStonesTotal := StonesTotal;
FStonesRemoved := StonesRemoved;
FSeconds := Seconds;
FGoalStatus := GoalStatus;
FHistory := JumpHistory;
 
Calculate;
PerformanceMemo.Lines.Clear;
PerformanceMemo.Lines.Add('');
PerformanceMemo.Lines.Add(Format(LNG_REMAINING, [FStonesTotal - 1 - FStonesRemoved,
RoundTo(((FStonesTotal - 1 - FStonesRemoved) / FStonesTotal * 100), -2)]));
PerformanceMemo.Lines.Add(Format(LNG_TIME_SECONDS, [FSeconds]));
PerformanceMemo.Lines.Add(Format(LNG_POINTS_PER_MINUTE, [Round(FScore / FSeconds * 60)]));
 
if FGoalStatus = gsLastStoneInGoalRed then
begin
ExtraPoints := FieldTypeWorth(ftRed) * 100;
PerformanceMemo.Lines.Add(Format(LNG_GOAL_RED, [ExtraPoints]))
end
else if FGoalStatus = gsLastStoneInGoalYellow then
begin
ExtraPoints := FieldTypeWorth(ftYellow) * 100;
PerformanceMemo.Lines.Add(Format(LNG_GOAL_YELLOW, [ExtraPoints]))
end
else if FGoalStatus = gsLastStoneInGoalGreen then
begin
ExtraPoints := FieldTypeWorth(ftGreen) * 100;
PerformanceMemo.Lines.Add(Format(LNG_GOAL_GREEN, [ExtraPoints]))
end
else if FGoalStatus = gsLastStoneOutsideGoal then
begin
ExtraPoints := 0;
PerformanceMemo.Lines.Add(Format(LNG_GOAL_MISSED, [ExtraPoints]))
end;
 
Inc(FScore, ExtraPoints);
PerformanceMemo.Lines.Strings[0] := Format(LNG_SCORE, [FScore]);
 
result := ShowModal;
end;
 
87,7 → 110,10
Append(f)
else
ReWrite(f);
WriteLn(f, Format(JNL_ENTRY, [DateTimeToStr(now()), NameEdit.Text, FScore, FSeconds, FStonesRemoved, FStonesTotal]));
 
// TODO: Maybe we should do much more details, like, how many green stones were removed, how many yellows etc., and which stone was in the goal?
WriteLn(f, Format(JNL_ENTRY, [DateTimeToStr(now()), NameEdit.Text, FScore, FSeconds, FStonesRemoved, FStonesTotal-1]));
 
CloseFile(f);
end;
 
136,13 → 162,10
begin
showmessage(LNG_ENTER_NAME);
NameEdit.SetFocus;
end
else
begin
SaveToJournal(NameEdit.Text, FScore, FStonesTotal, FStonesRemoved, FSeconds);
Close;
Exit;
end;
 
SaveToJournal(NameEdit.Text, FScore, FStonesTotal, FStonesRemoved, FSeconds);
ModalResult := mrOK;
end;
 
/trunk/HighScore.pas
189,11 → 189,15
end;
 
procedure THighScoreForm.ClearBtnClick(Sender: TObject);
resourcestring
LNG_ARE_YOU_SURE = 'Are you really sure you want to clear the high score list?';
begin
// TODO: Benutzer fragen, ob OK
if MessageDlg(LNG_ARE_YOU_SURE, mtConfirmation, mbYesNoCancel) = mrYes then
begin
DeleteFile(Format(JNL_FILE, [FLevelName]));
ClearLists;
end;
end;
 
procedure THighScoreForm.ClearLists;
begin
/trunk/History.dfm
1,8 → 1,8
object HistoryForm: THistoryForm
Left = 192
Top = 103
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsSingle
BorderIcons = [biSystemMenu]
BorderStyle = bsDialog
Caption = 'Jump History'
ClientHeight = 353
ClientWidth = 281
/trunk/LevelFunctions.pas
25,6 → 25,7
function CheckLevelIntegrity(LevelString: string; ShowErrors: boolean): TLevelError; overload;
function CheckLevelIntegrity(LevelString: string): TLevelError; overload;
function LevelStringToLevelArray(LevelString: string; ShowErrors: boolean): TLevelArray;
function FieldTypeWorth(t: TFieldType): integer;
 
var
AllowDiagonalMoves: boolean;
305,4 → 306,12
end;
end;
 
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
else result := 0;
end;
 
end.
/trunk/Main.pas
14,6 → 14,8
Stone: TImage;
end;
 
TGoalStatus = (gsNoGoal, gsMultipleStonesRemaining, gsLastStoneInGoalRed, gsLastStoneInGoalYellow, gsLastStoneInGoalGreen, gsLastStoneOutsideGoal);
 
TFieldState = (fsError, fsLocked, fsAvailable, fsStone);
 
TPlayGroundMatrix = array of array of TField;
99,9 → 101,11
function FieldState(x, y: integer): TFieldState; overload;
procedure ClearMatrix(Matrix: TPlayGroundMatrix; FreeVCL: boolean);
function CloneMatrix(Source: TPlayGroundMatrix): TPlayGroundMatrix;
function MatrixHasGoal(Matrix: TPlayGroundMatrix): boolean;
procedure LoadPictureForType(FieldType: TFieldType; Picture: TPicture);
function MatrixWorth(Matrix: TPlayGroundMatrix): integer;
function FieldTypeWorth(t: TFieldType): integer;
function GoalStatus: TGoalStatus;
function GoalFieldType(Matrix: TPlayGroundMatrix): TFieldType;
end;
 
var
114,6 → 118,33
 
{$R *.dfm}
 
function TMainForm.MatrixHasGoal(Matrix: TPlayGroundMatrix): boolean;
var
i, j: integer;
begin
result := false;
for i := Low(Matrix) to High(Matrix) do
begin
for j := Low(Matrix[i]) to High(Matrix[i]) do
begin
result := result or Matrix[i][j].Goal;
end;
end;
end;
 
function TMainForm.GoalFieldType(Matrix: TPlayGroundMatrix): TFieldType;
var
i, j: integer;
begin
for i := Low(Matrix) to High(Matrix) do
begin
for j := Low(Matrix[i]) to High(Matrix[i]) do
begin
if Matrix[i][j].Goal then result := Matrix[i][j].FieldType
end;
end;
end;
 
function TMainForm.MatrixWorth(Matrix: TPlayGroundMatrix): integer;
var
i, j: integer;
307,14 → 338,6
Statistics.Panels.Items[2].Text := Format(LNG_POINTS, [Points]);
end;
 
function TMainForm.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
else result := 0;
end;
 
procedure TMainForm.CountPoints(t: TFieldType);
begin
inc(Points, FieldTypeWorth(t));
436,12 → 459,17
RefreshTime;
if MEnableSound.Checked then
begin
if LevelRemovedStones = LevelTotalStones then
PlaySound(RES_FINISH, HInstance, SND_ASYNC or SND_NOWAIT or SND_RESOURCE)
if LevelRemovedStones = LevelTotalStones-1 then
begin
if GoalStatus in [gsLastStoneInGoalRed, gsLastStoneInGoalYellow, gsLastStoneInGoalGreen] then
PlaySound(RES_WIN2, HInstance, SND_ASYNC or SND_NOWAIT or SND_RESOURCE)
else
PlaySound(RES_WIN1, HInstance, SND_ASYNC or SND_NOWAIT or SND_RESOURCE)
end
else
PlaySound(RES_LOSE, HInstance, SND_ASYNC or SND_NOWAIT or SND_RESOURCE);
end;
res := FinishForm.Execute(ExtractFileNameWithoutExt(LevelFile), Points, LevelTotalStones, LevelRemovedStones, CountedSeconds, JumpHistory);
res := FinishForm.Execute(ExtractFileNameWithoutExt(LevelFile), Points, LevelTotalStones, LevelRemovedStones, CountedSeconds, GoalStatus, JumpHistory);
if (res = mrOK) and FinishForm.ReplayCheckbox.Checked then RestartLevel;
end;
{$ENDREGION}
659,6 → 687,26
else Close();
end;
 
function TMainForm.GoalStatus: TGoalStatus;
var
ft: TFieldType;
begin
if not MatrixHasGoal(PlaygroundMatrix) then
result := gsNoGoal
else if LevelRemovedStones < LevelTotalStones-1 then
Result := gsMultipleStonesRemaining
else
begin
ft := GoalFieldType(PlaygroundMatrix);
if ft = ftRed then
result := gsLastStoneInGoalRed
else if ft = ftYellow then
result := gsLastStoneInGoalYellow
else if ft = ftGreen then
result := gsLastStoneInGoalGreen;
end;
end;
 
procedure TMainForm.FormCreate(Sender: TObject);
begin
JumpHistory := TStringList.Create;
/trunk/Private/Konzept.txt
4,7 → 4,6
Abstand oben ist größer als links und rechts vom brett
 
ToDo
- zielfeld bei finishform berücksichtigen
- how to play formulieren
- anzeige des aktuellen levels und ob diagonal erlaubt ist
 
17,6 → 16,8
- modal Form blink fehler
- den ausgewählten stein irgendwie farblich markieren?
- abfrage "Möchten Sie das Spiel wirklich beenden?"
- genauere statistik: wie viele grüne, gelbe, rote wurden entfernt etc.
- im finish-form genau zeigen, wie sich die punktzahl zusammensetzt (grün+gelb+rot+goal)
 
Zukunft
- hervorheben von gültigen feldern (conf)
/trunk/Private/Resource/Finish.wav
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/trunk/Private/Resource/Win1.wav
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/Private/Resource/Win2.wav
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/deu/PegSolitaire_DEU.bdsproj
28,7 → 28,8
<Options Name="Evidence"></Options>
<Options Name="KeyFile"></Options>
<Options Name="KeyName"></Options>
</Options> <FileList>
</Options>
<FileList>
<File FileName="About.dfm" ContainerId="W32Form" ModuleName="About.dfm"/>
<File FileName="Choice.dfm" ContainerId="W32Form" ModuleName="Choice.dfm"/>
<File FileName="Finish.dfm" ContainerId="W32Form" ModuleName="Finish.dfm"/>
/trunk/deu/PegSolitaire_DRC.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream