summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-09-30 21:29:21 +0200
committerErich Eckner <git@eckner.net>2018-09-30 21:29:21 +0200
commitd81c2373be6697e2ebcfd082831115c4f182b6a0 (patch)
tree87f7c58fa15a5057bccbf2ffd206016236faa491
parentaba523b2d0815b4d900b387044abda19995c0973 (diff)
downloadRaetsel-d81c2373be6697e2ebcfd082831115c4f182b6a0.tar.xz
buchstabenunit.pas & hochhausunit.pas neu
-rw-r--r--buchstabenunit.pas108
-rw-r--r--hochhausunit.pas82
-rw-r--r--raetsel.lpi10
-rw-r--r--raetsel.lpr2
-rw-r--r--raetsel.lps131
-rw-r--r--raetselunit.pas160
-rw-r--r--unit1.lfm2
-rw-r--r--unit1.pas2
8 files changed, 277 insertions, 220 deletions
diff --git a/buchstabenunit.pas b/buchstabenunit.pas
new file mode 100644
index 0000000..718a70d
--- /dev/null
+++ b/buchstabenunit.pas
@@ -0,0 +1,108 @@
+unit buchstabenunit;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, raetselunit, Forms;
+
+type
+ tBuchstabenRaetsel = class(tFelderRaetsel)
+ private
+ procedure relativeInhaltsAenderung(diff: longint); override;
+ function absoluteInhaltsAenderung(key: word): boolean; override;
+ public
+ constructor create(aOwner: tForm);
+ destructor destroy; override;
+ function _loesen(lm: tFelderLoesMeta): longint; override;
+ end;
+
+function buchstabenAlphabetFunktion(i: longint): string;
+
+implementation
+
+uses
+ math;
+
+function buchstabenAlphabetFunktion(i: longint): string;
+begin
+ if i<0 then
+ result:=''
+ else if i=0 then
+ result:='-'
+ else begin
+ result:='';
+ while i>0 do begin
+ dec(i);
+ result:=char(ord('A')+(i mod 26))+result;
+ i:=i div 26;
+ end;
+ end;
+end;
+
+// tBuchstabenRaetsel **********************************************************
+
+constructor tBuchstabenRaetsel.create(aOwner: tForm);
+begin
+ inherited create(aOwner,2,@buchstabenAlphabetFunktion);
+ spinEdits[1].showHint:=true;
+ spinEdits[1].hint:='Anzahl Buchstaben';
+ spinEdits[1].value:=5;
+ spinEdits[2].showHint:=true;
+ spinEdits[2].hint:='Anzahl Leerfelder';
+ spinEdits[2].value:=1;
+ aktualisiereGroesze;
+end;
+
+destructor tBuchstabenRaetsel.destroy;
+begin
+ inherited destroy;
+end;
+
+procedure tBuchstabenRaetsel.relativeInhaltsAenderung(diff: longint);
+begin
+ if (cursorPosition<0) or (cursorPosition>=dim*dim) then exit;
+ inhalt[cursorPosition]:=min(max(-1,inhalt[cursorPosition]+diff),groeszen[0]);
+end;
+
+function tBuchstabenRaetsel.absoluteInhaltsAenderung(key: word): boolean;
+begin
+ result:=true;
+ if (key>=ord('A')) and (key<=min(ord('A')+groeszen[0]-1,ord('Z'))) then begin
+ inhalt[cursorPosition]:=key-ord('A')+1;
+ exit;
+ end;
+ if (key=ord(' ')) or (key=46) or (key=8) then begin
+ inhalt[cursorPosition]:=-1;
+ exit;
+ end;
+ if (key=189) then begin
+ inhalt[cursorPosition]:=0;
+ exit;
+ end;
+ result:=false;
+end;
+
+function tBuchstabenRaetsel._loesen(lm: tFelderLoesMeta): longint;
+begin
+ if not lm.fwd then begin
+ result:=1;
+ exit;
+ end;
+ if inhalt[lm.posi]>=0 then begin
+ result:=_loesen(lm);
+ exit;
+ end;
+
+ result:=0;
+ //for
+
+ if not lm.inhaltBehalten then begin
+ inhalt[lm.posi]:=-1;
+ lm.aktualisiereInhalt(lm.posi);
+ end;
+end;
+
+end.
+
diff --git a/hochhausunit.pas b/hochhausunit.pas
new file mode 100644
index 0000000..7a98f6a
--- /dev/null
+++ b/hochhausunit.pas
@@ -0,0 +1,82 @@
+unit hochhausunit;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, raetselunit, Forms;
+
+type
+ tHochhausRaetsel = class(tFelderRaetsel)
+ private
+ procedure relativeInhaltsAenderung(diff: longint); override;
+ function absoluteInhaltsAenderung(key: word): boolean; override;
+ public
+ constructor create(aOwner: tForm);
+ destructor destroy; override;
+ function _loesen(lm: tFelderLoesMeta): longint; override;
+ end;
+
+function zahlenAlphabetFunktion(i: longint): string;
+
+implementation
+
+uses
+ math;
+
+function zahlenAlphabetFunktion(i: longint): string;
+begin
+ if i<0 then
+ result:=''
+ else if i=0 then
+ result:='-'
+ else
+ result:=inttostr(i);
+end;
+
+// tHochhausRaetsel ************************************************************
+
+constructor tHochhausRaetsel.create(aOwner: tForm);
+begin
+ inherited create(aOwner,1,@zahlenAlphabetFunktion);
+ spinEdits[1].showHint:=true;
+ spinEdits[1].hint:='Anzahl Spalten';
+ spinEdits[1].value:=5;
+ aktualisiereGroesze;
+end;
+
+destructor tHochhausRaetsel.destroy;
+begin
+ inherited destroy;
+end;
+
+procedure tHochhausRaetsel.relativeInhaltsAenderung(diff: longint);
+begin
+ if (cursorPosition<0) or (cursorPosition>=dim*dim) then exit;
+ if inhalt[cursorPosition]=-1 then inhalt[cursorPosition]:=0;
+ inhalt[cursorPosition]:=min(max(0,inhalt[cursorPosition]+diff),groeszen[0]);
+ if inhalt[cursorPosition]=0 then inhalt[cursorPosition]:=-1;
+end;
+
+function tHochhausRaetsel.absoluteInhaltsAenderung(key: word): boolean;
+begin
+ result:=true;
+ if (key>=ord('1')) and (key<=min(ord('1')+groeszen[0]-1,ord('9'))) then begin
+ inhalt[cursorPosition]:=key-ord('1')+1;
+ exit;
+ end;
+ if (key=ord(' ')) or (key=46) or (key=8) then begin
+ inhalt[cursorPosition]:=-1;
+ exit;
+ end;
+ result:=false;
+end;
+
+function tHochhausRaetsel._loesen(lm: tFelderLoesMeta): longint;
+begin
+
+end;
+
+end.
+
diff --git a/raetsel.lpi b/raetsel.lpi
index 618272c..0b62fb2 100644
--- a/raetsel.lpi
+++ b/raetsel.lpi
@@ -29,7 +29,7 @@
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
- <Units Count="4">
+ <Units Count="6">
<Unit0>
<Filename Value="raetsel.lpr"/>
<IsPartOfProject Value="True"/>
@@ -53,6 +53,14 @@
<Filename Value="raetselunit.pas"/>
<IsPartOfProject Value="True"/>
</Unit3>
+ <Unit4>
+ <Filename Value="buchstabenunit.pas"/>
+ <IsPartOfProject Value="True"/>
+ </Unit4>
+ <Unit5>
+ <Filename Value="hochhausunit.pas"/>
+ <IsPartOfProject Value="True"/>
+ </Unit5>
</Units>
</ProjectOptions>
<CompilerOptions>
diff --git a/raetsel.lpr b/raetsel.lpr
index 839a24b..92f798f 100644
--- a/raetsel.lpr
+++ b/raetsel.lpr
@@ -7,7 +7,7 @@ uses
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
- Forms, unit1, Unit2, raetselunit
+ Forms, unit1, Unit2, raetselunit, buchstabenunit, hochhausunit
{ you can add units after this };
{$R *.res}
diff --git a/raetsel.lps b/raetsel.lps
index 3b8bb0d..9ca4488 100644
--- a/raetsel.lps
+++ b/raetsel.lps
@@ -3,13 +3,13 @@
<ProjectSession>
<Version Value="10"/>
<BuildModes Active="Default"/>
- <Units Count="11">
+ <Units Count="13">
<Unit0>
<Filename Value="raetsel.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos Y="18"/>
- <UsageCount Value="38"/>
+ <UsageCount Value="39"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
@@ -17,9 +17,9 @@
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
- <TopLine Value="21"/>
- <CursorPos X="48" Y="40"/>
- <UsageCount Value="38"/>
+ <TopLine Value="10"/>
+ <CursorPos X="38" Y="34"/>
+ <UsageCount Value="39"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@@ -30,20 +30,19 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit2"/>
- <EditorIndex Value="3"/>
+ <EditorIndex Value="4"/>
<CursorPos X="20" Y="12"/>
- <UsageCount Value="37"/>
+ <UsageCount Value="38"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit2>
<Unit3>
<Filename Value="raetselunit.pas"/>
<IsPartOfProject Value="True"/>
- <IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
- <TopLine Value="218"/>
- <CursorPos X="30" Y="242"/>
- <UsageCount Value="32"/>
+ <TopLine Value="22"/>
+ <CursorPos Y="51"/>
+ <UsageCount Value="33"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
@@ -92,132 +91,148 @@
</Unit9>
<Unit10>
<Filename Value="../units/lowlevelunit.pas"/>
- <EditorIndex Value="2"/>
+ <EditorIndex Value="-1"/>
<TopLine Value="1187"/>
<CursorPos Y="1209"/>
<UsageCount Value="10"/>
- <Loaded Value="True"/>
</Unit10>
+ <Unit11>
+ <Filename Value="buchstabenunit.pas"/>
+ <IsPartOfProject Value="True"/>
+ <IsVisibleTab Value="True"/>
+ <EditorIndex Value="3"/>
+ <TopLine Value="8"/>
+ <CursorPos X="8" Y="26"/>
+ <UsageCount Value="20"/>
+ <Loaded Value="True"/>
+ </Unit11>
+ <Unit12>
+ <Filename Value="hochhausunit.pas"/>
+ <IsPartOfProject Value="True"/>
+ <EditorIndex Value="2"/>
+ <CursorPos X="36" Y="8"/>
+ <UsageCount Value="20"/>
+ <Loaded Value="True"/>
+ </Unit12>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="241" TopLine="218"/>
+ <Filename Value="hochhausunit.pas"/>
+ <Caret Line="65"/>
</Position1>
<Position2>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="243" TopLine="218"/>
+ <Filename Value="hochhausunit.pas"/>
+ <Caret Line="21"/>
</Position2>
<Position3>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="246" TopLine="218"/>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="8" Column="76"/>
</Position3>
<Position4>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="247" TopLine="218"/>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="34" Column="38" TopLine="10"/>
</Position4>
<Position5>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="248" TopLine="218"/>
+ <Filename Value="hochhausunit.pas"/>
+ <Caret Line="8" Column="33"/>
</Position5>
<Position6>
<Filename Value="raetselunit.pas"/>
- <Caret Line="249" TopLine="218"/>
+ <Caret Line="84" TopLine="62"/>
</Position6>
<Position7>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="250" TopLine="218"/>
+ <Filename Value="hochhausunit.pas"/>
+ <Caret Line="8" Column="40"/>
</Position7>
<Position8>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="251" TopLine="218"/>
+ <Filename Value="hochhausunit.pas"/>
+ <Caret Line="15" Column="21"/>
</Position8>
<Position9>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="252" TopLine="218"/>
+ <Filename Value="buchstabenunit.pas"/>
+ <Caret Line="21"/>
</Position9>
<Position10>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="253" TopLine="218"/>
+ <Filename Value="buchstabenunit.pas"/>
+ <Caret Line="84" Column="36" TopLine="62"/>
</Position10>
<Position11>
<Filename Value="raetselunit.pas"/>
- <Caret Line="254" TopLine="218"/>
</Position11>
<Position12>
<Filename Value="raetselunit.pas"/>
- <Caret Line="255" TopLine="219"/>
+ <Caret Line="46" Column="21" TopLine="31"/>
</Position12>
<Position13>
<Filename Value="raetselunit.pas"/>
- <Caret Line="256" TopLine="220"/>
+ <Caret Line="330" Column="18" TopLine="294"/>
</Position13>
<Position14>
<Filename Value="raetselunit.pas"/>
- <Caret Line="327" TopLine="299"/>
+ <Caret Line="349" Column="15" TopLine="325"/>
</Position14>
<Position15>
<Filename Value="raetselunit.pas"/>
- <Caret Line="328" TopLine="299"/>
+ <Caret Line="366" Column="11" TopLine="325"/>
</Position15>
<Position16>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="329" TopLine="299"/>
+ <Filename Value="hochhausunit.pas"/>
+ <Caret Line="15" Column="14"/>
</Position16>
<Position17>
<Filename Value="raetselunit.pas"/>
- <Caret Line="256" TopLine="249"/>
+ <Caret Line="54" Column="3" TopLine="47"/>
</Position17>
<Position18>
<Filename Value="raetselunit.pas"/>
- <Caret Line="329" TopLine="307"/>
+ <Caret Line="330" Column="18" TopLine="294"/>
</Position18>
<Position19>
<Filename Value="raetselunit.pas"/>
- <Caret Line="359" TopLine="349"/>
+ <Caret Line="349" Column="15" TopLine="328"/>
</Position19>
<Position20>
<Filename Value="raetselunit.pas"/>
- <Caret Line="360" TopLine="349"/>
+ <Caret Line="361" Column="15" TopLine="328"/>
</Position20>
<Position21>
<Filename Value="raetselunit.pas"/>
- <Caret Line="329" TopLine="223"/>
</Position21>
<Position22>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="57" Column="13" TopLine="35"/>
+ <Filename Value="hochhausunit.pas"/>
+ <Caret Line="15" Column="14"/>
</Position22>
<Position23>
<Filename Value="raetselunit.pas"/>
- <Caret Line="230" Column="21" TopLine="221"/>
+ <Caret Line="46" Column="55" TopLine="28"/>
</Position23>
<Position24>
<Filename Value="raetselunit.pas"/>
- <Caret Line="244" Column="15" TopLine="221"/>
+ <Caret Line="91" Column="16" TopLine="69"/>
</Position24>
<Position25>
<Filename Value="raetselunit.pas"/>
- <Caret Line="271" Column="50" TopLine="247"/>
+ <Caret Line="46" Column="53" TopLine="12"/>
</Position25>
<Position26>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="323" Column="30" TopLine="293"/>
+ <Filename Value="hochhausunit.pas"/>
+ <Caret Line="19"/>
</Position26>
<Position27>
- <Filename Value="raetselunit.pas"/>
+ <Filename Value="buchstabenunit.pas"/>
+ <Caret Line="91" Column="20" TopLine="62"/>
</Position27>
<Position28>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="57" Column="13" TopLine="21"/>
+ <Filename Value="buchstabenunit.pas"/>
+ <Caret Line="19"/>
</Position28>
<Position29>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="230" Column="21" TopLine="215"/>
+ <Filename Value="hochhausunit.pas"/>
+ <Caret Line="26" Column="8"/>
</Position29>
<Position30>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="246" Column="23" TopLine="218"/>
+ <Filename Value="hochhausunit.pas"/>
+ <Caret Line="8" Column="36"/>
</Position30>
</JumpHistory>
</ProjectSession>
diff --git a/raetselunit.pas b/raetselunit.pas
index a5c63d5..2d60340 100644
--- a/raetselunit.pas
+++ b/raetselunit.pas
@@ -43,11 +43,11 @@ type
procedure erzeugeOnClick(sender: tObject);
procedure loeschen; dynamic; abstract;
function loesen(inhaltBehalten: boolean): longint; dynamic; abstract;
- function _loesen(lm: tFelderLoesMeta): longint; dynamic; abstract;
procedure leeren; dynamic; abstract;
public
constructor create(aOwner: tForm);
destructor destroy; override;
+ function _loesen(lm: tFelderLoesMeta): longint; dynamic; abstract;
procedure zeichnen; dynamic; abstract;
end;
@@ -78,32 +78,9 @@ type
procedure zeichnen; override;
end;
- tBuchstabenRaetsel = class(tFelderRaetsel)
- private
- procedure relativeInhaltsAenderung(diff: longint); override;
- function absoluteInhaltsAenderung(key: word): boolean; override;
- function _loesen(lm: tFelderLoesMeta): longint; override;
- public
- constructor create(aOwner: tForm);
- destructor destroy; override;
- end;
-
- tHochhausRaetsel = class(tFelderRaetsel)
- private
- procedure relativeInhaltsAenderung(diff: longint); override;
- function absoluteInhaltsAenderung(key: word): boolean; override;
- function _loesen(lm: tFelderLoesMeta): longint; override;
- public
- constructor create(aOwner: tForm);
- destructor destroy; override;
- end;
-
const
spacing = 2;
-function buchstabenAlphabetFunktion(i: longint): string;
-function zahlenAlphabetFunktion(i: longint): string;
-
implementation
uses
@@ -386,6 +363,7 @@ begin
lm.aktualisiereRand(p[i]);
end;
end;
+ lm.free;
end;
procedure tFelderRaetsel.aktualisiereZeichenflaechenGroesze;
@@ -473,139 +451,5 @@ begin
schreibeZentriert(i mod dim,i div dim,inhalt[i]);
end;
-// tBuchstabenRaetsel **********************************************************
-
-constructor tBuchstabenRaetsel.create(aOwner: tForm);
-begin
- inherited create(aOwner,2,@buchstabenAlphabetFunktion);
- spinEdits[1].showHint:=true;
- spinEdits[1].hint:='Anzahl Buchstaben';
- spinEdits[1].value:=5;
- spinEdits[2].showHint:=true;
- spinEdits[2].hint:='Anzahl Leerfelder';
- spinEdits[2].value:=1;
- aktualisiereGroesze;
-end;
-
-destructor tBuchstabenRaetsel.destroy;
-begin
- inherited destroy;
-end;
-
-procedure tBuchstabenRaetsel.relativeInhaltsAenderung(diff: longint);
-begin
- if (cursorPosition<0) or (cursorPosition>=dim*dim) then exit;
- inhalt[cursorPosition]:=min(max(-1,inhalt[cursorPosition]+diff),groeszen[0]);
-end;
-
-function tBuchstabenRaetsel.absoluteInhaltsAenderung(key: word): boolean;
-begin
- result:=true;
- if (key>=ord('A')) and (key<=min(ord('A')+groeszen[0]-1,ord('Z'))) then begin
- inhalt[cursorPosition]:=key-ord('A')+1;
- exit;
- end;
- if (key=ord(' ')) or (key=46) or (key=8) then begin
- inhalt[cursorPosition]:=-1;
- exit;
- end;
- if (key=189) then begin
- inhalt[cursorPosition]:=0;
- exit;
- end;
- result:=false;
-end;
-
-function tBuchstabenRaetsel._loesen(lm: tFelderLoesMeta): longint;
-begin
- if not lm.fwd then begin
- result:=1;
- exit;
- end;
- if inhalt[lm.posi]>=0 then begin
- result:=_loesen(lm);
- exit;
- end;
-
- result:=0;
- //for
-
- if not lm.inhaltBehalten then begin
- inhalt[lm.posi]:=-1;
- lm.aktualisiereInhalt(lm.posi);
- end;
-end;
-
-// tHochhausRaetsel ************************************************************
-
-constructor tHochhausRaetsel.create(aOwner: tForm);
-begin
- inherited create(aOwner,1,@zahlenAlphabetFunktion);
- spinEdits[1].showHint:=true;
- spinEdits[1].hint:='Anzahl Spalten';
- spinEdits[1].value:=5;
- aktualisiereGroesze;
-end;
-
-destructor tHochhausRaetsel.destroy;
-begin
- inherited destroy;
-end;
-
-procedure tHochhausRaetsel.relativeInhaltsAenderung(diff: longint);
-begin
- if (cursorPosition<0) or (cursorPosition>=dim*dim) then exit;
- if inhalt[cursorPosition]=-1 then inhalt[cursorPosition]:=0;
- inhalt[cursorPosition]:=min(max(0,inhalt[cursorPosition]+diff),groeszen[0]);
- if inhalt[cursorPosition]=0 then inhalt[cursorPosition]:=-1;
-end;
-
-function tHochhausRaetsel.absoluteInhaltsAenderung(key: word): boolean;
-begin
- result:=true;
- if (key>=ord('1')) and (key<=min(ord('1')+groeszen[0]-1,ord('9'))) then begin
- inhalt[cursorPosition]:=key-ord('1')+1;
- exit;
- end;
- if (key=ord(' ')) or (key=46) or (key=8) then begin
- inhalt[cursorPosition]:=-1;
- exit;
- end;
- result:=false;
-end;
-
-function tHochhausRaetsel._loesen(lm: tFelderLoesMeta): longint;
-begin
-
-end;
-
-// allgemeine Funktionen *******************************************************
-
-function buchstabenAlphabetFunktion(i: longint): string;
-begin
- if i<0 then
- result:=''
- else if i=0 then
- result:='-'
- else begin
- result:='';
- while i>0 do begin
- dec(i);
- result:=char(ord('A')+(i mod 26))+result;
- i:=i div 26;
- end;
- end;
-end;
-
-function zahlenAlphabetFunktion(i: longint): string;
-begin
- if i<0 then
- result:=''
- else if i=0 then
- result:='-'
- else
- result:=inttostr(i);
-end;
-
end.
diff --git a/unit1.lfm b/unit1.lfm
index 9d5b43d..e06801d 100644
--- a/unit1.lfm
+++ b/unit1.lfm
@@ -8,5 +8,5 @@ object Form1: TForm1
OnCreate = FormCreate
OnDestroy = FormDestroy
OnShow = FormShow
- LCLVersion = '1.6.0.4'
+ LCLVersion = '1.8.4.0'
end
diff --git a/unit1.pas b/unit1.pas
index 795ecf3..d9e333a 100644
--- a/unit1.pas
+++ b/unit1.pas
@@ -31,7 +31,7 @@ implementation
{$R *.lfm}
uses
- unit2;
+ unit2, hochhausunit, buchstabenunit;
// tForm1 **********************************************************************