From 137b3ccdee33888e8879576d8e6c9dab31af37fe Mon Sep 17 00:00:00 2001 From: tajmone Date: Thu, 30 May 2019 12:29:55 +0200 Subject: [PATCH] StdLib Man: Short Examples Implement as external sources the short examples of Ch.15. Some example files are deployed to `extras/manual`, others not. --- extras/manual/StdLibMan.html | 18 +- extras/manual/short-example1.alan | 30 ++ extras/manual/short-example1_no-lib.alan | 25 ++ extras/manual/short-example2.alan | 43 +++ extras/manual/short-example6.alan | 63 ++++ extras_src/manual/StdLibMan_15.adoc | 298 +------------------ extras_src/manual/_short-example3.alan | 42 +++ extras_src/manual/_short-example4.alan | 27 ++ extras_src/manual/_short-example5.alan | 30 ++ extras_src/manual/short-example1.alan | 32 ++ extras_src/manual/short-example1_no-lib.alan | 27 ++ extras_src/manual/short-example2.alan | 45 +++ extras_src/manual/short-example6.alan | 65 ++++ 13 files changed, 447 insertions(+), 298 deletions(-) create mode 100644 extras/manual/short-example1.alan create mode 100644 extras/manual/short-example1_no-lib.alan create mode 100644 extras/manual/short-example2.alan create mode 100644 extras/manual/short-example6.alan create mode 100644 extras_src/manual/_short-example3.alan create mode 100644 extras_src/manual/_short-example4.alan create mode 100644 extras_src/manual/_short-example5.alan create mode 100644 extras_src/manual/short-example1.alan create mode 100644 extras_src/manual/short-example1_no-lib.alan create mode 100644 extras_src/manual/short-example2.alan create mode 100644 extras_src/manual/short-example6.alan diff --git a/extras/manual/StdLibMan.html b/extras/manual/StdLibMan.html index b612098..1acda7a 100644 --- a/extras/manual/StdLibMan.html +++ b/extras/manual/StdLibMan.html @@ -6662,7 +6662,7 @@

15. Short examples

Here, the hero must go from room1 north to room2 and eat an apple to win the game.

-
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.
+
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.
@@ -6670,7 +6670,7 @@

15. Short examples

-
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.
+
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.
@@ -6681,19 +6681,19 @@

15. Short examples

Here, the player must get a candy from the kitchen and give it to a crying child in the nursery to win the game.

-
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.
+
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.
-

Examples 3-4 below show mainly different variations of the my_game instance and not complete games:

+

Examples 3-4 below show mainly different variations of the my_game instance and not complete games:

  • -

    In this example of defining the my_game instance, the author has changed the default verb responses for eat, climb and take_from. +

    In this example of defining the my_game instance, the author has changed the default verb responses for eat, climb and take_from. In addition, the author has added a check and a response of his/her own to take_from:

    -
    THE my_game ISA DEFINITION_BLOCK
    
    VERB eat
    
    DOES ONLY "You don't feel like eating anything in this game."
    
    END VERB.
    
    VERB climb
    
    DOES ONLY "Let's just stay on the ground, shall we?"
    
    END VERB.
    
    VERB take_from
    
    WHEN obj
    
    CHECK COUNT ISA ACTOR, AT hero = 1
    
    -- ( = the hero himself)
    
    ELSE "You don't want to take anything while somebody
    
    might be looking."
    
    DOES "Triumphantly, you fish" SAY THE obj. "out of"
    
    SAY THE holder. "."
    
    END VERB.
    
    END THE.
    +
    THE my_game ISA DEFINITION_BLOCK
      VERB eat
        DOES ONLY
          "You don't feel like eating anything in this game."
      END VERB.
    
      VERB climb
        DOES ONLY
          "Let's just stay on the ground, shall we?"
      END VERB.
    
      VERB take_from
        WHEN obj
          CHECK COUNT ISA ACTOR, AT hero = 1
          -- ( = the hero himself)
            ELSE "You don't want to take anything
                  while somebody might be looking."
          DOES
            "Triumphantly, you fish" SAY THE obj.
            "out of"SAY THE holder. "."
      END VERB.
    END THE.
  • @@ -6701,7 +6701,7 @@

    15. Short examples

    Here, the author uses the automatic formulation for the game title, author, and other information:

    -
    THE my_game ISA DEFINITION_BLOCK
    
    HAS title "The Lost Treasure".
    
    HAS subtitle "An interactive treasure hunt".
    
    HAS author "Sam".
    
    HAS year 2019.
    
    HAS version "1".
    
    END THE.
    
    THE garden ISA LOCATION
    
    DESCRIPTION "..."
    
    END THE.
    
    START AT garden.
    
    DESCRIBE banner.
    +
    THE my_game ISA DEFINITION_BLOCK
      HAS title "The Lost Treasure".
      HAS subtitle "An interactive treasure hunt".
      HAS author "Sam".
      HAS year 2019.
      HAS version "1".
    END THE.
    
    THE garden ISA LOCATION
      DESCRIPTION "..."
    END THE.
    
    START AT garden.
    DESCRIBE banner.
    @@ -6709,7 +6709,7 @@

    15. Short examples

    Here, the game author has added a check of his own to the library-defined drink verb and changed an illegal parameter message for the verbs look_behind, look_in, and look_under:

    -
    THE my_game ISA DEFINITION_BLOCK
    
    VERB drink
    
    CHECK hero IS thirsty
    
    ELSE "You don't feel like drinking anything right now."
    
    END VERB.
    
    HAS illegal_parameter_there "You can't \$v there.".
    
    END THE.
    +
    THE my_game ISA DEFINITION_BLOCK
      VERB drink
        CHECK hero IS thirsty
          ELSE "You don't feel like drinking anything right now."
        END VERB.
    
      HAS illegal_parameter_there "You can't $v there.".
    END THE.
    @@ -6718,7 +6718,7 @@

    15. Short examples

    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.
    
    // PAGE 110 //
    
    
    
    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.
    +
    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.
    diff --git a/extras/manual/short-example1.alan b/extras/manual/short-example1.alan new file mode 100644 index 0000000..f13ecc3 --- /dev/null +++ b/extras/manual/short-example1.alan @@ -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. diff --git a/extras/manual/short-example1_no-lib.alan b/extras/manual/short-example1_no-lib.alan new file mode 100644 index 0000000..b0cb920 --- /dev/null +++ b/extras/manual/short-example1_no-lib.alan @@ -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. diff --git a/extras/manual/short-example2.alan b/extras/manual/short-example2.alan new file mode 100644 index 0000000..97fdcbf --- /dev/null +++ b/extras/manual/short-example2.alan @@ -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. diff --git a/extras/manual/short-example6.alan b/extras/manual/short-example6.alan new file mode 100644 index 0000000..4c4682c --- /dev/null +++ b/extras/manual/short-example6.alan @@ -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. diff --git a/extras_src/manual/StdLibMan_15.adoc b/extras_src/manual/StdLibMan_15.adoc index 1f6be07..d429423 100644 --- a/extras_src/manual/StdLibMan_15.adoc +++ b/extras_src/manual/StdLibMan_15.adoc @@ -17,76 +17,14 @@ Here, the hero must go from room1 north to room2 and eat an apple to win the gam + [source,alan] -------------------------------------------------------------------------------- -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. +include::{utf8dir}/short-example1.alan[tag=shown] -------------------------------------------------------------------------------- + (This game wouldn't actually need the library at all; it would be even shorter to code:) + [source,alan] -------------------------------------------------------------------------------- -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. +include::{utf8dir}/short-example1_no-lib.alan[tag=shown] -------------------------------------------------------------------------------- + In this latter case, though, the player wouldn't for example be able to examine him-/herself, trying to go any other direction, take inventory, try various things with the apple, quit properly, etc. @@ -95,155 +33,31 @@ In this latter case, though, the player wouldn't for example be able to examine + [source,alan] -------------------------------------------------------------------------------- -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. +include::{utf8dir}/short-example2.alan[tag=shown] -------------------------------------------------------------------------------- + -Examples 3-4 below show mainly different variations of the my_game instance and not complete games: +Examples 3-4 below show mainly different variations of the `my_game` instance and not complete games: -3. In this example of defining the my_game instance, the author has changed the default verb responses for `eat`, `climb` and `take_from`. +3. In this example of defining the `my_game` instance, the author has changed the default verb responses for `eat`, `climb` and `take_from`. In addition, the author has added a check and a response of his/her own to `take_from`: + [source,alan] -------------------------------------------------------------------------------- -THE my_game ISA DEFINITION_BLOCK - -VERB eat - -DOES ONLY "You don't feel like eating anything in this game." - -END VERB. - -VERB climb - -DOES ONLY "Let's just stay on the ground, shall we?" - -END VERB. - -VERB take_from - -WHEN obj - -CHECK COUNT ISA ACTOR, AT hero = 1 - --- ( = the hero himself) - -ELSE "You don't want to take anything while somebody - -might be looking." - -DOES "Triumphantly, you fish" SAY THE obj. "out of" - -SAY THE holder. "." - -END VERB. - -END THE. +include::{utf8dir}/_short-example3.alan[tag=shown] -------------------------------------------------------------------------------- 4. Here, the author uses the automatic formulation for the game title, author, and other information: + [source,alan] -------------------------------------------------------------------------------- -THE my_game ISA DEFINITION_BLOCK - -HAS title "The Lost Treasure". - -HAS subtitle "An interactive treasure hunt". - -HAS author "Sam". - -HAS year 2019. - -HAS version "1". - -END THE. - -THE garden ISA LOCATION - -DESCRIPTION "..." - -END THE. - -START AT garden. - -DESCRIBE banner. +include::{utf8dir}/_short-example4.alan[tag=shown] -------------------------------------------------------------------------------- 5. Here, the game author has added a check of his own to the library-defined drink verb and changed an illegal parameter message for the verbs look_behind, look_in, and look_under: + [source,alan] -------------------------------------------------------------------------------- -THE my_game ISA DEFINITION_BLOCK - -VERB drink - -CHECK hero IS thirsty - -ELSE "You don't feel like drinking anything right now." - -END VERB. - -HAS illegal_parameter_there "You can't \$v there.". - -END THE. +include::{utf8dir}/_short-example5.alan[tag=shown] -------------------------------------------------------------------------------- 6. A complete example game with locked doors and keys. @@ -251,101 +65,7 @@ This code reintroduces the situation used in example 1, with a locked door and t + [source,alan] -------------------------------------------------------------------------------- -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. - -// PAGE 110 // - - - -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. +include::{utf8dir}/short-example6.alan[tag=shown] -------------------------------------------------------------------------------- // PAGE 111 // diff --git a/extras_src/manual/_short-example3.alan b/extras_src/manual/_short-example3.alan new file mode 100644 index 0000000..716fc95 --- /dev/null +++ b/extras_src/manual/_short-example3.alan @@ -0,0 +1,42 @@ + +-- EXAMPLE FILE NOT DEPLOYED IN "/extras/manual/" FOLDER!!! +-------------------------------------------------------------------------------- + +-- In this example of defining the `my_game` instance, the author has changed +-- the default verb responses for `eat`, `climb` and `take_from`. + +-- In addition, the author has added a check and a response of his/her own to +-- `take_from`: + +-------------------------------------------------------------------------------- +IMPORT 'library.i'. + +-- tag::shown[] +THE my_game ISA DEFINITION_BLOCK + VERB eat + DOES ONLY + "You don't feel like eating anything in this game." + END VERB. + + VERB climb + DOES ONLY + "Let's just stay on the ground, shall we?" + END VERB. + + VERB take_from + WHEN obj + CHECK COUNT ISA ACTOR, AT hero = 1 + -- ( = the hero himself) + ELSE "You don't want to take anything + while somebody might be looking." + DOES + "Triumphantly, you fish" SAY THE obj. + "out of"SAY THE holder. "." + END VERB. +END THE. +-- end::shown[] + +THE startlocation IsA site. +END THE startlocation. + +START AT startlocation. diff --git a/extras_src/manual/_short-example4.alan b/extras_src/manual/_short-example4.alan new file mode 100644 index 0000000..1c2c0b8 --- /dev/null +++ b/extras_src/manual/_short-example4.alan @@ -0,0 +1,27 @@ + +-- EXAMPLE FILE NOT DEPLOYED IN "/extras/manual/" FOLDER!!! +-------------------------------------------------------------------------------- + +-- Here, the author uses the automatic formulation for the game title, author, +-- and other information: + +-------------------------------------------------------------------------------- + +IMPORT 'library.i'. + +-- tag::shown[] +THE my_game ISA DEFINITION_BLOCK + HAS title "The Lost Treasure". + HAS subtitle "An interactive treasure hunt". + HAS author "Sam". + HAS year 2019. + HAS version "1". +END THE. + +THE garden ISA LOCATION + DESCRIPTION "..." +END THE. + +START AT garden. +DESCRIBE banner. +-- end::shown[] diff --git a/extras_src/manual/_short-example5.alan b/extras_src/manual/_short-example5.alan new file mode 100644 index 0000000..3d5e075 --- /dev/null +++ b/extras_src/manual/_short-example5.alan @@ -0,0 +1,30 @@ + +-- EXAMPLE FILE NOT DEPLOYED IN "/extras/manual/" FOLDER!!! +-------------------------------------------------------------------------------- + +-- Here, the game author has added a check of his own to the library-defined +-- drink verb and changed an illegal parameter message for the verbs +-- look_behind, look_in, and look_under: + +-------------------------------------------------------------------------------- +IMPORT 'library.i'. + +THE HERO IsA ACTOR. + IS NOT thirsty. +END THE HERO. + +-- tag::shown[] +THE my_game ISA DEFINITION_BLOCK + VERB drink + CHECK hero IS thirsty + ELSE "You don't feel like drinking anything right now." + END VERB. + + HAS illegal_parameter_there "You can't $v there.". +END THE. +-- end::shown[] + +THE startlocation IsA site. +END THE startlocation. + +START AT startlocation. diff --git a/extras_src/manual/short-example1.alan b/extras_src/manual/short-example1.alan new file mode 100644 index 0000000..074c47d --- /dev/null +++ b/extras_src/manual/short-example1.alan @@ -0,0 +1,32 @@ +-------------------------------------------------------------------------------- +-- 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. +-------------------------------------------------------------------------------- + +-- tag::shown[] +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. +-- end::shown[] diff --git a/extras_src/manual/short-example1_no-lib.alan b/extras_src/manual/short-example1_no-lib.alan new file mode 100644 index 0000000..c375843 --- /dev/null +++ b/extras_src/manual/short-example1_no-lib.alan @@ -0,0 +1,27 @@ +-------------------------------------------------------------------------------- +-- 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. +-------------------------------------------------------------------------------- + +-- tag::shown[] +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. +-- end::shown[] diff --git a/extras_src/manual/short-example2.alan b/extras_src/manual/short-example2.alan new file mode 100644 index 0000000..7719d57 --- /dev/null +++ b/extras_src/manual/short-example2.alan @@ -0,0 +1,45 @@ +-------------------------------------------------------------------------------- +-- To win the game, the player must get a candy from the kitchen and give it to +-- a crying child in the nursery. +-------------------------------------------------------------------------------- + +-- tag::shown[] +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. +-- end::shown[] diff --git a/extras_src/manual/short-example6.alan b/extras_src/manual/short-example6.alan new file mode 100644 index 0000000..bc7545a --- /dev/null +++ b/extras_src/manual/short-example6.alan @@ -0,0 +1,65 @@ +-------------------------------------------------------------------------------- +-- 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. +-------------------------------------------------------------------------------- + +-- tag::shown[] +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. +-- end::shown[]