-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement as external sources the short examples of Ch.15. Some example files are deployed to `extras/manual`, others not.
- Loading branch information
Showing
13 changed files
with
447 additions
and
298 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.