!---------------------------------------------------------------------------------
!
! Once: a fable for the lost
!
! begun spring 1998 / designed for Inform 6.14
!
! see branch.h for branch_set class definition
!
!---------------------------------------------------------------------------------

!---------------------------------------------------------------------------------
!
! constants
!
!---------------------------------------------------------------------------------

constant Story "Once";
constant Headline ": a fable for the lost
                                  ^DEMO version for the TextFire 12-PACK
                                  ^(First-time readers should type 'about')
                                  ^Copyright (c) 1998 by TextFire, Inc. All rights reserved.^";

constant won 4;
constant lost 3;

!---------------------------------------------------------------------------------
!
! library replaces
!
!---------------------------------------------------------------------------------

replace DrawStatusLine;

[ DrawStatusLine;
 rtrue;
];

replace ScoreSub;
replace FullScoreSub;

[ ScoreSub;
 if (~~deadflag)
       "This is a fable, not a game.";
 rtrue;
];

[ FullScoreSub;
 if (~~deadflag)
       "This is a story, not a game.";
 rtrue;
];

replace InvSub;

[ InvSub;
 "You aren't allowed anything.";
];


replace QuitSub;

[ QuitSub;
 L__M(##Quit,2);
 if (YesOrNo()~=0) {
       print "^Thank you for playing the demo version of ";
       style bold;
       print "Once";
       style roman;
       print ", a TextFire release. On-line registration for TextFire products will
                  be available at http://www.textfire.com on or before June 30, 1998.
                  Thanks for your patience!^^(Press any key to exit.)";
       WaitForKey();
       quit;
       };
];

[ NoAskQuit;
       print "^Thank you for playing the demo version of ";
       style bold;
       print "Once";
       style roman;
       print ", a TextFire release. On-line registration for TextFire products will
                  be available at http://www.textfire.com on or before June 30, 1998.
                  Thanks for your patience!^^(Press any key to exit.)";
       WaitForKey();
       quit;
];

include "Parser";

!---------------------------------------------------------------------------------
!
! entry points
!
!---------------------------------------------------------------------------------

[ DeathMessage;
 switch(deadflag) {
               3:
               print "everything is fine among the daisies";

               4:
               print "you learn to plant weeds";

               };
];

include "Verblib";
include "Branch";

!---------------------------------------------------------------------------------
!
! global objects and functions
!
!---------------------------------------------------------------------------------

[ Initialise;
 give player light;                                                    ! no dark rooms
 location = garden;
 player.description = "You know yourself by looking through your eyes.";
 StartTimer(girl,3);
 "You were once a little boy. Your eyes once were green, and your words
  were like wildflowers.^";
];

[ WaitForKey notNeeded;
 @read_char 1 notNeeded;
 rtrue;
];

branch_set madeleine1
       with
               num_branches
                       2,
               branch_1
                       "~Hello.~",
               chosen_1
                       [;
                        print "~Hello,~ you say.^^~My name is Madeleine,~ she says.
                                       ~I need you to come with me.~";
                        madeleine2.display();

                       ],
               branch_2
                       "~What are you doing here?~",
               chosen_2
                       [;
                        print "~What are you doing here?~ you ask.^^~I'm Madeleine,~
                                       she says. ~I'm here to find you. We need to go
                                       together.~";
                        madeleine2.display();

                       ];

branch_set madeleine2
       with
               num_branches
                       2,
               branch_1
                       "~Go where?~",
               chosen_1
                       [;
                        print "^^~Go where?~ you ask.^^~See that hill?~ And for the
                                       first time ever, you see the hill, green and so far
                                       away. ~Will you come with me?~ she asks.";
                        madeleine3.display();

                       ],
               branch_2
                       "~But I have to tend the garden.~",
               chosen_2
                       [;
                        print "^^~But I have to tend the garden.~^^~The daisies will
                                       remember how to live,~ she says. ~Your grandmother
                                       will help them. Will you come?~";
                        madeleine3.display();

                       ];

branch_set madeleine3
       with
               num_branches
                       2,
               branch_1
                       "~No.~",
               chosen_1
                       [;
                        deadflag = lost;
                        "^^~No,~ you say.";
                       ],
               branch_2
                       "~Yes.~",
               chosen_2
                       [;
                        StartTimer(hill,7);
                        print "^^~Yes,~ you cry, and run to her. The distance is so
                                       great, but you reach her, and you set out together
                                       towards the hill, eating dandelions and drinking
                                       rainwater.^^By the time you reach the hill, it is
                                       night. You and Madeleine make beds of baby's bells,
                                       but you can't sleep.^";
                        PlayerTo(hill);

                       ];

branch_set grandmother1
       with
               num_branches
                       3,
               branch_1
                       "~Madeleine brought me here.~",
               chosen_1
                       [;
                        print "~Madeleine brought me here,~ you say.^^~Who?~ she asks.
                                       ~I don't see anyone here but you and I.~^^You look around
                                       -- Madeleine's gone!^^";
                        grandmother2.display();

                       ],
               branch_2
                       "~I don't know.~",
               chosen_2
                       [;
                        deadflag = lost;
                        "~I don't know,~ you say, looking at her feet.^^~Well then, come
                         along,~ she says, and this time, you can't fight her.^^The weeding
                         of the garden goes quickly.";
                       ],
               branch_3
                       "~Leave me alone!~",
               chosen_3
                       [;
                        deadflag = won;
                        "~Leave me alone!~ you cry and start running. You don't know where
                         you go, and when you turn around, Madeleine is not there.^^You
                         live in the woods for many years; and then you begin to seek the
                         hill again.";
                       ];

branch_set grandmother2
       with
               num_branches
                       2,
               branch_1
                       "~She was just here.~",
               chosen_1
                       [;
                        print "~She was just here,~ you insist.^^~You're too old for
                                       imaginary friends,~ she says. ~Now, come home. I'll forgive
                                       you after you finish weeding the garden.~^^";
                        grandmother3.display();

                       ],
               branch_2
                       "~She must've left.~",
               chosen_2
                       [;
                        print "~She must've left.~^^~I've been watching you for hours,~ she
                                       says. ~There's no one here.~^^";
                       grandmother4.display();

                       ];

branch_set grandmother3
       with
               num_branches
                       2,
               branch_1
                       "~I'm not coming back.~",
               chosen_1
                       [;
                        move grandmother to hill;
                        remove sleepingGirl;
                        "~I'm not coming back,~ you say.^^~How dare you say that!~
                         Grandmother screams and seizes you by the arm.";
                       ],
               branch_2
                       "~I'm sorry.~",
               chosen_2
                       [;
                        deadflag = lost;
                        "~I'm sorry,~ you say, and take her hand.^^~Let's go home,~
                         she says.";
                       ];

branch_set grandmother4
       with
               num_branches
                       2,
               branch_1
                       "~I know she was here.~",
               chosen_1
                       [;
                        deadflag = won;
                        "~I know she was here.~^^~I am here,~ Madeleine says from behind
                         you. ~Your grandmother couldn't see me before.~^^Grandmother and
                         Madeleine stare at each other.^^~Let's go,~ Madeleine says.
                         ~There are other hills we need to see.~^^Grandmother doesn't
                         say a word as you leave.";
                       ],
               branch_2
                       "~I guess you're right.~",
               chosen_2
                       [;
                        deadflag = lost;
                        "~I guess you're right,~ you admit.";
                       ];

!---------------------------------------------------------------------------------
!
! the garden
!
!---------------------------------------------------------------------------------

object garden "In the Garden"
       with
               description
                       [;
                        print "^You stand in the middle of Grandmother's garden. You
                                       still have many weeds left to find. The woods are so far
                                       away.";
                        if (self hasnt general) {
                                       give self general;
                                       "^^Grandmother always insists on an immaculate garden. ~The
                                        daises will not allow anyone to crowd their soil. They
                                        forgot how to live with the unknowable.~";
                                       };
                        "";
                       ],
               cant_go
                       "You would, but you know you'd have to come back.",
               before
                       [;
                        wait:
                        print "The sky stays the same. ";
                        rfalse;

                        listen:
                        "Silence.";
                       ];

object -> visibleGarden "garden"
       with
               name
                       "garden" "soil" "dirt",
               description
                       "The garden is unending. Daisies. And weeds, forcing their way into
                        the rows.",
               before
                       [;
                        take:
                        "It would be impossible.";

                        weed:
                        <<weed weeds>>;
                       ],
       has
               scenery;

object -> daySky "sky"
       with
               article
                       "the",
               name
                       "sky",
               description
                       "The sky is suffocatingly clear.",
       has
               scenery;

object -> woods "woods"
       with
               article
                       "the",
               name
                       "woods" "forest" "tree" "wood" "trees",
               description
                       "Wild and lost.",
               before
               [;
                enter:
                <<go n_obj>>;
               ],
       has
               scenery pluralname;

object -> daisies "daisies"
       with
               name
                       "daisy" "daisies" "flower" "flowers",
               description
                       "Fragile, like half-melted icicles.",
               before
               [;
                take:
                "Grandmother wouldn't let you.";

                weed:
                <<weed weeds>>;

                smell:
                "They're like licorice.";

                pull:
                <<take self>>;
               ],
       has
               scenery pluralname;

object -> weeds "weeds"
       with
               name
                       "weed" "weeds",
               description
                       "They try to hide themselves, but it's all futile.",
               before
                       [;
                        weed:
                               if (self.number == 1) {
                                               self.number++;
                                               "You reach down and snap off a dull green weed, but you
                                                can't find its roots. You let it go.";
                                               };
                               "You find another weed and tear it from the ground.";

                       take:
                       <<weed self>>;

                       smell:
                       "Like earth.";

                       find:
                       <<weed self>>;

                       pull:
                       <<weed self>>;
                       ],
               number
                       1,
       has scenery pluralname;

object girl "girl"
       with
               name
                       "girl" "woman" "lady" "madeleine",
               initial
                       "The girl stands, watching you.",
               description
                       "Her hair is strewn with leaves and flowers. Her eyes remind you
                        of your mother's.",
               time_out
                       [;
                        move self to garden;
                        "^A girl appears at the edge of the woods. ~Hello,~ she calls.";
                       ],
               time_left
                       0,
               react_before
                       [;
                        weed:
                        print "You ignore the girl. The weeding takes the whole afternoon,
                                       and afterwards, you sit with the daisies and watch the
                                       shadows of the world lengthen.^";
                        deadflag = lost;


                        wait:
                        print "The girl watches you. ";
                        rfalse;
                       ],
               life
                       [;
                        attack:
                        "You wouldn't hurt her.";

                        kiss:
                        "She's too far away.";

                        wakeOther:
                        "She seems awake enough.";
                       ],
               orders
                       [; "To speak to her, type 'speak to her.'";
                       ],
               before
                       [;
                         speak:
                         madeleine1.display();
                         rtrue;
                       ],
       has
               animate female;

!--------------------------------------------------------------------------------
!
! the hill
!
!--------------------------------------------------------------------------------

object hill "Lying on the Hill"
       with
               description
                       "^The crickets sing of broken wings. The night sky is blank: only
                        one star swims tonight.",
               cant_go
                       "You couldn't leave Madeleine.",
               before
                       [;
                        listen:
                        if (grandmother notin self) "The crickets talk to each other.";

                        weed:
                        if (grandmother notin self)
                        "Though you know that there have to be weeds nearby, you don't want
                         to touch them.";

                        wait:
                        if (grandmother notin self)
                        print "The night continues around you. ";

                        sleep:
                        if (grandmother notin self)
                        self.number++;
                        switch(self.number) {
                               1:
                               "You lie on the ground, but nothing happens.";

                               2:
                               "You try to settle into sleep, but the earth still clutches at
                                you.";

                               3:
                               grandmother.confront();
                               rtrue;
                               };
                       ],
               time_out
                       [;
                        self.number = 2;
                        print "^";
                        <<sleep>>;
                       ],
               time_left
                       0,
               number
                       0;

object -> nightSky "night sky"
       with
               article
                       "an",
               name
                       "sky" "night",
               description
                       "The sky is limitless.",
       has
               scenery;

object -> star "lonely star"
       with
               name
                       "star" "stars" "lonely",
               description
                       "The North Star. So far away.",
               before
               [;
                take:
                "The star's unreachable.";

                touch:
                "You reach out for it. But it's only light.";
               ],
       has
               scenery;

object -> crickets "crickets"
       with
               article
                       "some",
               name
                       "cricket" "crickets",
               description
                       "You can't see them, but their song hangs around you in the air.",
               before
               [;
                take:
                "You think you scoop one from the ground, but it disappears from your
                 hand, a shadow.";

                speak:
                "You try to imitate their song. But your words are still a little
                 boy's.";

                find:
                "You look around, but you can't see them.";
               ],
       has
               scenery pluralname;

object -> sleepingGirl "Madeleine"
       with
               name
                       "girl" "woman" "lady" "madeleine",
               initial
                       "Madeleine sleeps quietly beside you.",
               description
                       "Her breaths are even.",
               before
                       [;
                        wakeOther:
                        "You tap her shoulder slightly. She shifts.";

                        speak:
                        "She's asleep.";

                        kiss:
                        "You kiss her gently on the forehead.";

                        attack:
                        "You couldn't.";
                       ],
               orders
                       [;
                        "She's asleep.";
                       ],
       has
               animate female proper;

object grandmother "Grandmother"
       with
               name
                       "grandmother" "grandma" "granny" "grammie",
               description
                       "She stares back at you stonily.",
               react_before
                       [;
                        attack:
                        print "You push her away, screaming, terrible, and run into the
                                       woods again. After many days, you come out again, but the
                                       hill is lost to you.^^You begin walking again; there will
                                       be other hills to be found.";
                        deadflag = won;
                        "";

                        look:
                        rfalse;

                        kiss:
                        print "You stop your protests and turn towards her, inward. ~I'm
                                       so sorry,~ you say.^^~It'll be fine,~ she says. ~The daisies
                                       missed you.~";
                        deadflag = lost;
                        "";

                        default:
                        print "Before you can, Grandmother picks you up and takes you,
                                       screaming, back to the garden. You clutch at the hill as
                                       you leave, but it is lost to you.";
                        deadflag = lost;
                        "";
                       ],
               confront
                       [;
                        print "You begin to count weeds plucked from the ground; the hands
                                       in your mind burrow deep into the ground, removing all
                                       roots.^^The other-world beckons, and you begin to follow the
                                       path --^^[MORE]";
                        WaitForKey();
                        @erase_window 0;
                        print "^^^~My grandson!~ Grandmother cries. You jump to your feet.
                                       ~What are you doing in such a place? You did not finish
                                       weeding the garden!~^^She stares at you, her raincoat
                                       clinging to her.^^";
                        grandmother1.display();
                       ],
       has
               animate female proper;

!--------------------------------------------------------------------------------
!
! grammar
!
!--------------------------------------------------------------------------------

include "Grammar";

extend "ask" replace
                                       * "about" topic                 -> TalkStub;

extend "tell" replace
                                       * "about" topic                 -> TalkStub;

extend 'answer' replace
                       * topic 'to' creature   -> TalkStub;

extend 'say' replace
                                       * topic 'to' creature   -> TalkStub;

extend 'shout' replace
                                       * topic 'to' creature   -> TalkStub;

[ TalkStubSub;
 "To speak to someone, type 'speak to person.'";
];

verb "talk"
                                       * 'to' creature                 -> Speak
                                       * creature                              -> Speak;

extend "speak" replace
                                       * 'to' creature                 -> Speak
                                       * creature                              -> Speak;

[ SpeakSub;
 "You can't speak to that.";
];

verb "find"
                                       * noun                                  -> Find;

[ FindSub;
 "You don't need to.";
];

verb "weed"
                                       * noun                                  -> Weed;

extend "pick" first
                                       * noun                                  -> Weed;

extend "remove" first
                                       * noun                                  -> Weed;

[ WeedSub;
 "You can't do that.";
];

verb meta "about" "info"
                                       *                                               -> About;

[ AboutSub;
 print "Note that to speak to someone in this fable, you should type 'speak to
                person.' A menu will appear at the top of the screen. Use either the
                arrow keys or 'N'(ext) and 'P'(revious) to choose what you'd like to
                say and press Enter or Return.^^The demo version of ";
 style bold;
 print "Once";
 style roman;
 print " was written by Robin Andrews for TextFire, Inc.^^About the author:^^
                Robin Andrews is a former journalist whose book of children's
                stories, ";
 style underline;
 print "Rockets and Shooting Stars";
 style roman;
 ", will be published next year. He lives on the Eastern Shore of Maryland
  with his wife, Sarah, and their two daughters, Lauren and Leslie.^^
  About TextFire:^^TextFire, Inc. is a partnership of authors formed for
  the purpose of providing quality works of interactive fiction to a
  worldwide community of players, hobbyists, and enthusiasts.  Help
  support our efforts to keep interactive fiction alive!";
];

verb meta "help" "hint" "hints"
                                       *                                               -> Help;

[ HelpSub;
 print "Hints are available with the full registered version of ";
 style bold;
 print "Once";
 style roman;
 ". Type REGISTER for additional information.";
];

verb meta "register"
                                       *                                               -> Register;

[ RegisterSub;
 "On-line registration for TextFire products will be available at
  http://www.textfire.com on or before June 30, 1998.  Thanks for your
  patience!";
];