home *** CD-ROM | disk | FTP | other *** search
- //⌐ David Jean, 1993
- game klondike is 29 by 20;
-
- // D1 D2 A1 A2 A3 A4
- // B1 B2 B3 B4 B5 B6 B7
-
- {--------------------------------------------------------------------------}
-
- #include 'predicat.cdh'
- #include 'function.cdh'
- #include 'deck.cdh'
-
- {--------------------------------------------------------------------------}
-
- procedure About is
- begin
- Clear 'About Klondike';
- write('Rules from : RΘglements officiels des jeux de cartes, Intl. playing card company limited, 1977.\n');
- write('Program : ⌐ David Jean, 1993.\n');
- end;
-
- #include 'rightbut.cdh'
-
- var f : integer;
-
- stack D2, A1, A2, A3, A4, B1, B2, B3, B4, B5, B6, B7;
-
- stack D1 is
- X := 2;
- Y := 2;
- Direction := over;
- W := 3;
- H := 4;
- Handler := VCARDS;
- //****************************
- Start is OneDeckDown;
- //****************************
- SelectLeftFrom(Spos : Index) is
- var i : integer;
- begin
- i:=Min(!,3);
- if i=0 then
- begin
- Pull D2! From D2;
- Turn [1..!] Side Down;
- Inverse [1..!];
- [0]:=EmptyCard;
- f:=!;
- end
- else
- begin
- Turn [!-i+1..!] Side Up;
- Inverse [!-i+1..!];
- Pull 3 To D2;
- if (!=0) and (f=D2!) then [0]:=CrossCard;
- end;
- end;
- //****************************
- Help is
- begin
- Clear 'The Stock';
- Write('You can click here to move three cards to The Waste Pile or ');
- Write('to turn The Waste Pile over when The Stock is empty.\n');
- Wait 'About...' About;
- end;
- end D1;
-
- stack D2 is
- X := 6;
- Y := 2;
- Direction := over;
- W := 3;
- H := 4;
- Handler := VCARDS;
- //****************************
- Start is f:=D1!;
- //****************************
- SelectLeftFrom(Spos : Index) is
- if !<>0 then Pull 1 To Cursor;
- //****************************
- SelectRightFrom(Spos : Index) is
- if !>0 then
- begin
- Pull 1 to Cursor;
- PollLeftTo(|A1,A2,A3,A4,B1,B2,B3,B4,B5,B6,B7|);
- end;
- //****************************
- Help is
- begin
- Clear 'The Waste Pile';
- Write('The topmost card of this pile is available to play on The Tableau or The Foundation.\n\n');
- Write('You can Drag cards from here by using the left mouse button.\n');
- Wait 'Right Button...' RButton;
- Wait 'About...' About;
- end;
- end D2;
-
- {--------------------------------------------------------------------------}
-
- stack A1 is
- X := 14;
- Y := 2;
- Direction := over;
- W := 3;
- H := 4;
- Handler := VCARDS;
- //****************************
- Start is
- begin
- [0]:=Ace+Spade;
- Turn [0] Side Shaded;
- end;
- //****************************
- SelectLeftTo(Spos : Index) is
- begin
- if Cursor!=1 then
- if (!=0) and SameCard?([0],Cursor[1]) then
- Pull 1 From Cursor
- else if SameSuit?(Cursor[1],[!]) and
- FollowRankWrap?([!],Cursor[1]) then
- Pull 1 From Cursor;
- end;
- //****************************
- Help is
- begin
- Clear 'Foundations';
- Write('Plays are made to the Foundations in the same suit and in ascending order.\n\n');
- Write('The goal is to move all 52 cards here.\n\n');
- Write('At the start, this stack is grayed to indicate which card must be played here first.\n');
- Wait 'About...' About;
- end;
- end A1;
-
- stack A2 from A1 is
- X := 18;
- Y := 2;
- //****************************
- Start is
- begin
- [0]:=Ace+Heart;
- Turn [0] Side Shaded;
- end;
- end A2;
-
- stack A3 from A1 is
- X := 22;
- Y := 2;
- //****************************
- Start is
- begin
- [0]:=Ace+Club;
- Turn [0] Side Shaded;
- end;
- end A3;
-
- stack A4 from A1 is
- X := 26;
- Y := 2;
- //****************************
- Start is
- begin
- [0]:=Ace+Diamond;
- Turn [0] Side Shaded;
- end;
- end A4;
-
- {--------------------------------------------------------------------------}
-
- stack B1 is
- X := 2;
- Y := 7;
- Direction := down;
- W := 3;
- H := 13;
- Handler := VCARDS;
- //****************************
- Start is
- begin
- Pull 1 From D1;
- Turn [1] Side Up;
- Draw D1;
- end;
- //****************************
- SelectLeftFrom(Spos : Index) is
- begin
- if SPos>! then SPos:=!;
- if IsSideDown?([Spos]) then break procedure;
- Pull !-Spos+1 To Cursor;
- end;
- //****************************
- SelectLeftTo(Spos : Index) is
- begin
- if (!=0) and IsKing?(Cursor[1]) then
- Pull Cursor! From Cursor
- else if AlternateColor?(Cursor[1],[!]) and
- FollowRankWrap?(Cursor[1],[!]) then
- Pull Cursor! From Cursor;
- end;
- //****************************
- SelectRightFrom(Spos : Index) is
- if !>0 then
- begin
- if SPos>! then SPos:=!;
- if IsSideDown?([Spos]) then break;
- Pull !-Spos+1 to Cursor;
- PollLeftTo(|A1,A2,A3,A4,B1,B2,B3,B4,B5,B6,B7|);
- end;
- //****************************
- Help is
- begin
- Clear 'The Tableau';
- Write('Each card played here must be in descending sequence and of alternating color ');
- Write('to the card on which it is played.\n\n');
- Write('The bottommost card can be played to The Foundation.\n\n');
- Write('You can pick any sequence of cards, ending with the bottommost card, ');
- Write('to move to another pile in The Tableau.\n\n');
- Write('Only Kings can be moved in an empty spot on The Tableau.\n');
- Wait 'Right Button...' RButton;
- Wait 'About...' About;
- end;
- end B1;
-
-
- stack B2 from B1 is
- X := 6;
- Y := 7;
- //****************************
- Start is
- begin
- Pull 2 From D1;
- Turn [2] Side Up;
- Draw D1;
- end;
- end B2;
-
- stack B3 from B1 is
- X := 10;
- Y := 7;
- //****************************
- Start is
- begin
- Pull 3 From D1;
- Turn [3] Side Up;
- Draw D1;
- end;
- end B3;
-
- stack B4 from B1 is
- X := 14;
- Y := 7;
- //****************************
- Start is
- begin
- Pull 4 From D1;
- Turn [4] Side Up;
- Draw D1;
- end;
- end B4;
-
- stack B5 from B1 is
- X := 18;
- Y := 7;
- //****************************
- Start is
- begin
- Pull 5 From D1;
- Turn [5] Side Up;
- Draw D1;
- end;
- end B5;
-
- stack B6 from B1 is
- X := 22;
- Y := 7;
- //****************************
- Start is
- begin
- Pull 6 From D1;
- Turn [6] Side Up;
- Draw D1;
- end;
- end B6;
-
- stack B7 from B1 is
- X := 26;
- Y := 7;
- //****************************
- Start is
- begin
- Pull 7 From D1;
- Turn [7] Side Up;
- Draw D1;
- end;
- end B7;
-
- {--------------------------------------------------------------------------}
-
- predicate Win? is return (A1!=13) and (A2!=13) and (A3!=13) and (A4!=13);
-
- predicate Integrity? is
- begin
- with it do
- if (it!>0) and IsSideDown?(it[it!]) then Turn it[it!] Side Up
- for B1, B2, B3, B4, B5, B6, B7;
-
- return TRUE;
- end;
-
- order D1, A1, A2, A3, A4, B1, B2, B3, B4, B5, B6, B7, D2;
- title:='Klondike'.
-