diff options
Diffstat (limited to 'hochhausunit.pas')
-rw-r--r-- | hochhausunit.pas | 82 |
1 files changed, 82 insertions, 0 deletions
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. + |