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