/trunk/Constants.pas |
---|
19,8 → 19,7 |
// Resourcennamen |
RES_JUMP = 'Jump'; |
RES_UNDO = 'Undo'; |
RES_WIN1 = 'Win1'; |
RES_WIN2 = 'Win2'; |
RES_FINISH = 'Finish'; |
RES_LOSE = 'Lose'; |
RES_EMPTY = 'EmptyField'; |
RES_GREEN = 'GreenStone'; |
58,10 → 57,6 |
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,8 → 3,7 |
RedStone BITMAP Private\Resource\RedStone.bmp |
EmptyField BITMAP Private\Resource\EmptyField.bmp |
Win1 WAVE Private\Resource\Win1.wav |
Win2 WAVE Private\Resource\Win2.wav |
Finish WAVE Private\Resource\Finish.wav |
Lose WAVE Private\Resource\Lose.wav |
Jump WAVE Private\Resource\Jump.wav |
Undo WAVE Private\Resource\Undo.wav |
/trunk/Main.pas |
---|
14,8 → 14,6 |
Stone: TImage; |
end; |
TGoalStatus = (gsNoGoal, gsMultipleStonesRemaining, gsLastStoneInGoalRed, gsLastStoneInGoalYellow, gsLastStoneInGoalGreen, gsLastStoneOutsideGoal); |
TFieldState = (fsError, fsLocked, fsAvailable, fsStone); |
TPlayGroundMatrix = array of array of TField; |
101,11 → 99,9 |
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 GoalStatus: TGoalStatus; |
function GoalFieldType(Matrix: TPlayGroundMatrix): TFieldType; |
function FieldTypeWorth(t: TFieldType): integer; |
end; |
var |
118,33 → 114,6 |
{$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; |
338,6 → 307,14 |
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)); |
459,17 → 436,12 |
RefreshTime; |
if MEnableSound.Checked then |
begin |
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) |
if LevelRemovedStones = LevelTotalStones then |
PlaySound(RES_FINISH, 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, GoalStatus, JumpHistory); |
res := FinishForm.Execute(ExtractFileNameWithoutExt(LevelFile), Points, LevelTotalStones, LevelRemovedStones, CountedSeconds, JumpHistory); |
if (res = mrOK) and FinishForm.ReplayCheckbox.Checked then RestartLevel; |
end; |
{$ENDREGION} |
687,26 → 659,6 |
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,6 → 4,7 |
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 |
16,8 → 17,6 |
- 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/Win1.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/Win2.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/Finish.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,8 → 28,7 |
<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 |
/trunk/HighScore.pas |
---|
189,15 → 189,11 |
end; |
procedure THighScoreForm.ClearBtnClick(Sender: TObject); |
resourcestring |
LNG_ARE_YOU_SURE = 'Are you really sure you want to clear the high score list?'; |
begin |
if MessageDlg(LNG_ARE_YOU_SURE, mtConfirmation, mbYesNoCancel) = mrYes then |
begin |
// TODO: Benutzer fragen, ob OK |
DeleteFile(Format(JNL_FILE, [FLevelName])); |
ClearLists; |
end; |
end; |
procedure THighScoreForm.ClearLists; |
begin |
/trunk/Finish.pas |
---|
4,7 → 4,7 |
uses |
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, |
Dialogs, StdCtrls, MMSystem, Math, ExtCtrls, Registry, Main; |
Dialogs, StdCtrls, MMSystem, Math, ExtCtrls, Registry; |
type |
TFinishForm = class(TForm) |
29,12 → 29,12 |
FStonesRemoved: integer; |
FSeconds: integer; |
FHistory: TStringList; |
FGoalStatus: TGoalStatus; |
procedure Calculate; |
procedure SaveToJournal(PlayerName: String; Score, StonesTotal, StonesRemoved, Seconds: Integer); |
procedure LoadSettings; |
public |
procedure SaveSettings; |
function Execute(LevelName: String; Score, StonesTotal, StonesRemoved, Seconds: Integer; GoalStatus: TGoalStatus; JumpHistory: TStringList): Integer; |
function Execute(LevelName: String; Score, StonesTotal, StonesRemoved, Seconds: Integer; JumpHistory: TStringList): Integer; |
end; |
var |
43,7 → 43,7 |
implementation |
uses |
History, Constants, LevelFunctions; |
History, Constants; |
{$R *.dfm} |
52,49 → 52,26 |
Close; |
end; |
function TFinishForm.Execute(LevelName: String; Score, StonesTotal, StonesRemoved, Seconds: Integer; GoalStatus: TGoalStatus; JumpHistory: TStringList): Integer; |
var |
ExtraPoints: Integer; |
procedure TFinishForm.Calculate; |
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; |
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]); |
Calculate; |
result := ShowModal; |
end; |
110,10 → 87,7 |
Append(f) |
else |
ReWrite(f); |
// 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])); |
WriteLn(f, Format(JNL_ENTRY, [DateTimeToStr(now()), NameEdit.Text, FScore, FSeconds, FStonesRemoved, FStonesTotal])); |
CloseFile(f); |
end; |
162,10 → 136,13 |
begin |
showmessage(LNG_ENTER_NAME); |
NameEdit.SetFocus; |
Exit; |
end |
else |
begin |
SaveToJournal(NameEdit.Text, FScore, FStonesTotal, FStonesRemoved, FSeconds); |
Close; |
end; |
SaveToJournal(NameEdit.Text, FScore, FStonesTotal, FStonesRemoved, FSeconds); |
ModalResult := mrOK; |
end; |
/trunk/LevelFunctions.pas |
---|
25,7 → 25,6 |
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; |
306,12 → 305,4 |
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/Finish.dfm |
---|
4,7 → 4,7 |
BorderIcons = [biSystemMenu] |
BorderStyle = bsSingle |
Caption = 'Level finished' |
ClientHeight = 306 |
ClientHeight = 290 |
ClientWidth = 274 |
Color = clBtnFace |
Font.Charset = DEFAULT_CHARSET |
90,7 → 90,7 |
end |
object JumpHistoryLink: TLabel |
Left = 8 |
Top = 216 |
Top = 200 |
Width = 232 |
Height = 13 |
Cursor = crHandPoint |
106,7 → 106,7 |
end |
object SaveBtn: TButton |
Left = 128 |
Top = 272 |
Top = 256 |
Width = 137 |
Height = 25 |
Caption = 'OK' |
116,7 → 116,7 |
end |
object CancelBtn: TButton |
Left = 8 |
Top = 272 |
Top = 256 |
Width = 89 |
Height = 25 |
Cancel = True |
135,7 → 135,7 |
Left = 8 |
Top = 112 |
Width = 257 |
Height = 98 |
Height = 81 |
TabStop = False |
Color = clBtnFace |
ReadOnly = True |
143,7 → 143,7 |
end |
object ReplayCheckBox: TCheckBox |
Left = 8 |
Top = 240 |
Top = 224 |
Width = 145 |
Height = 17 |
Caption = 'Play the same level again' |
/trunk/History.dfm |
---|
1,8 → 1,8 |
object HistoryForm: THistoryForm |
Left = 192 |
Top = 103 |
BorderIcons = [biSystemMenu] |
BorderStyle = bsDialog |
BorderIcons = [biSystemMenu, biMinimize] |
BorderStyle = bsSingle |
Caption = 'Jump History' |
ClientHeight = 353 |
ClientWidth = 281 |