home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Home Edutainment Collection 5: Windows Games
/
Aztech-HomeEdutainmentCollection-Vol5-WindowsGames.iso
/
cardws12
/
klondike.cdl
< prev
next >
Wrap
Text File
|
1993-09-21
|
9KB
|
402 lines
//⌐ David Jean, 1993
game klondike is 29 by 20;
// D1 D2 A1 A2 A3 A4
// B1 B2 B3 B4 B5 B6 B7
{--------------------------------------------------------------------------}
{****c1 et c2 sont de meme sorte}
predicate SameSuite?(c1, c2 : Card) is
return (c1 / 13) = (c2 / 13);
{****c2 est un de plus que c1}
predicate FollowSuiteWrap?(c1, c2 : Card) is
return ((c1 + 1) mod 13) = (c2 mod 13);
{****c1 et c2 sont de couleurs diffente}
predicate AlternateColor?(c1, c2 : Card) is
return (((c1 / 13) + (c2 / 13)) mod 2) = 1;
{****c1 et c2 sont du meme Rang}
predicate SameRank?(c1, c2 : Card) is
return (c1 mod 13) = (c2 mod 13);
{****c1 et c2 ont la meme face}
predicate SameCard?(c1, c2 : Card) is
return (c1 mod DeckSize) = (c2 mod DeckSize);
{****verifie si c1 est un roi}
predicate IsKing?(c1 : card) is
return (c1 mod 13)=King;
function min(a, b : integer): integer is
if a<b then return a else return b;
predicate IsSideDown?(c1 : card) is
return (c1 / DeckSize)=down;
{--------------------------------------------------------------------------}
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;
procedure RButton is
begin
Clear 'Right Mouse Button';
Write('If you click here with the right button, the card will automatically ');
Write('go to the most appropriate place, looking for a spot in The Foundation first ');
Write('and then to the Tableau.\n');
Write('If the card can\'t be played nothing will happen.\n');
Wait 'About...' About;
end;
var f : integer;
stack D2;
stack A1;
stack A2;
stack A3;
stack A4;
stack B1;
stack B2;
stack B3;
stack B4;
stack B5;
stack B6;
stack B7;
stack D1 is
X := 2;
Y := 2;
Direction := over;
W := 3;
H := 4;
//****************************
Start is
begin
Add Ace+Spade .. King+Diamond;
Turn [1..52] side down;
Shuffle;
end;
//****************************
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:=1;
end
else
begin
Turn [!-i+1..!] Side Up;
Inverse [!-i+1..!];
Pull 3 To D2;
if (!=0) and (f=1) 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;
//****************************
Start is f:=1;
//****************************
SelectLeftFrom(Spos : Index) is
begin
if !<>0 then
begin
f:=2;
Pull 1 To Cursor;
end;
end;
//****************************
SelectRightFrom(Spos : Index) is
begin
with it do
if !<>0 then
if ((it!=0) and SameCard?([!],it[0])) or
(SameSuite?(it[it!],[!]) and FollowSuiteWrap?(it[it!],[!])) then
begin
Pull 1 To it;
f:=2;
break procedure;
end
for A1, A2, A3, A4;
with it do
if !<>0 then
if ((it!=0) and IsKing?([!])) or
(AlternateColor?(it[it!],[!]) and
FollowSuiteWrap?([!],it[it!])) then
begin
Pull 1 To it;
f:=2;
break procedure;
end
for 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;
//****************************
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 SameSuite?(Cursor[1],[!]) and
FollowSuiteWrap?([!],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;
//****************************
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
FollowSuiteWrap?(Cursor[1],[!]) then
Pull Cursor! From Cursor;
end;
//****************************
SelectRightFrom(Spos : Index) is
begin
if SPos>! then SPos:=!;
if IsSideDown?([Spos]) then break procedure;
if Spos=! then
with it do
if !<>0 then
if ((it!=0) and SameCard?([!],it[0])) or
(SameSuite?(it[it!],[!]) and FollowSuiteWrap?(it[it!],[!])) then
begin
Pull 1 To it;
break procedure;
end
for A1, A2, A3, A4;
with it do
if !<>0 then
if ((it!=0) and IsKing?([Spos])) or
(AlternateColor?(it[it!],[Spos]) and
FollowSuiteWrap?([Spos],it[it!])) then
begin
Pull !-Spos+1 To it;
break procedure;
end
for 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 Loose? is return FALSE;
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, D2, A1, A2, A3, A4, B1, B2, B3, B4, B5, B6, B7.