diff options
author | Erich Eckner <git@eckner.net> | 2018-09-29 11:44:12 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-09-29 11:44:12 +0200 |
commit | ca79f7d3720b106b14c50712a942611dfc09b198 (patch) | |
tree | f7d9c1bd4b4d938e0229e3c2cb9fd23d1f37eba6 | |
parent | af27d71dff86ca1f21a242f05b00852f3fa59e2f (diff) | |
download | Raetsel-ca79f7d3720b106b14c50712a942611dfc09b198.tar.xz |
alter Stand
-rw-r--r-- | raetsel.lps | 109 | ||||
-rw-r--r-- | raetselunit.pas | 323 | ||||
-rw-r--r-- | unit2.lfm | 2 |
3 files changed, 358 insertions, 76 deletions
diff --git a/raetsel.lps b/raetsel.lps index 0cfa3ac..fc7dde7 100644 --- a/raetsel.lps +++ b/raetsel.lps @@ -3,13 +3,13 @@ <ProjectSession> <Version Value="9"/> <BuildModes Active="Default"/> - <Units Count="10"> + <Units Count="11"> <Unit0> <Filename Value="raetsel.lpr"/> <IsPartOfProject Value="True"/> <EditorIndex Value="-1"/> <CursorPos Y="18"/> - <UsageCount Value="35"/> + <UsageCount Value="38"/> </Unit0> <Unit1> <Filename Value="unit1.pas"/> @@ -18,8 +18,8 @@ <HasResources Value="True"/> <ResourceBaseClass Value="Form"/> <TopLine Value="21"/> - <CursorPos Y="61"/> - <UsageCount Value="35"/> + <CursorPos X="48" Y="43"/> + <UsageCount Value="38"/> <Loaded Value="True"/> <LoadedDesigner Value="True"/> </Unit1> @@ -30,31 +30,41 @@ <HasResources Value="True"/> <ResourceBaseClass Value="Form"/> <UnitName Value="Unit2"/> - <EditorIndex Value="2"/> + <EditorIndex Value="3"/> <CursorPos X="20" Y="12"/> - <UsageCount Value="34"/> + <UsageCount Value="37"/> <Loaded Value="True"/> <LoadedDesigner Value="True"/> </Unit2> <Unit3> + <Filename Value="raetselunit.pas"/> + <IsPartOfProject Value="True"/> + <IsVisibleTab Value="True"/> + <EditorIndex Value="1"/> + <TopLine Value="95"/> + <CursorPos X="42" Y="120"/> + <UsageCount Value="32"/> + <Loaded Value="True"/> + </Unit3> + <Unit4> <Filename Value="Unit1.pas"/> <EditorIndex Value="-1"/> <CursorPos X="3" Y="17"/> <UsageCount Value="9"/> - </Unit3> - <Unit4> + </Unit4> + <Unit5> <Filename Value="RaetselFileUnit.pas"/> <UnitName Value="raetselFileUnit"/> <EditorIndex Value="-1"/> <UsageCount Value="9"/> - </Unit4> - <Unit5> + </Unit5> + <Unit6> <Filename Value="raetselFileUnit.pas"/> <EditorIndex Value="-1"/> <CursorPos X="28" Y="11"/> <UsageCount Value="9"/> - </Unit5> - <Unit6> + </Unit6> + <Unit7> <Filename Value="ori_Unit1.pas"/> <ComponentName Value="Form1"/> <HasResources Value="True"/> @@ -63,16 +73,6 @@ <EditorIndex Value="-1"/> <CursorPos X="15" Y="13"/> <UsageCount Value="9"/> - </Unit6> - <Unit7> - <Filename Value="raetselunit.pas"/> - <IsPartOfProject Value="True"/> - <IsVisibleTab Value="True"/> - <EditorIndex Value="1"/> - <TopLine Value="157"/> - <CursorPos X="37" Y="170"/> - <UsageCount Value="29"/> - <Loaded Value="True"/> </Unit7> <Unit8> <Filename Value="/usr/share/lazarus/lcl/stdctrls.pp"/> @@ -90,124 +90,133 @@ <CursorPos X="10" Y="509"/> <UsageCount Value="10"/> </Unit9> + <Unit10> + <Filename Value="../units/lowlevelunit.pas"/> + <EditorIndex Value="2"/> + <TopLine Value="78"/> + <CursorPos X="10" Y="100"/> + <UsageCount Value="10"/> + <Loaded Value="True"/> + </Unit10> </Units> <JumpHistory Count="30" HistoryIndex="29"> <Position1> <Filename Value="raetselunit.pas"/> - <Caret Line="155" Column="45" TopLine="120"/> + <Caret Line="276" Column="12" TopLine="255"/> </Position1> <Position2> <Filename Value="raetselunit.pas"/> + <Caret Line="437" Column="97" TopLine="408"/> </Position2> <Position3> <Filename Value="raetselunit.pas"/> - <Caret Line="29" Column="13"/> </Position3> <Position4> - <Filename Value="raetselunit.pas"/> - <Caret Line="122" Column="39" TopLine="86"/> + <Filename Value="unit1.pas"/> + <Caret Line="61" TopLine="21"/> </Position4> <Position5> <Filename Value="raetselunit.pas"/> - <Caret Line="134" Column="15" TopLine="99"/> + <Caret Line="27" Column="14" TopLine="5"/> </Position5> <Position6> <Filename Value="raetselunit.pas"/> - <Caret Line="155" Column="45" TopLine="119"/> + <Caret Line="74" TopLine="34"/> </Position6> <Position7> <Filename Value="raetselunit.pas"/> - <Caret Line="167" Column="24" TopLine="131"/> + <Caret Line="486" TopLine="392"/> </Position7> <Position8> <Filename Value="raetselunit.pas"/> + <Caret Line="44" TopLine="43"/> </Position8> <Position9> <Filename Value="raetselunit.pas"/> - <Caret Line="31" Column="25"/> + <Caret Line="402" TopLine="377"/> </Position9> <Position10> <Filename Value="raetselunit.pas"/> - <Caret Line="135" Column="18" TopLine="102"/> + <Caret Line="75" Column="14" TopLine="42"/> </Position10> <Position11> <Filename Value="raetselunit.pas"/> - <Caret Line="161" Column="26" TopLine="147"/> + <Caret Line="27" Column="21" TopLine="5"/> </Position11> <Position12> <Filename Value="raetselunit.pas"/> + <Caret Line="66" TopLine="29"/> </Position12> <Position13> <Filename Value="raetselunit.pas"/> - <Caret Line="31" Column="25"/> + <Caret Line="75" Column="21" TopLine="39"/> </Position13> <Position14> <Filename Value="raetselunit.pas"/> - <Caret Line="29" Column="13"/> + <Caret Line="278" Column="18" TopLine="242"/> </Position14> <Position15> <Filename Value="raetselunit.pas"/> - <Caret Line="121" Column="41" TopLine="85"/> + <Caret Line="291" Column="15" TopLine="255"/> </Position15> <Position16> <Filename Value="raetselunit.pas"/> - <Caret Line="133" Column="10" TopLine="97"/> + <Caret Line="39" Column="55" TopLine="19"/> </Position16> <Position17> <Filename Value="raetselunit.pas"/> - <Caret Line="121" TopLine="98"/> + <Caret Line="26" Column="20" TopLine="18"/> </Position17> <Position18> <Filename Value="raetselunit.pas"/> - <Caret Line="122" Column="21" TopLine="98"/> + <Caret Line="48" Column="20" TopLine="16"/> </Position18> <Position19> <Filename Value="raetselunit.pas"/> - <Caret Line="135" Column="15" TopLine="99"/> + <Caret Line="146" Column="9" TopLine="110"/> </Position19> <Position20> <Filename Value="raetselunit.pas"/> - <Caret Line="161" Column="85" TopLine="121"/> + <Caret Line="274" Column="31" TopLine="238"/> </Position20> <Position21> <Filename Value="raetselunit.pas"/> - <Caret Line="172" Column="22" TopLine="136"/> </Position21> <Position22> <Filename Value="raetselunit.pas"/> - <Caret Line="185" Column="51" TopLine="149"/> + <Caret Line="15" Column="10"/> </Position22> <Position23> <Filename Value="raetselunit.pas"/> - <Caret Line="29" Column="13" TopLine="7"/> + <Caret Line="16" Column="10"/> </Position23> <Position24> <Filename Value="raetselunit.pas"/> - <Caret Line="122" Column="21" TopLine="86"/> + <Caret Line="445" Column="3" TopLine="423"/> </Position24> <Position25> <Filename Value="raetselunit.pas"/> - <Caret Line="135" Column="15" TopLine="99"/> + <Caret Line="83" Column="35" TopLine="47"/> </Position25> <Position26> <Filename Value="raetselunit.pas"/> - <Caret Line="161" Column="50" TopLine="125"/> + <Caret Line="289" Column="3" TopLine="264"/> </Position26> <Position27> <Filename Value="raetselunit.pas"/> - <Caret Line="170" Column="30" TopLine="134"/> + <Caret Line="288" Column="9" TopLine="266"/> </Position27> <Position28> <Filename Value="raetselunit.pas"/> - <Caret Line="171" Column="13" TopLine="135"/> + <Caret Line="287" Column="10" TopLine="267"/> </Position28> <Position29> <Filename Value="raetselunit.pas"/> - <Caret Line="172" Column="22" TopLine="136"/> + <Caret Line="285" Column="24" TopLine="268"/> </Position29> <Position30> <Filename Value="raetselunit.pas"/> - <Caret Line="140" TopLine="109"/> + <Caret Line="114" Column="10" TopLine="95"/> </Position30> </JumpHistory> </ProjectSession> diff --git a/raetselunit.pas b/raetselunit.pas index bdeb19b..a2c069e 100644 --- a/raetselunit.pas +++ b/raetselunit.pas @@ -5,18 +5,46 @@ unit raetselunit; interface uses - Classes, SysUtils, Forms, Spin, Controls, StdCtrls, ExtCtrls; + Classes, SysUtils, Forms, Spin, Controls, StdCtrls, ExtCtrls, LCLType, + lowlevelunit; type tAlphabetFunktion = function(i: longint): string; + tFelderRaetsel = class; + + tFelderLoesMeta = class + private + _inh: boolean; + _perm: tLongintArray; + _mgl: tInt64Array; + _posi: longint; + public + constructor create(ib: boolean; fr: tFelderRaetsel); + destructor destroy; + function posi: longint; + function fwd: boolean; + procedure rev; + property inhaltBehalten: boolean read _inh; + procedure aktualisiereInhalt(p: longint); + procedure aktualisiereRand(p: longint); + end; + tRaetsel = class private besitzer: tForm; zeichenflaeche: tImage; + erzeugeBtn: tButton; function besitzerHoehe: longint; dynamic; function besitzerBreite: longint; dynamic; procedure zeichenFlaecheNeuKreieren; + procedure onKeyDown(sender: tObject; var key: word; shiftState: tShiftState); dynamic; abstract; + procedure onMouseDown(sender: tObject; button: tMouseButton; shiftState: tShiftState; x,y: longint); dynamic; abstract; + 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; @@ -24,19 +52,26 @@ type end; tFelderRaetsel = class(tRaetsel) - spinEdits: array of tSpinEdit; - diagonalenCB: tCheckBox; - groeszen: array of longint; - felder,rand: array of longint; - dim,schriftGroesze: longint; - zellGroesze: extended; - uebersetze: tAlphabetFunktion; + spinEdits: array of tSpinEdit; + diagonalenCB: tCheckBox; + groeszen,inhalt,rand: array of longint; + moeglich: array of int64; + dim,schriftGroesze,cursorPosition: longint; + zellGroesze: extended; + uebersetze: tAlphabetFunktion; procedure anzSEsOnChange(sender: tObject); + procedure onKeyDown(sender: tObject; var key: word; shiftState: tShiftState); override; + procedure onMouseDown(sender: tObject; button: tMouseButton; shiftState: tShiftState; x,y: longint); override; procedure aktualisiereGroesze; + procedure loeschen; override; + function loesen(inhaltBehalten: boolean): longint; override; + procedure leeren; override; procedure aktualisiereZeichenflaechenGroesze; function besitzerHoehe: longint; override; function besitzerBreite: longint; override; procedure schreibeZentriert(x,y,i: longint); + procedure relativeInhaltsAenderung(diff: longint); dynamic; abstract; + function absoluteInhaltsAenderung(key: word): boolean; dynamic; abstract; public constructor create(aOwner: tForm; anzInhTypen: longint; alphabetFunktion: tAlphabetFunktion); destructor destroy; override; @@ -45,6 +80,9 @@ type 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; @@ -52,6 +90,9 @@ type 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; @@ -68,6 +109,47 @@ implementation uses math; +// tFelderLoesMeta ************************************************************* + +constructor tFelderLoesMeta.create(ib: boolean; fr: tFelderRaetsel); +var + i: longint; +begin + inherited create; + _inh:=ib; + _perm:=permutation(length(fr.inhalt)); + setlength(_perm,length(_perm)+1); + for i:=length(_perm)-1 downto 1 do + _perm[i]:=_perm[i-1]; + _perm[0]:=-1; + setlength(_mgl,length(fr.inhalt)); + _posi:=0; +end; + +destructor tFelderLoesMeta.destroy; +begin + setlength(_perm,0); + setlength(_mgl,0); + inherited destroy; +end; + +function tFelderLoesMeta.posi: longint; +begin + result:=_perm[_posi]; +end; + +function tFelderLoesMeta.fwd: boolean; +begin + result:=_posi<length(_perm); + if result then + inc(_posi); +end; + +procedure tFelderLoesMeta.rev; +begin + dec(_posi); +end; + // tRaetsel ******************************************************************** constructor tRaetsel.create(aOwner: tForm); @@ -76,6 +158,14 @@ begin besitzer:=aOwner; zeichenflaeche:=tImage.create(besitzer); zeichenflaeche.parent:=besitzer; + zeichenflaeche.onMouseDown:=@onMouseDown; + erzeugeBtn:=tButton.create(besitzer); + erzeugeBtn.parent:=besitzer; + erzeugeBtn.left:=spacing;; + erzeugeBtn.top:=spacing;; + erzeugeBtn.caption:='Erzeugen!'; + erzeugeBtn.onClick:=@erzeugeOnClick; + erzeugeBtn.onKeyDown:=@onKeyDown; end; destructor tRaetsel.destroy; @@ -105,10 +195,18 @@ begin i.width:=zeichenflaeche.width; i.height:=zeichenflaeche.height; i.canvas.font.size:=zeichenflaeche.canvas.font.size; + i.onMouseDown:=zeichenflaeche.onMouseDown; zeichenflaeche.free; zeichenflaeche:=i; end; +procedure tRaetsel.erzeugeOnClick(sender: tObject); +begin + loeschen; + loesen(true); + leeren; +end; + // tFelderRaetsel ************************************************************** constructor tFelderRaetsel.create(aOwner: tForm; anzInhTypen: longint; alphabetFunktion: tAlphabetFunktion); @@ -117,17 +215,19 @@ var begin inherited create(aOwner); uebersetze:=alphabetFunktion; + cursorPosition:=-1; setlength(spinEdits,anzInhTypen+1); setlength(groeszen,length(spinEdits)-1); for i:=0 to length(spinEdits)-1 do begin spinEdits[i]:=tSpinEdit.create(besitzer); with spinEdits[i] do begin parent:=besitzer; - top:=spacing; + top:=erzeugeBtn.top+erzeugeBtn.height+spacing; if i>0 then left:=spinEdits[i-1].left + spinEdits[i-1].width; left:=left+spacing; onChange:=@anzSEsOnChange; + onKeyDown:=@self.onKeyDown; tag:=i; end; if i>0 then @@ -135,11 +235,11 @@ begin end; spinEdits[0].showHint:=true; spinEdits[0].hint:='Schriftgröße'; - spinEdits[0].value:=7; + spinEdits[0].value:=14; diagonalenCB:=tCheckBox.create(besitzer); diagonalenCB.parent:=besitzer; diagonalenCB.caption:='Diagonalen'; - diagonalenCB.top:=spacing; + diagonalenCB.top:=erzeugeBtn.top+erzeugeBtn.height+spacing; diagonalenCB.left:=spinEdits[length(spinEdits)-1].left+spinEdits[length(spinEdits)-1].width+spacing; zeichenflaeche.left:=spacing; zeichenflaeche.top:=diagonalenCB.top+diagonalenCB.height+spacing; @@ -162,6 +262,48 @@ begin aktualisiereGroesze; end; +procedure tFelderRaetsel.onKeyDown(sender: tObject; var key: word; shiftState: tShiftState); +begin + if not absoluteInhaltsAenderung(key) then + case key of + VK_DOWN: + cursorPosition:= + (cursorPosition mod dim) + + dim*min(dim-1,cursorPosition div dim + 1); + VK_UP: + cursorPosition:= + (cursorPosition mod dim) + + dim*max(0,cursorPosition div dim - 1); + VK_LEFT: + cursorPosition:= + max(0,cursorPosition mod dim - 1) + + dim*(cursorPosition div dim); + VK_RIGHT: + cursorPosition:= + min(dim-1,cursorPosition mod dim + 1) + + dim*(cursorPosition div dim); + 33,107,187: + if (cursorPosition>=0) and (cursorPosition<dim*dim) then + relativeInhaltsAenderung(1); + 34,109,189: + if (cursorPosition>=0) and (cursorPosition<dim*dim) then + relativeInhaltsAenderung(-1); + else + exit; + end{of case}; + key:=0; + zeichnen; +end; + +procedure tFelderRaetsel.onMouseDown(sender: tObject; button: tMouseButton; shiftState: tShiftState; x,y: longint); +begin + x:=floor(x/zellGroesze-1); + y:=floor(y/zellGroesze-1); + if (x<0) or (x>=dim) or (y<0) or (y>=dim) then exit; + cursorPosition:=x+y*dim; + zeichnen; +end; + procedure tFelderRaetsel.aktualisiereGroesze; var i: longint; @@ -172,15 +314,66 @@ begin groeszen[i]:=spinEdits[i+1].value; dim:=dim+groeszen[i]; end; - setlength(felder,dim*dim); - for i:=0 to length(felder)-1 do - felder[i]:=random(dim+1)-1; // 0; + setlength(inhalt,dim*dim); setlength(rand,4*dim); - for i:=0 to length(rand)-1 do - rand[i]:=random(dim+1)-1; // 0; + leeren; + cursorPosition:=0; aktualisiereZeichenflaechenGroesze; end; +procedure tFelderRaetsel.loeschen; +var + i: longint; +begin + for i:=0 to length(inhalt)-1 do + inhalt[i]:=-1; + for i:=0 to length(rand)-1 do + rand[i]:=-1; +end; + +function tFelderRaetsel.loesen(inhaltBehalten: boolean): longint; +var + lm: tFelderLoesMeta; +begin + lm:=tFelderLoesMeta.create(inhaltBehalten,self); + result:=_loesen(lm); + lm.free; +end; + +procedure tFelderRaetsel.leeren; +var + p: tLongintArray; + i,w: longint; +var + lm: tFelderLoesMeta; +begin + lm:=tFelderLoesMeta.create(false,self); + + p:=permutation(dim*dim); + for i:=0 to length(p)-1 do begin + if inhalt[p[i]]<0 then continue; + w:=inhalt[p[i]]; + inhalt[p[i]]:=-1; + lm.aktualisiereInhalt(p[i]); + if _loesen(lm)<>1 then begin + inhalt[p[i]]:=w; + lm.aktualisiereInhalt(p[i]); + end; + end; + + p:=permutation(dim*4); + for i:=0 to length(p)-1 do begin + if rand[p[i]]<0 then continue; + w:=rand[p[i]]; + rand[p[i]]:=-1; + lm.aktualisiereRand(p[i]); + if _loesen(lm)<>1 then begin + rand[p[i]]:=w; + lm.aktualisiereRand(p[i]); + end; + end; +end; + procedure tFelderRaetsel.aktualisiereZeichenflaechenGroesze; begin zeichenflaeche.canvas.font.size:=schriftGroesze; @@ -190,7 +383,7 @@ begin zeichenflaeche.canvas.textWidth(uebersetze(dim)), zeichenflaeche.canvas.textHeight(uebersetze(dim)) ); - zeichenflaeche.height:=(dim+2)*round(2*zellGroesze); + zeichenflaeche.height:=round((dim+2)*zellGroesze); zeichenflaeche.width:=zeichenflaeche.height; zeichenFlaecheNeuKreieren; besitzer.height:=besitzerHoehe; @@ -226,8 +419,8 @@ begin br:=textWidth(s); ho:=textHeight(s); textOut( - round(2*(x+1.5)*zellGroesze-br/2), - round(2*(y+1.5)*zellGroesze-ho/2), + round((x+1.5)*zellGroesze-br/2), + round((y+1.5)*zellGroesze-ho/2), s ); end; @@ -240,21 +433,30 @@ begin zeichenflaeche.canvas.brush.color:=$ffffff; zeichenflaeche.canvas.rectangle(-10,-10,zeichenflaeche.width+10,zeichenflaeche.height+10); zeichenflaeche.canvas.pen.width:=3; + zeichenflaeche.canvas.pen.color:=$000000; for i:=0 to dim do with zeichenflaeche.canvas do begin - moveTo(round((i+1)*2*zellGroesze),round(2*zellGroesze)); - lineTo(round((i+1)*2*zellGroesze),round((dim+1)*2*zellGroesze)); - moveTo(round(2*zellGroesze),round((i+1)*2*zellGroesze)); - lineTo(round((dim+1)*2*zellGroesze),round((i+1)*2*zellGroesze)); + moveTo(round((i+1)*zellGroesze),round(zellGroesze)); + lineTo(round((i+1)*zellGroesze),round((dim+1)*zellGroesze)); + moveTo(round(zellGroesze),round((i+1)*zellGroesze)); + lineTo(round((dim+1)*zellGroesze),round((i+1)*zellGroesze)); end; + zeichenflaeche.canvas.pen.color:=$8080ff; + if (cursorPosition>=0) and (dim>0) then + zeichenflaeche.canvas.rectangle( + round(((cursorPosition mod dim)+1)*zellGroesze), + round(((cursorPosition div dim)+1)*zellGroesze), + round(((cursorPosition mod dim)+2)*zellGroesze+1), + round(((cursorPosition div dim)+2)*zellGroesze+1) + ); for i:=0 to dim-1 do begin schreibeZentriert(i,-1,rand[i]); schreibeZentriert(dim,i,rand[dim+i]); schreibeZentriert(i,dim,rand[2*dim+i]); schreibeZentriert(-1,i,rand[3*dim+i]); end; - for i:=0 to length(felder)-1 do - schreibeZentriert(i mod dim,i div dim,felder[i]); + for i:=0 to length(inhalt)-1 do + schreibeZentriert(i mod dim,i div dim,inhalt[i]); end; // tBuchstabenRaetsel ********************************************************** @@ -276,6 +478,50 @@ 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); @@ -292,6 +538,33 @@ 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(inhaltBehalten: boolean; perm: tLongintArray; posi: longint): longint; +begin + +end; + // allgemeine Funktionen ******************************************************* function buchstabenAlphabetFunktion(i: longint): string; @@ -3,7 +3,7 @@ object Form2: TForm2 Height = 94 Top = 197 Width = 192 - Caption = 'Form2' + Caption = 'Rätsel' ClientHeight = 94 ClientWidth = 192 LCLVersion = '1.6.0.4' |