Akalabeth Main Game File

31 thoughts
last posted April 5, 2014, 6 a.m.

1 earlier thought

0

Adventure Shop

The very last routine is a good place to start. It's the adventure shop.

First we clear the screen and print the title.

60200  HOME : PRINT "WELCOME TO THE ADVENTURE SHOP"

Next we ask the player what item they want to buy (they just press a key).

60210  PRINT "WHICH ITEM SHALT THOU BUY ";: GET Q$: IF Q$ = "Q" THEN  PRINT : PRINT "BYE": FOR Z = 1 TO 1000: NEXT : TEXT : HOME : RETURN

If "Q" is pressed, we say BYE, pause, clear the screen again and return.

Next, given what was pressed, we work out the corresponding index Z into some array and price P.

We initially set Z to -1 so we know if we've fallen through the if statements without matching anything.

60215 Z =  - 1
60220  IF Q$ = "F" THEN  PRINT "FOOD":Z = 0:P = 1
60221  IF Q$ = "R" THEN  PRINT "RAPIER":Z = 1:P = 8
60222  IF Q$ = "A" THEN  PRINT "AXE":Z = 2:P = 5
60223  IF Q$ = "S" THEN  PRINT "SHIELD":Z = 3:P = 6
60224  IF Q$ = "B" THEN  PRINT "BOW":Z = 4:P = 3
60225  IF Q$ = "M" THEN  PRINT "AMULET":Z = 5:P = 15

If Z is still -1, we did match anything so display and message and try again:

60226  IF Z =  - 1 THEN  PRINT Q$: PRINT "I'M SORRY WE DON'T HAVE THAT.": GOTO 60210

Next we check if the player's class allows them to have a rapier or bow. Class is stored in PT$ and M corresponds to a Mage.

60227  IF Q$ = "R" AND PT$ = "M" THEN  PRINT "I'M SORRY MAGES": PRINT "CAN'T USE THAT!": GOTO 60210
60228  IF Q$ = "B" AND PT$ = "M" THEN  PRINT "I'M SORRY MAGES": PRINT "CAN'T USE THAT!": GOTO 60210

Next we check if the player can afford the price P. C(5) seems to be the amount of gold the player has.

60230  IF C(5) - P < 0 THEN  PRINT "M'LORD THOU CAN NOT AFFORD THAT ITEM.": GOTO 60210

PW seams to be an array of how many items of each type the player has. Normally buying an item increments its count by 1 but food is incremented by 10 so in that case we first increment it by 9 before the general case increments it by another one. We also subtract the price P from C(5).

60235  IF Z = 0 THEN PW(Z) = PW(Z) + 9
60236 PW(Z) = PW(Z) + 1:C(5) = C(5) - P

Finally, we update the display with the new counts:

60237  VTAB (10): HTAB (16): PRINT C(5);"  "
60240  VTAB (5 + Z): HTAB (25 -  LEN ( STR$ (PW(Z)))): PRINT PW(Z);: HTAB (1): VTAB (14): PRINT

and go back to asking if they want to buy anything else:

60250  GOTO 60210

29 later thoughts