Skip to content

Commit

Permalink
StdLib Man: Short Examples
Browse files Browse the repository at this point in the history
Implement as external sources the short examples of Ch.15.
Some example files are deployed to `extras/manual`, others not.
  • Loading branch information
tajmone committed May 30, 2019
1 parent d9a2f8c commit 137b3cc
Show file tree
Hide file tree
Showing 13 changed files with 447 additions and 298 deletions.
18 changes: 9 additions & 9 deletions extras/manual/StdLibMan.html

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions extras/manual/short-example1.alan
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--------------------------------------------------------------------------------
-- A very short complete game using minimal obligatory imports and coding.
-- To win the game, the hero must go from room1 north to room2 and eat an apple.
--------------------------------------------------------------------------------

IMPORT 'library.i'.

THE my_game ISA DEFINITION_BLOCK
END THE.

THE room1 ISA LOCATION
DESCRIPTION "North to room2."
EXIT north TO room2.
END THE.

THE room2 ISA LOCATION
DESCRIPTION "South to room1."
EXIT south TO room1.
END THE.

THE apple ISA OBJECT AT room2
IS edible.

VERB eat
DOES "Congratulations!" QUIT.
END VERB.
END THE.

START AT room1.
DESCRIBE banner.
25 changes: 25 additions & 0 deletions extras/manual/short-example1_no-lib.alan
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--------------------------------------------------------------------------------
-- A reimplementation of "short-example1.alan" without the Standard Library.

-- In this version, though, the player wouldn't be able to examine him-/herself,
-- try to go any other direction, take inventory, try various things with the
-- apple, quit properly, etc.
--------------------------------------------------------------------------------

THE room1 ISA LOCATION
DESCRIPTION "North to room2."
EXIT north TO room2.
END THE.

THE room2 ISA LOCATION
DESCRIPTION "South to room1."
EXIT south TO room1.
END THE.

THE apple ISA OBJECT AT room2
VERB eat
DOES "Congratulations!" QUIT.
END VERB.
END THE.

START AT room1.
43 changes: 43 additions & 0 deletions extras/manual/short-example2.alan
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
--------------------------------------------------------------------------------
-- To win the game, the player must get a candy from the kitchen and give it to
-- a crying child in the nursery.
--------------------------------------------------------------------------------

IMPORT 'library.i'.

THE my_game ISA DEFINITION_BLOCK
END THE.

THE nursery ISA ROOM
DESCRIPTION "The kitchen is to the east."
EXIT east to kitchen.
END THE.

THE child ISA PERSON AT nursery
DESCRIPTION "There is a crying child here."

VERB give
WHEN recipient
DOES ONLY
IF obj = candy
THEN "You give the candy to the child who stops
crying and starts licking it happily."
QUIT.
END IF.
END VERB.
END THE.

THE kitchen ISA ROOM
DESCRIPTION "You can go west, back to the nursery."
EXIT west TO nursery.
END THE.

THE table ISA SUPPORTER AT kitchen
IS NOT takeable.
END THE.

THE candy ISA OBJECT IN table
IS edible.
END THE.

START AT nursery.
63 changes: 63 additions & 0 deletions extras/manual/short-example6.alan
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
--------------------------------------------------------------------------------
-- A complete example game with locked doors and keys.

-- This code reintroduces the situation used in example 1, with a locked door
-- and two keys added.
--------------------------------------------------------------------------------

IMPORT 'lib_classes.i'.
IMPORT 'lib_definitions.i'.
IMPORT 'lib_locations.i'.
IMPORT 'lib_messages.i'.
IMPORT 'lib_verbs.i'.

THE my_game ISA DEFINITION_BLOCK
END THE.

THE room1 ISA LOCATION
DESCRIPTION "North to room2."
EXIT north TO room2
CHECK locked_door_1 IS open
ELSE "The door to the north is on the way."
END EXIT.
END THE.

THE locked_door_1 ISA DOOR AT room1
DESCRIPTION ""
NAME door
HAS otherside locked_door_2.
IS lockable. IS locked.
HAS matching_key silver_key.
END THE.

THE silver_key ISA OBJECT AT room1
NAME silver key
END THE.

THE brass_key ISA OBJECT AT room1
NAME brass key
END THE.

THE room2 ISA LOCATION
DESCRIPTION "South to room1."
EXIT south TO room1
CHECK locked_door_2 IS open
ELSE "The door to the south is on the way."
END EXIT.
END THE.

THE locked_door_2 ISA DOOR AT room2
DESCRIPTION ""
NAME door
END THE.

THE apple ISA OBJECT AT room2
IS edible.

VERB eat
DOES "Congratulations!" QUIT.
END VERB.
END THE.

START AT room1.
DESCRIBE banner.
Loading

0 comments on commit 137b3cc

Please sign in to comment.