REM Mark's Blackjack - version 1.0a REM slightly edited by Richard Weston REM 15th January 2003 MODE8 M=0:X=0:E=0 COLOUR9 PRINT'' "This is the simple BlackJack game (21 or bust!)." COLOUR15 PRINT'"Press any key to continue." wait=GET CLS PRINT''"Do you want to load a previously saved score or start a new game? Type L or S." LS$=GET$ IF LS$="L" THEN PROCload DIM C$(52),C(52),PC$(26),DC$(26),PC(26),DC(26) REPEAT CLS FOR Q=1 TO 13 PRINT'"Hand no. ";Q FOR N=1 TO 26 PC$(N)="0" DC$(N)="0" PC(N)=0 DC(N)=0 NEXT REM NEXT PROCcards PRINT "Place your bet!" INPUT B REPEAT Y=RND(52) PC$(1)=C$(Y) IF PC$(1)="0" THEN X=0 ELSE X=1 UNTIL X=1 PC(1)=C(Y) C$(Y)="0" REPEAT Y=RND(52) PC$(2)=C$(Y) IF PC$(2)="0" THEN X=0 ELSE X=1 UNTIL X=1 PC(2)=C(Y) C$(Y)="0" REPEAT Y=RND(52) DC$(1)=C$(Y) IF DC$(1)="0" THEN X=0 ELSE X=1 UNTIL X=1 DC(1)=C(Y) C$(Y)="0" REPEAT Y=RND(52) DC$(2)=C$(Y) IF DC$(2)="0" THEN X=0 ELSE X=1 UNTIL X=1 DC(2)=C(Y) PNH=2 DNH=2 C$(Y)="0" REPEAT PNH=PNH+1 PROChit IF HS$="H" THEN PROCwanthit IF HS$="S" THEN PC$(PNH+1)="0" IF HS$="D" THEN PROCdouble IF PC$(PNH+1)="0" THEN PC(PNH+1)=0 UNTIL HS$="S" DT=DC(1)+DC(2) REPEAT DNH=DNH+1 IF DT<17 THEN PROCdealerhit ELSE PROCdealernohit DT=DT+DC(DNH) UNTIL X=1 PROCdisplaycards PRINT "Your total earnings so far are ";M;"." NEXT PROCdisplaycards PRINT " " PRINT "All the cards have been played." PRINT"Your total earnings at the end of the game were ";M;"." PRINT " " PRINT "Would you like to have another go while keeping your earnings," PRINT"have another go and reset them to zero," PRINT"reset your saved score to zero," PRINT"save them and end the game" PRINT"or just end the game?" PRINT "(Type AK, R, SR, SA or E)" INPUT W$ IF W$="R" THEN M=0 IF W$="SA" THEN PROCsave IF W$="E" THEN E=1 IF W$="SR" THEN PROCresetsaved UNTIL E=1 END : DEFPROCwin PRINT "Congratulations, you have won!" M=M+B ENDPROC : DEFPROCdraw PRINT "It's a draw." ENDPROC : DEFPROClose PRINT "Sorry, you have lost." M=M-B ENDPROC : DEFPROCresetsaved X=OPENUP("BJKS") M=0 PRINT#X,M CLOSE#X ENDPROC : DEFPROCsave X=OPENOUT("BJKS") PRINT#X,M CLOSE#X E=1 ENDPROC : DEFPROCload X=OPENIN("BJKS") IF X=0 THEN ENDPROC INPUT#X,M CLOSE#X PRINT'"Your saved score is "M wait=INKEY(200) ENDPROC : DEFPROChit CLS PRINT "You have the ";PC$(1);" and the ";PC$(2); PNH=2 REPEAT PNH=PNH+1 IF PC$(PNH)="0" THEN PRINT "." ELSE PRINT " and the ";PC$(PNH); UNTIL PC$(PNH)="0" PNH=2 PT=PC(1)+PC(2) REPEAT COLOUR(8+RND(7)) PNH=PNH+1 PT=PT+PC(PNH) UNTIL PC$(PNH+1)="0" PRINT "Your score is ";PT PRINT " " X=0 PRINT "Do you want to 'hit' - have another card," PRINT"or 'double' - have another card and double your bet?" PRINT"Type H, D or STOP" HS$=GET$ PNH=2 REPEAT COLOUR(8+RND(7)) PNH=PNH+1 IF PC$(PNH)="0" THEN X=1 UNTIL X=1 ENDPROC : DEFPROCwanthit REPEAT Y=RND(52) PC$(PNH)=C$(Y) IF PC$(PNH)="0" THEN X=0 ELSE X=1 UNTIL X=1 PC(PNH)=C(Y) C$(Y)="0" ENDPROC : DEFPROCdouble REPEAT Y=RND(52) PC$(PNH)=C$(Y) IF PC$(PNH)="0" THEN X=0 ELSE X=1 UNTIL X=1 PC(PNH)=C(Y) C$(Y)="0" B=B*2 REMHS$="S" ENDPROC : DEFPROCdealerhit REPEAT Y=RND(52) DC$(DNH)=C$(Y) IF DC$(DNH)="0" THEN X=0 ELSE X=1 UNTIL X=1 DC(DNH)=C(Y) C$(Y)="0" ENDPROC : DEFPROCcards C$(1)="Ace of Spades" C$(2)="Two of Spades" C$(3)="Three of Spades" C$(4)="Four of Spades" C$(5)="Five of Spades" C$(6)="Six of Spades" C$(7)="Seven of Spades" C$(8)="Eight of Spades" C$(9)="Nine of Spades" C$(10)="Ten of Spades" C$(11)="Jack of Spades" C$(12)="Queen of Spades" C$(13)="King of Spades" C$(14)="Ace of Clubs" C$(15)="Two of Clubs" C$(16)="Three of Clubs" C$(17)="Four of Clubs" C$(18)="Five of Clubs" C$(19)="Six of Clubs" C$(20)="Seven of Clubs" C$(21)="Eight of Clubs" C$(22)="Nine of Clubs" C$(23)="Ten of Clubs" C$(24)="Jack of Clubs" C$(25)="Queen of Clubs" C$(26)="King of Clubs" C$(27)="Ace of Hearts" C$(28)="Two of Hearts" C$(29)="Three of Hearts" C$(30)="Four of Hearts" C$(31)="Five of Hearts" C$(32)="Six of Hearts" C$(33)="Seven of Hearts" C$(34)="Eight of Hearts" C$(35)="Nine of Hearts" C$(36)="Ten of Hearts" C$(37)="Jack of Hearts" C$(38)="Queen of Hearts" C$(39)="King of Hearts" C$(40)="Ace of Diamonds" C$(41)="Two of Diamonds" C$(42)="Three of Diamonds" C$(43)="Four of Diamonds" C$(44)="Five of Diamonds" C$(45)="Six of Diamonds" C$(46)="Seven of Diamonds" C$(47)="Eight of Diamonds" C$(48)="Nine of Diamonds" C$(49)="Ten of Diamonds" C$(50)="Jack of Diamonds" C$(51)="Queen of Diamonds" C$(52)="King of Diamonds" C(1)=1 C(2)=2 C(3)=3 C(4)=4 C(5)=5 C(6)=6 C(7)=7 C(8)=8 C(9)=9 C(10)=10 C(11)=10 C(12)=10 C(13)=10 C(14)=1 C(15)=2 C(16)=3 C(17)=4 C(18)=5 C(19)=6 C(20)=7 C(21)=8 C(22)=9 C(23)=10 C(24)=10 C(25)=10 C(26)=10 C(27)=1 C(28)=2 C(29)=3 C(30)=4 C(31)=5 C(32)=6 C(33)=7 C(34)=8 C(35)=9 C(36)=10 C(37)=10 C(38)=10 C(39)=10 C(40)=1 C(41)=2 C(42)=3 C(43)=4 C(44)=5 C(45)=6 C(46)=7 C(47)=8 C(48)=9 C(49)=10 C(50)=10 C(51)=10 C(52)=10 ENDPROC : DEFPROCdealernohit X=1 DC$(DNH+1)="0" DC(DNH+1)=0 ENDPROC : DEFPROCdisplaycards CLS PRINT "Deal ";Q;"." PRINT " " PRINT "You had the ";PC$(1);" and the ";PC$(2); PNH=2 REPEAT PNH=PNH+1 IF PC$(PNH)="0" THEN PRINT "." ELSE PRINT " and the ";PC$(PNH); UNTIL PC$(PNH)="0" PT=PC(1) N=2 REPEAT PT=PT+PC(N) N=N+1 UNTIL N=25+1 DT=DC(1) N=2 REPEAT DT=DT+DC(N) N=N+1 UNTIL N=25+1 PRINT " " PRINT "The dealer had the ";DC$(1);" and the ";DC$(2); DNH=2 REPEAT DNH=DNH+1 IF DC$(DNH)="0" THEN PRINT "." ELSE PRINT " and the ";DC$(DNH); UNTIL DC$(DNH)="0" PRINT " " PRINT "Your score was ";PT PRINT "The dealer's score was ";DT PRINT " " IF PT>21 AND DT>21 THEN PROCdraw :ENDPROC IF PT<22 AND DT>21 THEN PROCwin :ENDPROC IF PT>21 AND DT<22 THEN PROClose :ENDPROC IF PT>DT AND PT<22 AND DT<22 THEN PROCwin :ENDPROC IF PT=DT AND PT<22 THEN PROCdraw :ENDPROC IF PT