55. Írjuk meg a Windows
környezetből ismert Passziánsz nevű programnak a karakteres képernyőn való
megvalósítását.
Program Passz;
Uses NewDelay, Crt, CrtPlus, Drivers;
Const KepSz: Byte= 1;
FonSz: Byte= 2;
LSz = 52;
Type TLap= Object
Fx, Fy, Ft, Fs, Fc: Byte;{tipus:káró,kör,treff,pikk; szám:1-13; color}
Fl: String[3]; {label}
Fv, Ff, Fe: Boolean; {visible, flash, enable}
Procedure Init(Ix, Iy, It, Is: Byte; Iv: Boolean);
Procedure Show;
Procedure Hide;
Procedure SetVisible(V: Boolean);
Function GetVisible: Boolean;
Procedure MoveTo(X, Y: Byte);
Procedure MoveRel(X, Y: Integer);
Function InSide(X, Y: Byte): Boolean;
Procedure FlashOn;
Procedure FlashOff;
Function GetFlash: Boolean;
Function GetTip: Byte;
Function GetSzin: Byte;
Function GetFig: Byte; {Az Fs-t adja vissza}
Procedure SetEnable(E: Boolean);
Function GetEnable: Boolean;
End;
TLFor= Object
FLapF: Array[1..LSz] Of TLap;
FNum: Byte;
Procedure Feltolt;
Procedure Kever;
Procedure Show;
Function InSide(X, Y: Byte): Boolean;
End;
TLMut= Object
FLapM: Array[1..LSz] Of TLap;
FNum: Byte;
Procedure Show;
Function InSide(X, Y: Byte): Boolean;
End;
TLAsz= Object
FLapA: Array[1..7, 0..18] Of TLap;
Procedure Show;
End;
TLCel= Object
FLapC: Array[1..4, 1..13] Of TLap;
FFent: Array[1..4] Of Byte;
Procedure Show;
End;
TLPuf= Object
FLapP: Array[1..12] Of TLap;
FNum: Byte;
End;
TControl= Object
FLFor: TLFor;
FLMut: TLMut;
FLAsz: TLAsz;
FLCel: TLCel;
FLPuf: TLPuf;
ULap: TLap;
Procedure Init;
Procedure Run;
Procedure Done;
End;
(******* TLap *************)
Procedure TLap.Init(Ix, Iy, It, Is: Byte; Iv: Boolean);
Begin
Fx:= Ix; Fy:= Iy; Ft:= It; Fs:= Is; Fv:= Iv;
Fv:= False; Ff:= False; Fe:= False;
End;
Procedure TLap.Show;
Var I, J, AHs, AKs: Byte;
Begin
If Fx=0 Then Exit;
HideMouse; AHs:= FonSz; AKs:= 0;
If Fv Then
Begin
AHs:= 7;
Case Ft Of
3,4: AKs:= 6;
5,6: AKs:= 0;
End;
End;
Fc:= AKs;
Szinek(AHs, AKs); Window(Fx,Fy,Fx+6,Fy+7); ClrScr; Window(1,1,80,50);
Keret(Fx,Fy,Fx+6,Fy+8);
If Fv Then
Case Fs Of
1: Begin
Fl:= Chr(Ft)+'A'; WriteXY(Fx+1,Fy,Fl);
For I:= 3 To 7 Do WriteXY(Fx+1,Fy+I,Chr(Ft));
For I:= 3 To 7 Do WriteXY(Fx+5,Fy+I,Chr(Ft));
For I:= 2 To 4 Do WriteXY(Fx+I,Fy+5,Chr(Ft));
For I:= 2 To 3 Do WriteXY(Fx+I,Fy+4-I,Chr(Ft));
WriteXY(Fx+4,Fy+2,Chr(Ft));
End;
2: Begin
Fl:= Chr(Ft)+'2'; WriteXY(Fx+1,Fy,Fl);
WriteXY(Fx+3,Fy+2,Chr(Ft)); WriteXY(Fx+3,Fy+6,Chr(Ft));
End;
3: Begin
Fl:= Chr(Ft)+'3'; WriteXY(Fx+1,Fy,Fl); WriteXY(Fx+3,Fy+2,Chr(Ft));
WriteXY(Fx+3,Fy+4,Chr(Ft)); WriteXY(Fx+3,Fy+6,Chr(Ft));
End;
4: Begin
Fl:= Chr(Ft)+'4'; WriteXY(Fx+1,Fy,Fl);
WriteXY(Fx+1,Fy+2,Chr(Ft)+' '+Chr(Ft));
WriteXY(Fx+1,Fy+6,Chr(Ft)+' '+Chr(Ft));
End;
5: Begin
Fl:= Chr(Ft)+'5'; WriteXY(Fx+1,Fy,Fl);
WriteXY(Fx+1,Fy+2,Chr(Ft)+' '+Chr(Ft));WriteXY(Fx+3,Fy+4,Chr(Ft));
WriteXY(Fx+1,Fy+6,Chr(Ft)+' '+Chr(Ft));
End;
6: Begin
Fl:= Chr(Ft)+'6'; WriteXY(Fx+1,Fy,Fl);
WriteXY(Fx+1,Fy+2,Chr(Ft)+' '+Chr(Ft));
WriteXY(Fx+1,Fy+4,Chr(Ft)+' '+Chr(Ft));
WriteXY(Fx+1,Fy+6,Chr(Ft)+' '+Chr(Ft));
End;
7: Begin
Fl:= Chr(Ft)+'7'; WriteXY(Fx+1,Fy,Fl);
WriteXY(Fx+1,Fy+2,Chr(Ft)+' '+Chr(Ft));WriteXY(Fx+3,Fy+3,Chr(Ft));
WriteXY(Fx+1,Fy+4,Chr(Ft)+' '+Chr(Ft));
WriteXY(Fx+1,Fy+6,Chr(Ft)+' '+Chr(Ft));
End;
8: Begin
Fl:= Chr(Ft)+'8'; WriteXY(Fx+1,Fy,Fl);
WriteXY(Fx+1,Fy+2,Chr(Ft)+' '+Chr(Ft));WriteXY(Fx+3,Fy+3,Chr(Ft));
WriteXY(Fx+1,Fy+4,Chr(Ft)+' '+Chr(Ft));WriteXY(Fx+3,Fy+5,Chr(Ft));
WriteXY(Fx+1,Fy+6,Chr(Ft)+' '+Chr(Ft));
End;
9: Begin
Fl:= Chr(Ft)+'9'; WriteXY(Fx+1,Fy,Fl);
WriteXY(Fx+1,Fy+1,Chr(Ft)+' '+Chr(Ft));
WriteXY(Fx+1,Fy+3,Chr(Ft)+' '+Chr(Ft));WriteXY(Fx+3,Fy+4,Chr(Ft));
WriteXY(Fx+1,Fy+5,Chr(Ft)+' '+Chr(Ft));
WriteXY(Fx+1,Fy+7,Chr(Ft)+' '+Chr(Ft));
End;
10: Begin
Fl:= Chr(Ft)+'10'; WriteXY(Fx+1,Fy,Fl);
WriteXY(Fx+1,Fy+1,Chr(Ft)+' '+Chr(Ft));WriteXY(Fx+3,Fy+2,Chr(Ft));
WriteXY(Fx+1,Fy+3,Chr(Ft)+' '+Chr(Ft));
WriteXY(Fx+1,Fy+5,Chr(Ft)+' '+Chr(Ft));WriteXY(Fx+3,Fy+6,Chr(Ft));
WriteXY(Fx+1,Fy+7,Chr(Ft)+' '+Chr(Ft));
End;
11: Begin
Fl:= Chr(Ft)+'J'; WriteXY(Fx+1,Fy,Fl);
For I:= 1 To 6 Do WriteXY(Fx+5,Fy+I,Chr(Ft));
For I:= 3 To 4 Do WriteXY(Fx+I,Fy+1,Chr(Ft));
For I:= 2 To 4 Do WriteXY(Fx+I,Fy+7,Chr(Ft));
WriteXY(Fx+4,Fy+4,Chr(Ft)); WriteXY(Fx+1,Fy+6,Chr(Ft));
End;
12: Begin
Fl:= Chr(Ft)+'Q'; WriteXY(Fx+1,Fy,Fl);
For I:= 2 To 6 Do WriteXY(Fx+1,Fy+I,Chr(Ft));
For I:= 2 To 5 Do WriteXY(Fx+5,Fy+I,Chr(Ft));
For I:= 2 To 4 Do WriteXY(Fx+I,Fy+1,Chr(Ft));
For I:= 2 To 3 Do WriteXY(Fx+I,Fy+7,Chr(Ft));
For I:= 3 To 5 Do WriteXY(Fx+I,Fy+2+I,Chr(Ft));
End;
13: Begin
Fl:= Chr(Ft)+'K'; WriteXY(Fx+1,Fy,Fl);
For I:= 1 To 7 Do WriteXY(Fx+1,Fy+I,Chr(Ft));
For I:= 2 To 5 Do WriteXY(Fx+I,Fy+6-I,Chr(Ft));
For I:= 3 To 5 Do WriteXY(Fx+I,Fy+2+I,Chr(Ft));
End;
End
Else
For I:= 1 To 5 Do For J:= 1 To 7 Do WriteXY(Fx+I,Fy+J,'*');
ShowMouse;Tunj;
End;
Procedure TLap.Hide;
Begin
Szinek(KepSz, 0); Window(Fx,Fy,Fx+6,Fy+8); ClrScr; Window(1,1,80,50);
End;
Procedure TLap.MoveTo(X, Y: Byte);
Begin
Hide; Fx:= X; Fy:= Y; Show;
End;
Procedure TLap.MoveRel(X, Y: Integer);
Begin
Fx:= Fx + X; Fy:= Fy + Y;
If Fx<1 Then Fx:= 1; If Fx>74 Then Fx:= 74;
If Fy<1 Then Fy:= 1; If Fy>42 Then Fy:= 42;
Show;
End;
Procedure TLap.SetVisible(V: Boolean);
Begin
Fv:= V;
End;
Function TLap.GetVisible: Boolean;
Begin
GetVisible:= Fv;
End;
Function TLap.InSide(X, Y: Byte): Boolean;
Begin
InSide:= (Fx<=X) And (X<=Fx+6) And (Fy<=Y) And (Y<=Fy+8);
End;
Procedure TLap.FlashOn;
Begin
If Fx=0 Then Exit;
Szinek(7, Fc+128); Keret(Fx,Fy,Fx+6,Fy+8);
Window(Fx,Fy,80,50); WriteXY(2,1,Fl); Window(1,1,80,50); Tunj;
Ff:= True;
End;
Procedure TLap.FlashOff;
Begin
If Fx=0 Then Exit;
Szinek(7, Fc); Keret(Fx,Fy,Fx+6,Fy+8);
Window(Fx,Fy,80,50); WriteXY(2,1,Fl); Window(1,1,80,50); Tunj;
Ff:= False;
End;
Function TLap.GetFlash: Boolean;
Begin
GetFlash:= Ff;
End;
Function TLap.GetTip: Byte;
Begin
GetTip:= Ft;
End;
Function TLap.GetSzin: Byte;
Begin
GetSzin:= Fc;
End;
Function TLap.GetFig: Byte;
Begin
GetFig:= Fs;
End;
Procedure TLap.SetEnable(E: Boolean);
Begin
Fe:= E;
End;
Function TLap.GetEnable: Boolean;
Begin
GetEnable:= Fe;
End;
(******** TLFor *********)
Procedure TLFor.Feltolt;
Var I: Byte;
Begin
FNum:= 0;
For I:= 1 To LSz Do With FLapF[I] Do
Begin
Init(4, 2, ((I-1) Div 13)+3, ((I-1) Mod 13)+1, False); Inc(FNum);
End;
End;
Procedure TLFor.Kever;
Var I: Word;
A, B: Byte;
P: TLap;
Begin
For I:= 1 To 2000 Do
Begin
A:= Random(LSz)+1; B:= Random(LSz)+1;
P:= FLapF[A]; FLapF[A]:= FLapF[B]; FLapF[B]:= P;
End;
End;
Procedure TLFor.Show;
Begin
If FNum>0 Then FLapF[FNum].Show
End;
Function TLFor.InSide(X, Y: Byte): Boolean;
Begin
InSide:= (X>3) And (11>X) And (Y>1) And (11>Y)
End;
(******** TLMut ****************)
Procedure TLMut.Show;
Begin
If FNum>0 Then FLapM[FNum].Show;
End;
Function TLMut.InSide(X, Y: Byte): Boolean;
Begin
InSide:= (X>14) And (22>X) And (Y>1) And (11>Y)
End;
(******** TLAsz ***************)
Procedure TLAsz.Show;
Var I, J: Byte;
Begin
For I:= 1 To 7 Do For J:= 1 To I Do
Begin
If I = J Then
Begin FLapA[I, J].SetVisible(True); FLapA[I, J].SetEnable(True) End;
FLapA[I, J].MoveTo(11*(I-1)+4, J+12);
End;
End;
(******** TCel **********)
Procedure TLCel.Show;
Var I: Byte;
Begin
For I:= 1 To 4 Do If FFent[I]>0 Then FLapC[I,FFent[I]].Show;
End;
(******** TControl ************)
Procedure TControl.Init;
Var I, J: Byte;
Begin
{A környezet beállítása}
TextMode(259); Szinek(KepSz, 15); ClrScr; Randomize; InitEvents;
{A képernyõ állandó elemei}
Szinek(KepSz, 7); For I:= 0 To 1 Do Keret( 3+I*11,1,11+I*11,11);
Szinek(KepSz, 15); For I:= 1 To 4 Do Keret( 25+I*11,1,33+I*11,11);
{A forrás feltöltése és keverés}
FLFor.Feltolt; FLFor.Kever;
{Üres lap inicializálása}
ULap.Init(0,0,0,0,False);
{Az asztal és a célhely üres lapokkal való feltöltése}
For I:= 1 To 7 Do For J:= 0 To 18 Do FLAsz.FLapA[I,J]:= ULap;
For I:= 1 To 4 Do For J:= 1 To 13 Do FLCel.FLapC[I,J]:= ULap;
{Az Asztal 0. sorának feltöltése}
For I:= 1 To 7 Do FLAsz.FLapA[I,0].Init(11*(I-1)+4,13,0,0,False);
{A lapok átrakása az asztalra}
For I:= 1 To 7 Do For J:= 1 To I Do
Begin
FLAsz.FLapA[I, J]:= FLFor.FLapF[FLFor.FNum];
FLFor.FLapF[FLFor.FNum]:= ULap; Dec(FLFor.FNum)
End;
{Kezdõkép}
FLCel.Show; FLAsz.Show; FLFor.Show; Tunj;
End;
Procedure TControl.Run;
Var I, J, K, L, X, Y: Byte;
Event: TEvent;
Function Atteheto(A, B: Byte): Boolean;
Var C, D, E, F: Byte;
Begin
Atteheto:= False;
C:= 18; While Not FLAsz.FLapA[B,C].GetVisible Do Dec(C);
D:= 0; While Not FLAsz.FLapA[A,D].GetVisible Do Inc(D);
E:= 18; While Not FLAsz.FLapA[A,E].GetVisible Do Dec(E);
For F:= D To E Do
If (FLAsz.FLapA[B,C].GetSzin<>FLAsz.FLapA[A,F].GetSzin) And
(FLAsz.FLapA[B,C].GetFig-FLAsz.FLapA[A,F].GetFig=1) Then
Atteheto:= True;
End;
Function KAtteheto(A: Byte): Boolean;
Var D: Byte;
Begin
KAtteheto:= False; D:= 0;
While Not FLAsz.FLapA[A,D].GetVisible Do Inc(D);
If FLAsz.FLapA[A,D].GetFig<>13 Then Exit; KAtteheto:= True;
End;
Procedure Atrak(A, B: Byte);
Var C, D: Byte;
Begin
C:= 18; While Not FLAsz.FLapA[B,C].GetVisible Do Dec(C);
D:= 18; While Not FLAsz.FLapA[A,D].GetVisible Do Dec(D);
FLPuf.FNum:= 0;
While (FLAsz.FLapA[B,C].GetFig-FLAsz.FLapA[A,D].GetFig>0) And
(FLAsz.FLapA[A,D].GetVisible) Do
Begin
Inc(FLPuf.FNum);
FLAsz.FLapA[A,D].Moveto(25,2);
FLPuf.FLapP[FLPuf.FNum]:= FLAsz.FLapA[A,D];
FLAsz.FLapA[A,D]:= ULap; Dec(D);
End;
If D>0 Then FLAsz.FLapA[A,D].Show;
If FLAsz.FLapA[A,D].GetVisible Then FLAsz.FLapA[A,D].SetEnable(True);
FLAsz.FLapA[B,C].SetEnable(False);
While FLPuf.FNum>0 Do
Begin
Inc(C); FLPuf.FLapP[FLPuf.FNum].MoveTo((B-1)*11+4,12+C);
FLAsz.FLapA[B,C]:= FLPuf.FLapP[FLPuf.FNum];
Dec(FLPuf.FNum);
End;
End;
Procedure KAtrak(A, B: Byte);
Var C, D: Byte;
Begin
C:= 0; D:= 0; While Not FLAsz.FLapA[A,D].GetEnable Do Inc(D);
FLPuf.FNum:= 0;
While FLAsz.FLapA[A,D].GetVisible Do
Begin
Inc(FLPuf.FNum);
FLAsz.FLapA[A,D].Moveto(25,2);
FLPuf.FLapP[FLPuf.FNum]:= FLAsz.FLapA[A,D];
FLAsz.FLapA[A,D]:= ULap; Dec(D);
End;
If D>0 Then FLAsz.FLapA[A,D].Show;
While FLPuf.FNum>0 Do
Begin
Inc(C); FLPuf.FLapP[FLPuf.FNum].MoveTo((B-1)*11+4,12+C);
FLAsz.FLapA[B,C]:= FLPuf.FLapP[FLPuf.FNum];
Dec(FLPuf.FNum);
End;
End;
Function Vege: Boolean;
Var A, S: Byte;
Begin
S:= 0; For A:= 1 To 4 Do S:= S+FLCel.FFent[A];
Vege:= S = LSz;
End;
Begin
Repeat
While (Not KeyPressed) And (MouseButtons=0) Do
Begin
{Lapok célhelyre rakása kettõs kattintással}
GetMouseEvent(Event);
If (Event.What=evMouseDown) And Event.Double Then
Begin
X:= MouseWhere.X+1; Y:= MouseWhere.Y+1;
{Forráshelyrõl}
With FLMut.FLapM[FLMut.FNum] Do If InSide(X,Y) Then
Begin
If FLCel.FLapC[GetTip-2,FLCel.FFent[GetTip-2]].GetFig=GetFig-1 Then
Begin
MoveTo((GetTip-3)*11+37,2);
FLCel.FLapC[GetTip-2,FLCel.FFent[GetTip-2]+1]:=
FLMut.FLapM[FLMut.FNum];
Inc(FLCel.FFent[GetTip-2]);
FLMut.FLapM[FLMut.FNum]:= ULap; Dec(FLMut.FNum); FLMut.Show;
End;
End Else
{Asztalról}
For I:= 1 To 7 Do For J:= 1 To 18 Do With FLAsz.FLapA[I,J] Do
If InSide(X,Y) And GetVisible And GetEnable Then
Begin
If FLCel.FLapC[GetTip-2,FLCel.FFent[GetTip-2]].GetFig=GetFig-1 Then
Begin
MoveTo((GetTip-3)*11+37,2);
FLCel.FLapC[GetTip-2,FLCel.FFent[GetTip-2]+1]:= FLAsz.FLapA[I,J];
Inc(FLCel.FFent[GetTip-2]); FLAsz.FLapA[I,J]:= ULap;
If J>1 Then
Begin
FLASz.FLapA[I,J-1].Show; FLAsz.FLapA[I,J-1].SetEnable(True)
End;
I:= 7; J:= 18;
X:= 0; Y:= 0;
End;
End;
If Vege Then Exit;
While MouseButtons=1 Do;
End;
{Ász automatikus kirakása}
If FLMut.FLapM[FLMut.FNum].GetFig=1 Then {Mutatóról}
Begin
K:= FLMut.FLapM[FLMut.FNum].GetTip;
FLMut.FLapM[FLMut.FNum].MoveTo((K-3)*11+37,2);
FLCel.FLapC[K-2,FLCel.FFent[K-2]+1]:= FLMut.FLapM[FLMut.FNum];
Inc(FLCel.FFent[K-2]);
FLMut.FLapM[FLMut.FNum]:= ULap; Dec(FLMut.FNum); FLMut.Show; Duda;
End;
For I:= 1 To 7 Do For J:= 1 To 18 Do With FLAsz.FLapA[I,J] Do
If (GetFig=1) And GetVisible Then {Asztalról}
Begin
K:= FLAsz.FLapA[I,J].GetTip;
FLAsz.FLapA[I,J].MoveTo((K-3)*11+37,2);
FLCel.FLapC[K-2,FLCel.FFent[K-2]+1]:= FLAsz.FLapA[I,J];
Inc(FLCel.FFent[K-2]); FLAsz.FLapA[I,J]:= ULap; If J>1 Then
Begin
FLAsz.FLapA[I,J-1].Show; FLAsz.FLapA[I,J-1].SetEnable(True)
End; Duda;
End;
End;
If Vege Then Exit;
{Bármely billentyûre kilép}
If KeyPressed Then Exit;
If MouseButtons=1 Then
Begin X:= MouseWhere.X+1; Y:= MouseWhere.Y+1 End;
{Kattintás a forráson}
If FLFor.InSide(X,Y) Then
Begin
If FLFor.FNum>0 Then
Begin
Inc(FLMut.FNum);
FLMut.FLapM[FLMut.FNum]:= FLFor.FLapF[FLFor.FNum];
FLMut.FLapM[FLMut.FNum].SetVisible(True);
FLMut.FLapM[FLMut.FNum].MoveTo(15,2);
FLFor.FLapF[FLFor.FNum]:= ULap;
Dec(FLFor.FNum);
End Else
Begin
For I:= 1 To FLMut.FNum Do
Begin
FLFor.FLapF[FLMut.FNum-I+1]:= FLMut.FLapM[I];
FLFor.FLapF[FLMut.FNum-I+1].SetVisible(False);
FLFor.FLapF[FLMut.FNum-I+1].MoveTo(4,2);
FLMut.FLapM[I]:= ULap;
End;
FLFor.FNum:= FLMut.FNum; FLMut.FNum:= 0;
End;
X:= 0; Y:= 0;
FLFor.Show; FLMut.Show; If Vege Then Exit; While MouseButtons=1 Do;
End;
{Kattintás a mutatón}
If X<>0 Then
If (FLMut.FNum>0) And FLMut.InSide(X,Y) Then
Begin
FLMut.FLapM[FLMut.FNum].FlashOn; While MouseButtons=1 Do;
Repeat
{Mozgás az asztal felett, a jó helyek mutatása villogással}
While (Not KeyPressed) And (MouseButtons=0) Do
Begin
X:= MouseWhere.X+1; Y:= MouseWhere.Y+1;
For I:= 1 To 7 Do For J:= 1 To 18 Do With FLAsz.FLapA[I,J] Do
If InSide(X,Y) And GetVisible And GetEnable And
(GetSzin<>FLMut.FLapM[FLMut.FNum].GetSzin) And
((GetFig-FLMut.FLapM[FLMut.FNum].GetFig)=1) And
Not GetFlash Then FlashOn Else
If Not InSide(X,Y) And
GetVisible And
GetFlash Then FlashOff;
End;
{Majd kattintás az asztalon}
If (MouseButtons=1) Then
Begin
X:= MouseWhere.X+1; Y:= MouseWhere.Y+1;
For I:= 1 To 7 Do For J:= 1 To 18 Do With FLAsz.FLapA[I,J] Do
If InSide(X,Y) And GetVisible And GetEnable And
(GetSzin<>FLMut.FLapM[FLMut.FNum].GetSzin) And
((GetFig-FLMut.FLapM[FLMut.FNum].GetFig)=1) Then
Begin
FLMut.FLapM[FLMut.FNum].FlashOff;
FLAsz.FLapA[I,J].FlashOff;
FLAsz.FLapA[I,J].SetEnable(False);
FLMut.FLapM[FLMut.FNum].MoveTo((I-1)*11+4,12+J+1);
FLAsz.FLapA[I,J+1]:= FLMut.FLapM[FLMut.FNum];
FLAsz.FLapA[I,J+1].SetEnable(True);
FLMut.FLapM[FLMut.FNum]:= ULap;
Dec(FLMut.FNum); FLMut.Show;
I:= 7; J:= 18;
End Else
If (FLAsz.FLapA[I,1].Fx=0) And
FLAsz.FLapA[I,0].InSide(X,Y) And
(FLMut.FLapM[FLMut.FNum].GetFig=13) Then
Begin
FLMut.FLapM[FLMut.FNum].MoveTo((I-1)*11+4,12+J);
FLAsz.FLapA[I,1]:= FLMut.FLapM[FLMut.FNum];
FLAsz.FLapA[I,1].SetEnable(True);
FLMut.FLapM[FLMut.FNum]:= ULap; Dec(FLMut.FNum); FLMut.Show;
I:= 7; J:= 18;
End;
While MouseButtons=1 Do;
With FLMut.FLapM[FLMut.FNum] Do If GetFlash Then FlashOff;
End;
If Vege Then Exit;
Until Keypressed Or (MouseButtons=0);
X:= 0; Y:= 0;
End;
{Elsõ kattintás az asztalon}
If X<>0 Then
For I:= 1 To 7 Do For J:= 1 To 18 Do With FLAsz.FLapA[I,J] Do
If InSide(X,Y) And GetVisible And GetEnable Then
Begin
FlashOn; While MouseButtons=1 Do;
Repeat
While (Not KeyPressed) And (MouseButtons=0) Do
Begin {Megnézi, van-e mit villogtatni}
X:= MouseWhere.X+1; Y:= MouseWhere.Y+1;
For K:= 1 To 7 Do For L:= 1 To 18 Do With FLAsz.FLapA[K,L] Do
If InSide(X,Y) And GetVisible And GetEnable And
(I<>K) And (J<>L) And
(GetSzin<>FLAsz.FLapA[I,J].GetSzin) And
((GetFig-FLAsz.FLapA[I,J].GetFig)=1) And
Not GetFlash Then FlashOn Else
If Not InSide(X,Y) And GetVisible And
GetFlash And (I<>K) And (J<>L) Then FlashOff;
End;
{Majd második kattintás az asztalon}
If (MouseButtons=1) Then
Begin
X:= MouseWhere.X+1; Y:= MouseWhere.Y+1;
For K:= 1 To 7 Do For L:= 1 To 18 Do With FLAsz.FLapA[K,L] Do
If InSide(X,Y) And GetVisible And GetEnable And
(GetSzin<>FLAsz.FLapA[I,J].GetSzin) And
((GetFig-FLAsz.FLapA[I,J].GetFig)=1) Then
Begin {Ha hely nem üres, de a lapra rátehetõ}
FLAsz.FLapA[I,J].FlashOff;
If (J>1) And FLAsz.FLapA[I,J-1].GetVisible Then
FLAsz.FLapA[I,J-1].SetEnable(True);
FLAsz.FLapA[K,L].FlashOff;
FLAsz.FLapA[K,L].SetEnable(False);
FLAsz.FLapA[I,J].MoveTo((K-1)*11+4,12+L+1);
FLAsz.FLapA[K,L+1]:= FLAsz.FLapA[I,J];
FLAsz.FLapA[I,J]:= ULap;
If J>1 Then FLAsz.FLapA[I,J-1].Show;
K:= 7; L:= 18;
End Else
If InSide(X,Y) And GetVisible And GetEnable And
Atteheto(I,K) Then
Begin
Atrak(I,K); K:= 7; L:= 18;
End Else
If (FLAsz.FLapA[K,1].Fx=0) And
FLAsz.FLapA[K,0].InSide(X,Y) And
(FLAsz.FLapA[I,J].GetFig=13) Then
Begin {Ha a hely üres és amit tenni akarunk, az egy király}
FLAsz.FLapA[I,J].FlashOff;
If (J>1) And FLAsz.FLapA[I,J-1].GetVisible Then
FLAsz.FLapA[I,J-1].SetEnable(True);
FLAsz.FLapA[I,J].MoveTo((K-1)*11+4,12+L);
FLAsz.FLapA[K,1]:= FLAsz.FLapA[I,J];
FLAsz.FLapA[I,J]:= ULap;
If J>1 Then FLAsz.FLapA[I,J-1].Show;
K:= 7; L:= 18;
End Else {Ha a hely üres, de az átrakandók közül elsõ egy király}
If (FLAsz.FLapA[K,1].Fx=0) And
FLAsz.FLapA[K,0].InSide(X,Y) And
KAtteheto(I) Then
Begin
KAtrak(I,K); K:= 7; L:= 18;
End Else FLAsz.FLapA[I,J].FlashOff;
If Vege Then Exit;
While MouseButtons=1 Do;
End;
I:= 7; J:= 18;
X:= 0; Y:= 0;
Until Keypressed Or (MouseButtons=0);
End Else
If InSide(X,Y) And
Not GetVisible And
(FLAsz.FLapA[I,J+1].Fx=0) Then
Begin
SetVisible(True); SetEnable(True); Show;
I:= 7; J:= 18;
X:= 0; Y:= 0;
End;
If Vege Then Exit;
While (MouseButtons=1) And (Not Vege) Do;
Until False;
End;
Procedure TControl.Done;
Var I, J, K: Byte;
Dx, P: Integer;
Begin
If KeyPressed Then Exit; Duda; Randomize;
For I:= 1 To 4 Do FLCel.FFent[I]:= 13;
Repeat
P:= Random(4)+1; Dx:= Random(4)-2;
If FLCel.FFent[P]>0 Then
Begin
With FLCel.FLapC[P,FLCel.FFent[P]] Do
Begin
Show;
For K:= 1 To 39 Do Begin MoveRel(Dx, 1); Delay(6) End;
End;
Dec(FLCel.FFent[P]);
End;
Until Keypressed Or
(FLCel.FFent[1]+FLCel.FFent[2]+FLCel.FFent[3]+FLCel.FFent[4]=0);
Varj;
End;
Var Control: TControl;
Begin
Control.Init;
Control.Run;
Control.Done;
End.