home *** CD-ROM | disk | FTP | other *** search
/ 300 Favorite Games / 300GAMES.iso / 61 / solii.cdl < prev    next >
Text File  |  1994-01-30  |  5KB  |  238 lines

  1. //⌐ David Jean, 1993
  2. game solII is 37 by 20;
  3.  
  4. //A1 A2 A3 A4 B1 B2 B3 B4 C1
  5.  
  6. {--------------------------------------------------------------------------}
  7.  
  8. #include 'predicat.cdh'
  9. #include 'sequence.cdh'
  10. #include 'deck.cdh'
  11.  
  12. {--------------------------------------------------------------------------}
  13.  
  14. procedure About is
  15. begin
  16.   Clear 'About Solitaire II';
  17.   write('Rules from : ?.\n');
  18.   write('Program : ⌐ David Jean, 1993.\n');
  19. end;
  20.  
  21. stack A1, A2, A3, A4, B1, B2, B3, B4;
  22.  
  23. {--------------------------------------------------------------------------}
  24.  
  25. predicate EmptySpot? is 
  26. begin
  27.   with it do
  28.     if it!=0 then return TRUE
  29.   for A1, A2, A3, A4, B1, B2, B3, B4;    
  30.   return FALSE;
  31. end;
  32.  
  33. predicate IsIn?(fs : stack; c1 : card) is
  34. var i : integer;
  35. begin
  36.   i:=1;
  37.   while i<=fs! do
  38.     if fs[i]=c1 then
  39.       begin
  40.       flash fs[i];
  41.       return TRUE;
  42.       end
  43.     else i:=i+1;
  44.   return FALSE;
  45. end;
  46.  
  47. predicate KingIsIn?(fs : stack) is
  48. var i : integer,
  49.     r : boolean;
  50. begin
  51.   //on commence a 2 parce qu'on s'en fout si un roi est le premier d'une pile
  52.   i:=2;
  53.   r:=FALSE;
  54.   while i<=fs! do
  55.     begin
  56.     if not IsSideDown?(fs[i]) then
  57.       if IsKing?(fs[i]) then
  58.         begin
  59.         flash fs[i];
  60.         r:=TRUE;
  61.         end;
  62.     i:=i+1;
  63.     end;
  64.   return r;
  65. end;
  66.  
  67. predicate Visible?(fs : stack; c1 : card) is
  68. begin
  69.   with it do
  70.     if it<>fs then
  71.       if IsIn?(it,c1) then return TRUE
  72.   for A1, A2, A3, A4, B1, B2, B3, B4;    
  73.   return FALSE;
  74. end;
  75.  
  76. predicate KingVisible?(fs : stack) is
  77. var r : boolean;
  78. begin
  79.   r:=FALSE;
  80.   with it do
  81.     if it<>fs then
  82.       if KingIsIn?(it) then r:=TRUE
  83.   for A1, A2, A3, A4, B1, B2, B3, B4;    
  84.   return r;
  85. end;
  86.  
  87. {--------------------------------------------------------------------------}
  88.  
  89. stack C1 is
  90.   X := 34;
  91.   Y := 2;
  92.   Direction := over;
  93.   W := 3;
  94.   H := 4;
  95.   //****************************
  96.   Start is OneDeckDown;
  97.   //****************************
  98.   Select(Spos : Index) is
  99.   var movepossible : boolean;
  100.     begin
  101.     movepossible:=FALSE;
  102.     with it do
  103.       if (it!=0) and KingVisible?(it) then movepossible:=TRUE
  104.       else if not IsAce?(it[it!]) and Visible?(it,it[it!]-1) then movepossible:=TRUE
  105.     for A1, A2, A3, A4, B1, B2, B3, B4;
  106.     if movepossible or (!=0) then break;
  107.     with it do
  108.       begin
  109.       Pull 1 to it;
  110.       Turn it[it!] side up;
  111.       Draw it;
  112.       end
  113.     for A1, A2, A3, A4;
  114.     end;
  115.   //****************************
  116.   Help is
  117.     begin
  118.     Clear 'The Stock';
  119.     Write('You can click here to move the four remaining cards to ');
  120.     Write('the first four pile on The Tableau.\n');
  121.     Write('It will work only if no move can be made on The Tableau.\n');
  122.     Write('If there are legal moves, they will flash.\n');    
  123.     Wait 'About...' About;
  124.     end;
  125. end C1;
  126.  
  127. {--------------------------------------------------------------------------}
  128.  
  129. stack A1 is
  130.   X := 2;
  131.   Y := 2;
  132.   Direction := down;
  133.   W := 3;
  134.   H := 18;
  135.   //****************************
  136.   Start is
  137.     begin
  138.     Pull 6 from C1;
  139.     Turn [1..6] side up;
  140.     Draw C1;
  141.     end;
  142.   //****************************
  143.   Select(Spos : Index) is
  144.     begin
  145.     if Spos>! then Spos:=!;
  146.     if IsSideDown?([Spos]) then break;
  147.     if IsKing?([Spos]) then
  148.       with it do
  149.         if (it!=0) then
  150.           begin
  151.           Pull !-Spos+1 to it;
  152.           break procedure;
  153.           end
  154.       for A1, A2, A3, A4, B1, B2, B3, B4      
  155.     else
  156.       with it do
  157.         if it<>self then
  158.           if FollowSuit?(it[it!],[Spos]) then
  159.         begin
  160.             Pull !-Spos+1 to it;
  161.             break procedure; 
  162.             end
  163.       for A1, A2, A3, A4, B1, B2, B3, B4;
  164.     end;
  165.   //****************************
  166.   Help is
  167.     begin
  168.     Clear 'The Tableau';
  169.     Write('Each card played here must be of the same suit and be in descending ');
  170.     Write('sequence to the card on which it is played.\n');
  171.     Write('You can pick a card anywhere on The Tableau (if it is side up).\n');
  172.     Write('Every cards below the one you choose will move with it.\n\n');
  173.     Write('Only kings can be moved in an empty spot.\n\n');
  174.     Write('The goal is four piles of a unique suit beginning with The King and ending with The Ace.\n'); 
  175.     Wait 'About...' About;
  176.     end;
  177. end A1;
  178.  
  179. stack A2 from A1 is
  180.   X := 6;
  181. end A2;
  182.  
  183. stack A3 from A1 is
  184.   X := 10;
  185. end A3;
  186.  
  187. stack A4 from A1 is
  188.   X := 14;
  189. end A4;
  190.  
  191. stack B1 from A1 is
  192.   X := 18;
  193.   //****************************
  194.   Start is
  195.     begin
  196.     Pull 6 from C1;
  197.     Turn [3..6] side up;
  198.     Draw C1;
  199.     end;
  200. end B1;
  201.  
  202. stack B2 from B1 is
  203.   X := 22;
  204. end B2;
  205.  
  206. stack B3 from B1 is
  207.   X := 26;
  208. end B3;
  209.  
  210. stack B4 from B1 is
  211.   X := 30;
  212. end B4;
  213.  
  214. {--------------------------------------------------------------------------}
  215.  
  216. predicate win? is
  217. begin
  218.   with it do
  219.     if (it!=13) then
  220.       if not (it.KingToAceSuit?) then return FALSE
  221.       else 
  222.     else if (it!<>0) then return FALSE  
  223.   for A1, A2, A3, A4, B1, B2, B3, B4;      
  224.   return TRUE;
  225. end;
  226.  
  227. predicate Integrity? is
  228. begin
  229.   with it do
  230.     if it!>0 then
  231.       if IsSideDown?(it[it!]) then
  232.         Turn it[it!] side up
  233.   for B1, B2, B3, B4;
  234.   return TRUE;
  235. end;
  236.  
  237. order C1, A1, A2, A3, A4, B1, B2, B3, B4;
  238.   title:='Solitaire II'.