home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 18
/
018.d81
/
solitaire
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
6KB
|
236 lines
995 poke53280,0:poke53281,13
999 print"[147]"
1000 rem ******************************
1010 rem
1020 rem s o l i t a i r e
1030 rem
1040 rem
1050 rem
1060 rem ******************************
1070 print"[144]shuffling cards for a game of solitaire!"
1090 print: print: print: print" i'll be ready in a few seconds..."
1100 forx=1 to val(right$(ti$,2))
1110 r=rnd(1):next x
1120 dim f(7,18),s(4),d(52),s$(4):rb=1
1130 s$(1)="[211]":s$(2)="[218]":s$(3)="[193]":s$(4)="[216]"
1140 rem suit#1 = hearts
1150 rem suit#2 = diamonds
1160 rem suit#3 = spades
1170 rem suit#4 = clubs
1180 :
1190 forx=0 to 7: fory=0to18:f(x,y)=0:next y,x
1200 forx=0to4:s(x)=0:nextx
1210 forx=0to52:d(x)=0:nextx
1220 rem *** shuffle cards in deck
1230 forx=1to52
1240 r=int(rnd(1)*52+1): ifd(r)>0then1240
1250 d(r)=x:nextx
1260 rem *** deal cards into piles
1270 r=52:forx=1to7:fory=1tox
1280 f(x,y)=d(r)+100
1290 d(r)=0:r=r-1:nexty
1300 f(x,x)=f(x,x)-100:nextx
1310 rem *** display everything
1320 c=3:c2=3:gosub2730
1330 rem ***command input
1340 print"";
1360 l=3:gosub3080
1370 if s(1)+s(2)+s(3)+s(4)<>130then1390
1380 l=3:gosub3080
1385 l=1:gosub3060:print"[144]congratulations, y o u w i n !":goto1510
1390 print"[144]d=deck, row#1-7, c=card, q=quit";:poke198,0:wait198,1:getp$
1392 p=val(p$)
1400 if(p>7)or(p<0)then2360
1410 ifp>0then1840
1420 ifp$="c"thengosub2900:goto1340:rem next card
1430 ifp$<>"q"goto1550
1440 rem *** quitter!
1450 forx=1to7:fory=1to18
1460 iff(x,y)>100thenf(x,y)=f(x,y)-100
1470 nexty,x
1480 gosub2830
1490 l=3:gosub3080
1500 l=1:gosub3060:print"[144]sorry, better luck next time !!!"
1510 print"want to play again (y/n) ?"
1520 getp$:ifp$= "y"then goto 5000
1530 ifp$<>"n"then1520
1540 goto63000
1550 ifp$<>"d"goto2360
1560 rem *** from deck to ...
1570 if d(1)=0then2370
1580 v=d(c):s1=int((d(c)-1)/13)+1
1590 ifv>13thenv=v-13:goto1590
1600 l=1:gosub3060
1610 print"from deck to (a=aces, row#1-7) ";:poke198,0:wait198,1:getr$
1620 ifr$<>"a"then1700
1630 rem *** deck to aces
1640 if s1<>(d(c)+12)/13then1670
1650 if s(s1)>0then2370
1660 goto1680
1670 ifd(c)<>s(s1)+1then2370
1680 s(s1)=d(c):x=s1:gosub2420:gosub3130:goto1340
1690 rem ***deck to row
1700 r=val(r$)
1710 y=1:if(r<1)or(r>7)then2360
1720 ify>18then2370
1730 if f(r,y)<>0theny=y+1:goto1720
1740 ify>1then1770
1750 ifv=13then1820
1760 goto2370
1770 v1=f(r,y-1)
1780 ifv1>13thenv1=v1-13:goto1780
1790 ifv<>v1-1then2370
1800 s2=int((f(r,y-1)-1)/26):s1=int((s1-1)/2)
1810 ifs1=s2then2370
1820 f(r,y)=d(c):gosub3180:gosub3130:gosub2830:goto1340
1830 rem ** from row to...
1840 y=0:iff(p,1)=0then2370
1850 rem *** single card in row?
1860 y=y+1: ify>18then2370
1870 y2=f(p,y): if y2>100then1860
1880 if f(p,y+1)<>0then1920
1890 if y2>13theny2=y2-13:goto1890
1900 goto2030
1910 rem *** from what card in row?
1920 l=1:gosub3060
1930 print"from row";p;"card (a,2-10,j,q,k) "
1934 gety$:ify$=""then1934
1935 y1=val(y$)
1936 ify1=1theny1=10
1940 ify$="a"theny1=1
1950 ify$="j"theny1=11
1960 ify$="q"theny1=12
1970 ify$="k"theny1=13
1980 if(y1=0)or(y1>13)then2360
1990 ify>18then2370
2000 y2=f(p,y):ify2>100theny=y+1:goto1990
2010 if y2>13theny2=y2-13:goto2010
2020 if y1<>y2 then y=y+1:goto1990
2030 r=f(p,y):l=1:gosub3060
2040 print"from ";:gosub2520
2050 print"[144] row";p;"to (a=aces,row#1-7)";:poke198,0:wait198,1:geta$
2060 rem *** from row/card to ...
2070 s1=int((f(p,y)-1)/13)+1
2080 ifa$<>"a"then2180
2090 rem *** from row/card to aces
2100 if f(p,y+1)>0then2370
2110 ifs1<>(f(p,y)+12)/13then2140
2120 ifs(s1)>0then2370
2130 goto2150
2140 if f(p,y)<>s(s1)+1then2370
2150 s(s1)=f(p,y):f(p,y)=0:if f(p,y-1)>100thenf(p,y-1)=f(p,y-1)-100
2160 gosub3180:gosub2830:x=s1:gosub2420:goto1340
2170 rem *** from row/card to row
2180 q=val(a$)
2190 z=1:if(q<1)or(q>7)then2360
2200 ifz>18then2250
2210 iff(q,z)<>0thenz=z+1:goto2200
2220 ifz>1then2250
2230 ify2=13then2300
2240 goto2370
2250 v1=f(q,z-1)
2260 ifv1>13thenv1=v1-13:goto2260
2270 ify2<>v1-1then2370
2280 s2=int((f(q,z-1)-1)/26):s1=int((s1-1)/2)
2290 ifs1=s2then2370
2300 if f(p,y-1)>100thenf(p,y-1)=f(p,y-1)-100
2310 f(q,z)=f(p,y):f(p,y)=0
2320 y=y+1:z=z+1
2330 iff(p,y)<>0then2310
2340 gosub3180:gosub2830:ifrb=0thengosub3034
2345 goto1340
2350 rem *** errors!
2360 print:print"[145] invalid response! ":goto2380
2370 print:print"[145] illegal play! "
2380 t=ti
2390 if(ti-t)<50goto2390
2400 goto1340
2410 rem *** display aces
2420 print"";
2430 forx1=1tox:print"";:nextx1
2440 if(s(x)=0)and(x>2)thenprint"--";s$(x):return
2450 ifs(x)=0thenprint"[149] ";s$(x);"[146][144]":return
2460 r=s(x):gosub2520:print:return
2470 rem *** display cards in piles
2480 r=f(x,y)
2490 if r=0thenprint" ";:return
2500 ifr>100thenprint"[144][207][183][208]";:return
2510 rem *** print card
2520 r1=r
2525 print"";
2530 ifr1>13thenr1=r1-13:goto2530
2540 ifr<27thenprint"[149]";:goto2550
2545 print"[144]";
2550 on r1 goto 2570,2580,2590,2600,2610,2620
2560 on r1-6goto2630,2640,2650,2660,2670,2680,2690
2570 print" a";:goto2700
2580 print" 2";:goto2700
2590 print" 3";:goto2700
2600 print" 4";:goto2700
2610 print" 5";:goto2700
2620 print" 6";:goto2700
2630 print" 7";:goto2700
2640 print" 8";:goto2700
2650 print" 9";:goto2700
2660 print"10";:goto2700
2670 print" j";:goto2700
2680 print" q";:goto2700
2690 print" k";
2700 r9=int((r-1)/13)+1
2710 prints$(r9);"[146]";:return
2720 rem *** display aces & rows
2730 print"[147]rows -1- -2- -3- -4- -5- -6- -7-"
2740 printchr$(17);chr$(17);chr$(192);chr$(192);chr$(192);chr$(192);chr$(238)
2750 print"aces";
2760 forxx=1to8:printchr$(221);chr$(17);chr$(157);:nextxx
2770 printchr$(221)
2780 printchr$(192);chr$(192);chr$(192);chr$(192);chr$(253)
2790 forx=1to4:gosub2420:nextx
2800 gosub2830
2810 goto2960
2820 rem *** update row display
2830 print"";
2840 fory=1to18
2850 y9=y-11:ify<12theny9=1
2860 printtab(4+((y9-1)*5));
2870 forx=y9to7:printspc(2);:gosub2480
2880 nextx:print:nexty:return
2890 rem *** next 3rd card in deck
2900 ifd(1)=0then2960
2910 x=0:fory=1to24:ifd(y)<>0thenx=x+1:nexty:ifflthenc=c2
2920 ifc=xthenc=3:goto2945
2930 c=c+3
2940 ifc>xthenc=c-1:goto2940
2945 c2=c:fl=0
2955 rem *** update deck display
2960 print"deck"
2980 print" ":rem 27 spaces
2990 print"[145]";
3000 ifd(1)=0thenprint" ";:goto3020:rem 3 spaces in print
3010 r=d(c):gosub2520
3020 x=0:fory=1to24:ifd(y)<>0thenx=x+1:nexty
3030 printtab(10);"[144](";x;"cards left )"
3032 ifx<>0then3040
3034 rb=0:cr$="no":forzr=1to7:forzc=1to18
3036 iff(zr,zc)>100thencr$="yes"
3038 nextzc:nextzr:ifcr$="no"then1380
3040 return
3050 rem *** back up lines then clear
3060 forl1=1tol:print"[145]";:nextl1
3070 rem *** blank lines!
3080 forl1=1tol
3090 print" ":rem 39 spaces
3100 nextl1
3110 forl1=1tol:print"[145]";:nextl1:return
3120 rem *** remove card from deck & disp
3130 forx=cto24:d(x)=d(x+1):nextx
3140 ifd(1)=0then3170
3145 ifflthenc2=c2-1
3150 c=c-1:ifnotflthenc2=c
3155 fl=-1
3160 ifc<1thenc=c2:gosub2900:return
3170 gosub2960:return
3180 print:print"please wait while i fix the cards !":return
5000 run
63000 load"payload connect",8