home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1986 May
/
1986-05.d64
/
klondike
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
5KB
|
163 lines
10 print"[147]":poke53280,5:poke53281,5:ifpeek(14850)<>24thengosub2000
20 dn$="":ov$=""
30 bk$="[211][209][210][212][157][157][157][157][213][187][188][214]":bl$=" [157][157][157][157] ":poke53272,31
40 b2$=" "
50 dim cd$(52):c$(0)="":c$(1)="[144]":c$(2)="":c$(3)="[144]":cd$(0)=bl$
60 forx=0to3:fory=1to13
70 cd$(x*13+y)=c$(x)+"[211]"+chr$(95+y)+chr$(109+x)+"[212][157][157][157][157][213]"+chr$(173+x)+chr$(159+y)+"[214]"
80 nexty,x
90 dimdk(52),st(24),ly(7,20),uc(7),tp(7):forx=1to52:dk(x)=x:next
100 deffnr(z)=int(52*rnd(z))+1
110 deffnsu(x)=int(x/13.1)+1:deffnvl(x)=x-13*(fnsu(x)-1)
120 deffnsc(x)=(x/2=int(x/2)):gosub1190
125 iftt<=0thentt=500
130 bt=int((tt+51)/52)
140 gosub710:gosub720
150 print"[147] #1 #2 #3 #4 #5 #6 #7[144]pile"
160 printov$"[144]f2-end game":printov$"[144]f8-quit"
170 print"[144]deck [144]stack total":print"bet"
180 print"from to";
190 print""ov$"hearts[157][157][157][157][157][157][144]spades[157][157][157][157][157][157]diamonds[157][157][157][157][157][157][157][157][144]";
200 print"clubs":nb=-1:gosub940:nb=0
210 forx=1to7:print""left$(dn$,x)left$(ov$,x*4-4);:fory=xto7:ify=xthen230
220 printbk$"[145]";:goto240
230 printcd$(ly(x,x))"[145]";
240 nexty:nextx
250 print""ov$"";:forx=1to4:printbk$"[157][157][157][157]";:next:print
260 gosub740
270 gosub760:ifquthen1240
280 print"[145][145][145][145][145]":forx=1to5:printb2$:next:tt=tt-52*bg:gosub940
290 rem *** main loop
300 gw=0:gm=-1:m1=1
310 ed=0:gosub960:ifedthenprint"[147]":goto125
320 ifquthen1240
330 ifgwthen1160
340 gm=0:gosub350:goto310
350 ifm1>-1then380
360 ifdp=0thenreturn
370 sp=sp+1:st(sp)=dk(dp):dp=dp-1:print""dn$"[145][145]";:gosub740:gm=-1:return
380 ifm1=0thenc1=st(sp):c3=c1:goto400
390 c1=ly(m1,uc(m1)+1):c3=ly(m1,tp(m1))
400 ifm2>-1then600
410 ifc3=0thenreturn
420 s3=fnsu(c3):v3=fnvl(c3):ifv3-1<>pl(s3)thenreturn
430 ifnotamthen510
440 bm=0:forx=1to4:iffnsc(x)=fnsc(s3)then460
450 ifv3>pl(x)+2thenbm=-1
460 next:if(m1>0)or(v3<3)then500
470 forx=1to7:c4=ly(x,uc(x)+1):v4=fnvl(c4):ifv4<>v3-1then490
480 iffnsc(s3)<>fnsc(fnsu(c4))thenbm=-1
490 next
500 ifbmthenreturn
510 ifm1=0then570
520 c=m1:gosub1150:iftp(m1)=1thenprintbl$:tp(m1)=0:goto580
530 iftp(m1)=1thenprintbl$:tp(m1)=0:goto560
540 tp(m1)=tp(m1)-1:printbl$"[157][157][157][157][145][145]"cd$(ly(m1,tp(m1)));
550 iftp(m1)=uc(m1)thenuc(m1)=uc(m1)-1
560 goto580
570 gosub1170
580 print""ov$left$(dn$,s3*4-3)cd$(c3):pl(s3)=v3:tt=tt+5*bg:mu=-1
590 gosub940:tq=0:forq=1to4:tq=tq+pl(q):next:gw=(tq=52):gm=-1:return
600 c2=ly(m2,tp(m2)):s1=fnsc(fnsu(c1)):s2=fnsc(fnsu(c2))
610 v1=fnvl(c1):v2=fnvl(c2):if(v1=13)and(v2=0)then630
620 if(s1=s2)or(v1+1<>v2)thenreturn
630 ifm1>0then650
640 gosub1170:ly(m2,tp(m2)+1)=c1:nc=1:goto690
650 nc=tp(m1)-uc(m1):c=m1:print""left$(dn$,uc(c)+1)left$(ov$,c*4-4);
660 forx=1tonc:printbl$"[157][157][157][157]";:ly(m2,tp(m2)+x)=ly(m1,uc(m1)+x):next
670 tp(m1)=uc(m1):uc(m1)=uc(m1)-1-(uc(m1)=0)
680 iftp(m1)>0thengosub1150:printcd$(ly(m1,tp(m1)));
690 c=m2:gosub1150:print"";:forx=1tonc:printcd$(ly(m2,tp(m2)+x))"[157][157][157][157]";:next
700 tp(m2)=tp(m2)+nc:gm=-1:return
710 forx=1to52:a=fnr(0):s=dk(a):dk(a)=dk(x):dk(x)=s:next:dp=52:return
720 forx=1to7:fory=xto7:ly(y,x)=dk(dp):dp=dp-1:nexty:tp(x)=x:uc(x)=x-1:nextx
730 st(1)=dk(dp):dp=dp-1:sp=1:forx=1to4:pl(x)=0:next:return
740 print""dn$"[145]"bk$"[145]"cd$(st(sp))
750 print""dp"[157] ";tab(6)sp"[157] ";:return
760 print" please enter your bet"
770 print" maximum bet =[144]"bt
780 print" press [144]f1 to bet it all"
790 print" press [144]f7 to re-shuffle"
800 print" -> [157][157][157][157][157][157][157][144][185][157]";:n=0:bg=0:b$=""
810 geta$:ifa$=""then810
820 if(a$=chr$(133))and(n=0)thenbg=bt:return
830 if(a$=chr$(136))and(n=0)then910
840 if(a$=chr$(140))and(n=0)thenqu=-1:return
850 ifa$<>chr$(13)then880
860 bg=val(b$):ifnot((bg=0)or(bg>bt))thenreturn
870 print:print"[145] ":goto760
880 if(a$<":")and(a$>"/")and(n<11)thenb$=b$+a$:n=n+1:printa$"[185][157]";:goto810
890 if(a$=chr$(20))and(n>0)thenn=n-1:print" [157][157][185][157]";:b$=mid$(b$,1,n)
900 goto810
910 print"working":gosub710:gosub720
920 print"";:forx=1to7:printcd$(ly(x,x));:next
930 print:print""cd$(st(sp)):goto760
940 print"[144]"dn$tab(19)tt"[157] ":ifnbthenreturn
950 printtab(19)bg:return
960 ifnotgmthen1010
970 am=-1:m2=-1:ifm1>0thenmu=0:forz=1to7:m1=z:gosub350:next
980 m1=0:gosub350
990 ifmuthenm1=1:goto970
1000 am=0:ifgwthenreturn
1010 print"[144]"dn$" [157][157][157][157][157][157][157][157][157][157][157][157][157][157]";
1020 geta$:ifa$=""then1020
1030 if(a$>"0")and(a$<"8")thenm1=val(a$):printa$"";:goto1090
1040 ifa$=chr$(137)thened=-1:return
1050 ifa$="d"thenm1=-1:print"deck";:return
1060 ifa$="s"thenm1=0:print"stack";:goto1090
1070 ifa$=chr$(140)thenqu=-1:return
1080 goto1020
1090 geta$:ifa$=""then1090
1100 if(a$>"0")and(a$<"8")thenm2=val(a$):printa$;:return
1110 if(a$="p")or(a$="f")thenm2=-1:print"pile";:return
1120 goto1010
1150 print""left$(dn$,tp(c))left$(ov$,c*4-4);:return
1160 tt=tt+740*bg:print"[147]you won!":goto130
1170 sp=sp-1:ifsp=0anddp>0thensp=1:st(sp)=dk(dp):dp=dp-1
1180 gosub740:return
1190 input"[147][144]enter your name ";n$
1200 f$="@0:"+n$+".money,s,":open2,8,2,f$+"r"
1210 input#2,tt:close2
1220 open2,8,2,f$+"w"
1230 print#2,0:close2:return
1240 open2,8,2,f$+"w":print#2,tt:close2
1250 print"[147][144]goodbye..."
1260 end
2000 forx=828to885:reada:pokex,a:next:sys828
2010 forx=0to16:b=14848+x*8:c=15104+x*8:fory=2to7:reada
2020 pokeb+y,a:ifx>12thena=a/2
2030 pokec+y-1+(x>12),a:nexty
2040 pokeb,255:pokec+7,255:pokeb+1,0:pokec-6*(x>12),0:nextx
2050 forx=14984to15031:reada:pokex,a:next
2060 forx=15320to15335:reada:pokex,a:next
2070 return
2080 data169,0,141,14,220,169,51,133,1,169,0,133,251,133,253,169
2090 data208,133,252,169,56,133,254,160,0,177,251,145
2100 data253,230,251,230,253,208,246,165,252,201,215,240,7,230,252,230
2110 data254,76,85,3,169,55,133,1,169,129,141,14,220,96
2120 data 24,60,102,126,102,0
2130 data 60,102,12,48,126,0
2140 data 60,102,12,102,60,0
2150 data 102,102,126,6,6,0
2160 data 126,96,124,6,124,0
2170 data 60,96,124,102,60,0
2180 data 126,6,12,24,24,0
2190 data 60,102,60,102,60,0
2200 data 60,102,62,6,60,0
2210 data 126,24,24,24,24,0
2220 data 30,12,12,108,56,0
2230 data 60,102,102,60,14,0
2240 data 102,108,120,108,102,0
2250 data 108,254,254,124,56,16
2260 data 16,56,124,254,56,124
2270 data 24,60,126,126,60,24
2280 data 56,56,254,254,56,124
2290 data 255,51,102,204,153,51,102,204
2300 data 255,204,102,51,153,204,102,51
2310 data 0,3,3,3,3,3,3,3
2320 data 0,192,192,192,192,192,192,192
2330 data 3,3,3,3,3,3,3,0
2340 data 192,192,192,192,192,192,192,0
2350 data 204,102,51,153,204,102,51,255
2360 data 51,102,204,153,51,102,204,255