Appendix E: Tutorial Game Source Code

#!../bin/jacl
#                                                           JACL TUTORIAL GAME 
# -----------------------------------------------------------------------------
# Copyright (C) Stuart Allen 1999-2000. All rights resevered.
# -----------------------------------------------------------------------------

location bedroom : master bedroom
 west		bathroom
 south		living_room

{look
write "<P>You are in your bedroom. There is a large, soft bed "
write "in the centre of the room while a doorway to the "
write "west leads into the bathroom.^"
}

object bed: bed
  short		a "bed"
  mass		scenery

{look_under
if guide(parent) = limbo
   write "<P>Hidden under the bed you find this week's "
   write "television guide.^"
   set guide(parent) = here
   points 50
   break
endif
write "<P>You don't find anything else.^"
}

object guide: television tv tele guide
  short		a "television guide"
  long		"The television guide is here."
  parent	limbo
  mass		5

{examine : read
write "<P>It contains a listing of this week's programmes.^"
}

{give_to_rick : show_to_rick
write "<P>~Cool!~ Rick exclaims as he snatches it from your "
write "hands.^"
write "<P>Satisfied that you have achieved at least one thing "
write "today, you decide to go back to bed.^"
points 50
execute +game_over
}

location bathroom : bathroom
 east		bedroom

{look
write "<P>You are in the bathroom. The only exit from here "
write "is back east into the bedroom.^"
}

{movement
if COMPASS = east : COMPASS = out
   write "<P>You bang your head as you walk through the "
   write "doorway.^^"
   break false
endif
write "<P>The only exit from here is to the east.^"
}

object box: small wooden box
  has		CONTAINER CLOSABLE CLOSED
  short		a "small wooden box"
  long		"There is a small wooden box here."
  mass		25
  quantity	20

{close_override
write "<P>The lid creaks as you push it closed.^"
ensure box has CLOSED
}

object note: orange note
  short		an "orange note"
  long		"An orange note rests on the ground."
  parent 	box
  mass		5

{read : examine
write "<P>The note reads, ~Welcome to Jamaica and have a nice day.~^"
}

location living_room: living room
  short		the "living room"
  north		bedroom

{look
if here has VISITED
   write "<P>You have returned to the living room.^"
else
   write "<P>You are in the living room. There is a small "
   write "television perched on a low-lying table in front "
   write "of a sofa.^"
endif
}

{eachturn
set rick(status) + 1
if rick(status) = 5
   write "<P>Rick takes a sip from his drink.^"
   set rick(status) = 0
endif
}

object television: television tv tele
  short		a "television"
  mass		scenery

{examine
write "<P>There is currently a cartoon showing on the "
write "television.^"
}

{turn_off
write "<P>As you reach over and switch off the television, "
write "you get quite a shock to see Rick rapidly growing "
write "a coat of hair and foaming at the mouth. The shock "
write "of this is only surpassed by that of him sinking "
write "his newly-acquired fangs into your throat.^"
execute +game_over
}

{turn_on
write "<p>The television is already on."
}

object rick: son boy teenager rick
  has		ANIMATE
  short		name "Rick"
  long		"Rick is here, watching television."
  mass		heavy

{examine
write "<P>Rick is staring blankly at the television screen.^"
}

{talk_to
write "<P>~Uh, yeah, I'll do it in a minute,~ Rick mumbles "
write "with out looking up. You have quite a strong "
write "suspicion that he didn't really hear a word "
write "you said.^"
}

#-----------------------------------------------------------------------------
# GLOBAL FUNCTIONS 
#-----------------------------------------------------------------------------

{+header
write "Content-type: text/html"
write "Expires: -1^^"
write "<HTML><HEAD>
write "<TITLE>Tutorial Game</TITLE>"
execute "+styles"
write "<script language=~JavaScript~>"
write "function putFocus(formInst, elementInst) {"
write "if (document.forms.length > 0) {"
write "document.forms[formInst].elements[elementInst].focus();}}"
write "</script>"
write "</HEAD><body bgcolor=~blue~ onLoad=~putFocus(0,0);~>"
write "<FORM NAME=~GameForm~ METHOD=get>"
}

{+footer
write "<HR>"
write "<CENTER>"
prompt
execute "+exits"
execute "+score"
write "</CENTER>"
write "</FORM>"
write "</BODY></HTML>"
}

{+default_ask_about
if noun1 = rick
   write "<P>Rick pokes out his bottom lip then blinks several "
   write "times. This, you have figured out over the "
   write "years, translates to, ~Not a clue.~^"
   break
endif
break false
}

{+intro
if interpreter = CGIJACL
   write "<center>"
   write "<H1>TUTORIAL GAME</H1>"
   write "<p>by I.F. Author</p>"
   write "</center>"
else
   clear
   centre "T U T O R I A L   G A M E"
   centre "by I. F. Author"
   write ^^
endif
write "<P>Your alarm rings and you climb out of bed. "
write "Monday morning again so soon. Oh well, at least "
write "your house doesn't have a front door so you have "
write "a good excuse for not going to work.^^"
if here hasnt OUTDOORS
  set north_wall(parent) = here
  set south_wall(parent) = here
  set east_wall(parent) = here
  set west_wall(parent) = here
endif
set ground(parent) = here
look
}

object kryten: myself self me
 has		ANIMATE
 short		name "yourself"
 quantity	42
 parent		bedroom
 player

{examine
write "<P>As beautiful as ever.<P>^"
execute "+inventory"
}

grammar about >about

{+about
write "This is the game from the tutorial section of the JACL Author's Guide."
write "See the appendix for the full source to this program.^"
}

{+game_over
write "<P>^"
write "<center>"
write "<h2>---[THE END]---</h2>"
write "</center>"
loop
   if noun3(parent) = player
      set noun3(parent) = limbo
   endif 
endloop
set player(parent) = prologue
look
}   

location prologue : prologue

{look
write "<p>The game is over. Type <b>restart</b> or <b>restore</b>. "
write "A <b>restore</b> command can optionally be followed by a filename.</p>^"
}

{+styles
write "<style>"
write "  <!--"
write "  P { 		font-family: Helvetica, Arial, Sanserif; "
write "			color: white; font-size: 14pt}"
write "  A { 		font-family: Helvetica, Arial, Sanserif; "
write "			color: yellow; font-size: 14pt}"
write "  H1 { 		font-family: Times, Garamond, serif; "
write "			color: white; font-size: 24pt}"
write "  H2 { 		font-family: Times, Garamond, serif; "
write "			color: white; font-size: 18pt}"
write "  -->"
write "</style>"
}

#include "verbs.library"