summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-10-01 11:21:32 +0200
committerErich Eckner <git@eckner.net>2018-10-01 11:21:32 +0200
commitfe01ae9355e0fddf2100e165d07fb41ae68b3470 (patch)
treea766e156d5367ed4b40213cf57b38d74882ec575
parent0c70d338a4157e59cb25f4881a349105957486a0 (diff)
downloadRaetsel-fe01ae9355e0fddf2100e165d07fb41ae68b3470.tar.xz
raetselunit.inc: passtZumZeichnen neu
-rw-r--r--raetsel.lps122
-rw-r--r--raetselunit.inc101
-rw-r--r--raetselunit.pas24
3 files changed, 172 insertions, 75 deletions
diff --git a/raetsel.lps b/raetsel.lps
index df267c7..81ab4d0 100644
--- a/raetsel.lps
+++ b/raetsel.lps
@@ -9,7 +9,7 @@
<IsPartOfProject Value="True"/>
<EditorIndex Value="2"/>
<CursorPos X="35" Y="10"/>
- <UsageCount Value="43"/>
+ <UsageCount Value="44"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@@ -18,9 +18,9 @@
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
- <TopLine Value="10"/>
- <CursorPos X="38" Y="21"/>
- <UsageCount Value="43"/>
+ <TopLine Value="32"/>
+ <CursorPos X="13" Y="68"/>
+ <UsageCount Value="44"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@@ -31,34 +31,33 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit2"/>
- <EditorIndex Value="6"/>
+ <EditorIndex Value="4"/>
<CursorPos X="20" Y="12"/>
- <UsageCount Value="42"/>
+ <UsageCount Value="43"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit2>
<Unit3>
<Filename Value="raetselunit.pas"/>
<IsPartOfProject Value="True"/>
+ <IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
- <TopLine Value="4"/>
- <CursorPos X="35" Y="9"/>
- <UsageCount Value="37"/>
+ <TopLine Value="452"/>
+ <CursorPos Y="487"/>
+ <UsageCount Value="38"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="buchstabenunit.pas"/>
- <EditorIndex Value="4"/>
+ <EditorIndex Value="-1"/>
<CursorPos Y="18"/>
<UsageCount Value="23"/>
- <Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="hochhausunit.pas"/>
- <EditorIndex Value="5"/>
+ <EditorIndex Value="-1"/>
<CursorPos Y="18"/>
<UsageCount Value="23"/>
- <Loaded Value="True"/>
</Unit5>
<Unit6>
<Filename Value="Unit1.pas"/>
@@ -84,8 +83,9 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
- <EditorIndex Value="7"/>
- <CursorPos X="34" Y="93"/>
+ <EditorIndex Value="5"/>
+ <TopLine Value="1043"/>
+ <CursorPos Y="1082"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit9>
@@ -113,10 +113,8 @@
<Unit13>
<Filename Value="raetselunit.inc"/>
<IsPartOfProject Value="True"/>
- <IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
- <TopLine Value="341"/>
- <CursorPos X="26" Y="360"/>
+ <CursorPos X="15" Y="13"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit13>
@@ -124,123 +122,123 @@
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="ori_Unit1.pas"/>
- <Caret Line="1027" Column="63" TopLine="1013"/>
+ <Caret Line="1826" Column="16" TopLine="1794"/>
</Position1>
<Position2>
- <Filename Value="raetselunit.inc"/>
- <Caret Line="150" TopLine="131"/>
+ <Filename Value="ori_Unit1.pas"/>
+ <Caret Line="112" Column="20" TopLine="94"/>
</Position2>
<Position3>
- <Filename Value="raetselunit.inc"/>
- <Caret Line="493" TopLine="454"/>
+ <Filename Value="ori_Unit1.pas"/>
+ <Caret Line="568" Column="20" TopLine="535"/>
</Position3>
<Position4>
- <Filename Value="raetselunit.inc"/>
- <Caret Line="210" Column="31" TopLine="191"/>
+ <Filename Value="ori_Unit1.pas"/>
+ <Caret Line="890" Column="17" TopLine="857"/>
</Position4>
<Position5>
<Filename Value="raetselunit.inc"/>
- <Caret Line="494" Column="9" TopLine="455"/>
+ <Caret Line="23"/>
</Position5>
<Position6>
<Filename Value="raetselunit.inc"/>
- <Caret Line="211" Column="30" TopLine="191"/>
+ <Caret Line="442" Column="3" TopLine="415"/>
</Position6>
<Position7>
- <Filename Value="raetselunit.inc"/>
- <Caret Line="23" Column="3"/>
+ <Filename Value="raetselunit.pas"/>
+ <Caret Line="338" TopLine="316"/>
</Position7>
<Position8>
<Filename Value="raetselunit.inc"/>
- <Caret Line="488" TopLine="449"/>
+ <Caret Line="15"/>
</Position8>
<Position9>
<Filename Value="raetselunit.pas"/>
- <Caret Line="372" Column="8" TopLine="351"/>
+ <Caret Line="39" Column="23" TopLine="34"/>
</Position9>
<Position10>
<Filename Value="raetselunit.pas"/>
- <Caret Line="467" TopLine="435"/>
+ <Caret Line="65" Column="23" TopLine="33"/>
</Position10>
<Position11>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="471" Column="30" TopLine="435"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="30" Column="32"/>
</Position11>
<Position12>
- <Filename Value="raetselunit.inc"/>
- <Caret Line="224" Column="3" TopLine="198"/>
+ <Filename Value="raetselunit.pas"/>
+ <Caret Line="220" Column="57" TopLine="203"/>
</Position12>
<Position13>
<Filename Value="raetselunit.pas"/>
- <Caret Line="85" Column="7"/>
+ <Caret Line="34" Column="31"/>
</Position13>
<Position14>
- <Filename Value="raetsel.lpr"/>
- <Caret Line="10" Column="35"/>
+ <Filename Value="raetselunit.pas"/>
+ <Caret Line="35" Column="20" TopLine="2"/>
</Position14>
<Position15>
- <Filename Value="raetselunit.inc"/>
- <Caret Line="219" Column="28" TopLine="199"/>
+ <Filename Value="raetselunit.pas"/>
+ <Caret Line="370" Column="28" TopLine="338"/>
</Position15>
<Position16>
<Filename Value="raetselunit.inc"/>
- <Caret Line="225" Column="38" TopLine="205"/>
+ <Caret Line="13" Column="15" TopLine="19"/>
</Position16>
<Position17>
<Filename Value="raetselunit.inc"/>
- <Caret Line="229" Column="23" TopLine="209"/>
+ <Caret Line="439" Column="26" TopLine="417"/>
</Position17>
<Position18>
<Filename Value="raetselunit.inc"/>
- <Caret Line="230" Column="18" TopLine="210"/>
+ <Caret Line="13" Column="15"/>
</Position18>
<Position19>
- <Filename Value="raetselunit.inc"/>
- <Caret Line="236" Column="32" TopLine="216"/>
+ <Filename Value="raetselunit.pas"/>
+ <Caret Line="370" Column="28" TopLine="338"/>
</Position19>
<Position20>
- <Filename Value="raetselunit.inc"/>
- <Caret Line="242" Column="34" TopLine="221"/>
+ <Filename Value="raetselunit.pas"/>
+ <Caret Line="468" TopLine="441"/>
</Position20>
<Position21>
- <Filename Value="raetselunit.inc"/>
- <Caret Line="249" Column="17" TopLine="229"/>
+ <Filename Value="raetselunit.pas"/>
+ <Caret Line="488" Column="25" TopLine="451"/>
</Position21>
<Position22>
<Filename Value="raetselunit.inc"/>
- <Caret Line="263" Column="13" TopLine="241"/>
+ <Caret Line="484" TopLine="445"/>
</Position22>
<Position23>
<Filename Value="raetselunit.inc"/>
- <Caret Line="396" Column="20" TopLine="364"/>
+ <Caret Line="524" Column="55" TopLine="490"/>
</Position23>
<Position24>
<Filename Value="raetselunit.inc"/>
- <Caret Line="231" Column="3" TopLine="211"/>
+ <Caret Line="449" Column="5" TopLine="430"/>
</Position24>
<Position25>
<Filename Value="raetselunit.inc"/>
- <Caret Line="309" Column="29" TopLine="280"/>
+ <Caret Line="524" Column="49" TopLine="490"/>
</Position25>
<Position26>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="85" Column="7"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="488" Column="17" TopLine="469"/>
</Position26>
<Position27>
<Filename Value="raetselunit.inc"/>
- <Caret Line="450" TopLine="259"/>
+ <Caret Line="507" Column="13" TopLine="487"/>
</Position27>
<Position28>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="85" Column="16" TopLine="65"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="452" Column="5" TopLine="439"/>
</Position28>
<Position29>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="24" Column="34" TopLine="10"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="520" TopLine="482"/>
</Position29>
<Position30>
<Filename Value="raetselunit.pas"/>
- <Caret Line="9" Column="35" TopLine="4"/>
+ <Caret Line="487" Column="3" TopLine="452"/>
</Position30>
</JumpHistory>
</ProjectSession>
diff --git a/raetselunit.inc b/raetselunit.inc
index 57e68fd..5d40b2d 100644
--- a/raetselunit.inc
+++ b/raetselunit.inc
@@ -10,6 +10,9 @@ type
private
// procedure relativeInhaltsAenderung(diff: longint); override;
// function absoluteInhaltsAenderung(key: word): boolean; override;
+ function passtZumZeichnen(spalte,zeile: integer): boolean; override;
+ function passt(spalte,zeile: integer): boolean; override;
+ function geloest: boolean; override;
public
{$IFDEF buchstaben}
NBuchst,
@@ -20,16 +23,11 @@ type
constructor create(aOwner: tForm);
destructor destroy; override;
procedure gesamtRaenderErzeugen;
-(* function passtZumZeichnen(Spalte,Zeile: integer): boolean;
- procedure Zeichnen;
- procedure schreibe(was: String; Spalte,Zeile: integer); *)
- function passt(spalte,zeile: integer): boolean; override;
// function Loesen(lPos: integer): boolean;
- function geloest: boolean;
-(* procedure leeren;
- procedure RandErzeugen;
- function anzLoesungen(lPos: integer): integer;
- procedure Image2Bemalen; *)
+// procedure leeren;
+// procedure RandErzeugen;
+// function anzLoesungen(lPos: integer): integer;
+// procedure Image2Bemalen;
end;
{$IFDEF hochhaus}
@@ -437,3 +435,88 @@ begin
closefile(dat);
end;
{$ENDIF}
+
+{$IFDEF passtZumZeichnen}
+// function tHochhausRaetsel.passtZumZeichnen(spalte,zeile: integer): boolean;
+var
+ I,KS,KZ: Integer;
+ W,S: Longint;
+begin
+ {$IFDEF buchstaben}
+ if inhalt[Zeile*dim+Spalte]=-1 then begin
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ if inhalt[Zeile*dim+Spalte]=0 then begin
+ {$ENDIF}
+ result:=false;
+ exit;
+ end;
+ W:=0;
+ S:=0;
+ for I:=0 to dim-1 do begin
+ {$IFDEF buchstaben}
+ W:=W*(NBuchst+2)+inhalt[Zeile*dim+I]+1;
+ S:=S*(NBuchst+2)+inhalt[I*dim+Spalte]+1;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ W:=W*(dim+1)+inhalt[Zeile*dim+I];
+ S:=S*(dim+1)+inhalt[I*dim+Spalte];
+ {$ENDIF}
+ end;
+ Result:=
+ {$IFDEF buchstaben}
+ (EMoeglich[S*(NBuchst+1)+Rand[Spalte]] or not EMoeglich[S*(NBuchst+1)]) and
+ (AMoeglich[W*(NBuchst+1)+Rand[dim+Zeile]] or not AMoeglich[W*(NBuchst+1)]) and
+ (AMoeglich[S*(NBuchst+1)+Rand[2*dim+Spalte]] or not AMoeglich[S*(NBuchst+1)]) and
+ (EMoeglich[W*(NBuchst+1)+Rand[3*dim+Zeile]] or not EMoeglich[W*(NBuchst+1)]);
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ (EMoeglich[S*(dim+1)+Rand[Spalte]] or not EMoeglich[S*(dim+1)]) and
+ (AMoeglich[W*(dim+1)+Rand[dim+Zeile]] or not AMoeglich[W*(dim+1)]) and
+ (AMoeglich[S*(dim+1)+Rand[2*dim+Spalte]] or not AMoeglich[S*(dim+1)]) and
+ (EMoeglich[W*(dim+1)+Rand[3*dim+Zeile]] or not EMoeglich[W*(dim+1)]);
+ {$ENDIF}
+ {$IFDEF buchstaben}
+ if inhalt[Zeile*dim+Spalte]=0 then
+ W:=NLeer
+ else
+ {$ENDIF}
+ W:=1;
+ if diagonalenCB.checked then begin
+ if Zeile=Spalte then begin
+ S:=W;
+ for I:=0 to dim-1 do
+ if (I<>Zeile) and (inhalt[I*(dim+1)]=inhalt[Zeile*dim+Spalte]) then
+ dec(S);
+ Result:=Result and (S>0);
+ end;
+ if Zeile+Spalte=dim-1 then begin
+ S:=W;
+ For I:=0 to dim-1 do
+ if (I<>Zeile) and (inhalt[(I+1)*(dim-1)]=inhalt[Zeile*dim+Spalte]) then
+ dec(S);
+ Result:=Result and (S>0);
+ end;
+ end;
+ if sudokuCB.checked then begin
+ KZ:=(Zeile div NSqrt)*NSqrt;
+ KS:=(Spalte div NSqrt)*NSqrt;
+ S:=W+1;
+ For I:=0 to dim-1 do
+ if inhalt[(KZ+(I div NSqrt))*dim+KS+(I mod NSqrt)]=inhalt[Zeile*dim+Spalte] then
+ dec(S);
+ Result:=Result and (S>0);
+ end;
+ S:=W;
+ For I:=0 to dim-1 do
+ if (I<>Zeile) and (inhalt[I*dim+Spalte]=inhalt[Zeile*dim+Spalte]) then
+ dec(S);
+ Result:=Result and (S>0);
+ S:=W;
+ For I:=0 to dim-1 do
+ if (I<>Spalte) and (inhalt[Zeile*dim+I]=inhalt[Zeile*dim+Spalte]) then
+ dec(S);
+ Result:=Result and (S>0);
+end;
+{$ENDIF}
+
diff --git a/raetselunit.pas b/raetselunit.pas
index 5f1033b..b0cea36 100644
--- a/raetselunit.pas
+++ b/raetselunit.pas
@@ -30,12 +30,13 @@ type
procedure erzeugeOnClick(sender: tObject);
procedure loeschen; dynamic; abstract;
procedure leeren; dynamic; abstract;
+ function loesen(inhaltBehalten: boolean; lPos: longint): longint; dynamic; abstract;
+ function passtZumZeichnen(spalte,zeile: integer): boolean; dynamic; abstract;
+ function passt(spalte,zeile: integer): boolean; dynamic; abstract;
+ function geloest: boolean; dynamic; abstract;
public
constructor create(aOwner: tForm);
destructor destroy; override;
- function loesen(inhaltBehalten: boolean; lPos: longint): longint; dynamic; abstract;
- function passt(spalte,zeile: integer): boolean; dynamic; abstract;
- function geloest: boolean; dynamic; abstract;
procedure zeichnen; dynamic; abstract;
end;
@@ -120,6 +121,9 @@ begin
erzeugeBtn.caption:='Erzeugen!';
erzeugeBtn.onClick:=@erzeugeOnClick;
erzeugeBtn.onKeyDown:=@onKeyDown;
+ progressbar1:=tProgressBar.create(besitzer);
+ progressbar1.visible:=false;
+ progressbar1.parent:=besitzer;
end;
destructor tRaetsel.destroy;
@@ -331,6 +335,7 @@ begin
zeichenflaeche.height:=round((dim+2)*zellGroesze);
zeichenflaeche.width:=zeichenflaeche.height;
zeichenFlaecheNeuKreieren;
+ progressbar1.width:=besitzerBreite;
besitzer.height:=besitzerHoehe;
besitzer.width:=besitzerBreite;
zeichnen;
@@ -362,7 +367,7 @@ begin
s:=uebersetze(i);
with zeichenflaeche.canvas do begin
brush.color:=$FFFFFF - $181818*byte(diagonalenCB.checked and ((x=y) or (x+y=dim+1)));
- if not passt(x,y) then
+ if not passtZumZeichnen(x,y) then
font.color:=$0000FF
else if geloest then
font.color:=$007F00
@@ -471,5 +476,16 @@ procedure tBuchstabenRaetsel.gesamtRaenderErzeugen;
{$UNDEF buchstaben}
{$UNDEF gesamtRaenderErzeugen}
+{$DEFINE passtZumZeichnen}
+function tHochhausRaetsel.passtZumZeichnen(spalte,zeile: integer): boolean;
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
+function tBuchstabenRaetsel.passtZumZeichnen(spalte,zeile: integer): boolean;
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
+{$UNDEF passtZumZeichnen}
+
end.