Constant Story "The Visitor";
Constant Headline "^A Chat^
               Copyright (c) 2000 by Peter Polkinghorne.^";

Include "Parser";

! Different way of finishing - not so much dead or won
[DeathMessage;
       print "Game Over";
];

! A bit of library intervention - to render score
Object LibraryMessages
 with before
      [;  Score: if (deadflag) switch (Gladys.friend)
                       { -1: "You are Gladys's enemy.";
                       0: "You are Gladys's acquaintance.";
                       1: "You are Gladys's friend.";
                       default: "Gladys is in a muddle!";
                       }
                else "That is not important, but friendship is.";
      ];

! We have some afterword - does NOT work as deadflag 3 - bother!
Constant AMUSING_PROVIDED;

[amusing;
       "Thanks for playing.^
       Gladys has multiple responses for most topics,
       and some notion of what has been said.^
       The idea for the portrait came from the many elderly
       ladies I met doing voluntary work, and some of my
       Great Aunts.  I hope I have done them justice.^^
       Peter Polkinghorne.";
];

Include "Verblib";

! Simple room

Object Room "Gladys's Room"
       with description
               "A dull institutional room, with a bed with bedside
               cupboard and chair.  A couple of photos decorate the
               cupboard.  A window is on the north wall.^

               There is an open door to the south.",

       cant_go "~Where do you think you are going?~ asks Gladys.",
       s_to
       [;
       deadflag = 3;
       switch (Gladys.friend) {
       -1: "As you leave, Gladys mutters to herself ~Good riddance!.~";
       0: "As you leave, Gladys says ~Bye dear.~";
       1: "As you leave, Gladys says ~Bye dear, come again soon.~";
       default: "As you leave, Gladys says ~I just don't know?~";
       }
       ]
       has light;

! Bit of scenery - all described by Gladys

Object -> Bed "Gladys's Bed"
       with name "Bed",
       description
               "~Oh that~ says Gladys, ~its not too bad for sleeping in.~",
       has scenery;

Object -> Chair "Gladys's Chair"
       with name "Chair",
       description
               "~It may be plain~ says Gladys, ~but its comfortable.~",
       has scenery;

Object -> Cupboard "Gladys's Cupboard"
       with name "Cupboard",
       description
               "~Thats got all I have left, in it.~ says Gladys.",
       has scenery;

Object -> Photos "Gladys's Photos"
       with name "Photos" "Snaps" "Photographs" "Photo" "Photograph" "Snap",
       description
               "~Thats me and my family~ says Gladys",
! get to know the family
       before
       [; take: gladys.&known-->6 = 1;
               gladys.&known-->7 = 1;
               gladys.&known-->8 = 1;
               gladys.&known-->9 = 1;
               gladys.&known-->10 = 1;
               "You pick up the two photos.  Gladys points to the
               first, a faded black and white wedding photo,
               ~Thats me and Harold on our wedding, nearly 50 years ago.~,
               the second is a family group in colour, Gladys and Harold
               as Grandparents, with as Gladys points out, ~Jane, our
               only daughter, and Iain her husband, and our two grandchildren
               Roderick and Isobel.~  You put the photos back.";
       ],
       has scenery;

Object -> Window "Gladys's Window"
       with name "Window",
       description
               "~Is it still raining?~ asks Gladys.",

! deal with looking through the window
       before
       [ ;
               search: "You see the rain pouring down over grey London
                       suburbia. ~Going to be dark soon.~ remarks Gladys.";
       ],
       has scenery;

Object -> SDoor "Gladys's Door"
       with name "Door",
       description
               "~Thats the way out, dear.~ says Gladys.",

! keep that door open
       before
       [;      open: "~Its already open, dear.~ exclaims Gladys.";
               close: "~No, leave it open, please.~ asks Gladys.";
       ],
       has scenery;

! The main actor and purpose of the exhibit

Object -> Gladys "Gladys Harding"
       with name "Gladys" "Mrs" "Harding" "old" "lady" "woman",
! the bits that make up Gladys
               add_to_scope Face Hands Clothes Shoes,
               describe
                       "Gladys is sitting in the chair.",
               description
                       "She is a small elderly lady with a nice smile.",

! some variables to represent the state of Gladys
               friend, ! -1 enemy, 0 acquaintance, 1 friend

! Topics are:
! 0:home 1:bungalow 2:visitor 3:weather 4:rheumatics 5:party 6:harold 7:jane
! 8:iain 9:roderick 10:isobel 11:family 12:london
               asked 0 0 0 0 0 0 0 0 0 0 0 0 0,
               known 1 0 1 1 0 1 0 0 0 0 0 1 1,

! trap some player actions on gladys
               before
               [;
                       listen: self.friend = 1;
                               "Gladys smiles and says ~Yes?~";

                       search, take, smell, touch, taste: self.friend = -1;
                               "Gladys yells ~'ere whats your game!~";

               ],

               life
               [;
               kiss: self.friend = 1;
                       "Gladys responds ~Oh you going now, bye dear~^";

! get rid of unpleasant person
               attack: deadflag = 3;
                       self.friend = -1;
                       "Gladys alarmed, presses a button you have not noticed.
                       A member of staff quickly arrives and hustles you off
                       the premises.
                       The police are told and you will never see Gladys again.";

! deal with other easy bits
               wakeother: "Gladys says ~I'm not asleep!~";

! Note nothing to show or give or throw (makes life easier)

! Here simple representation of memory:
! asked - array indexed by topic of how many times asked
! known - array indexed by topic of whether player expected to know
!  - this allows variation in response and topic flow
!       - ask about A find out B - if ask about B out of turn respond
!         differently

               ask: self.friend = 1;
               switch (second)
               {
! topic 0
               'home', 'nursing':
                       (self.&asked-->0)++;
                       switch (self.&asked-->0) {
                       1:      self.&known-->1 = 1;
                               "~Its alright, but not like my old bungalow.~
                               says Gladys regretfully.";

                       2:      "~You know what I miss?~ asks Gladys impishly,
                               ~Men! We're practically all ladies here!~";

                       default: "~I really don't want to talk about the home
                               any more.~ says Gladys wearily.";
                       }

! topic 1
               'bungalow':
                       (self.&asked-->1)++;
                       if ( self.&known-->1 )
                               switch (self.&asked-->1) {
                               1:      "~We lived there for years, ever since
                               the war.  They were happy days.~ smiles Gladys";
                               2:      "~It was near Eastcote, the Harrow side.
                                       Very good for the tube, but quiet.
                                       Yes it was a good place to be.~
                                       reminisces Gladys.";
                               default: "~Where do you live ...~ wonders
                                       Gladys";
                               }
                       else
                               "~Eh what?~ asks Gladys";


! topic 2
               'self', 'visitor', 'player':
                       (self.&asked-->2)++;
                       switch (self.&asked-->2) {
                       1:      "~Its very kind of you to bring me back,
                               I really enjoyed the tea party.~
                               says Gladys.";

                       2:      "~You know I glad there are young people like
                               you?~ smiles Gladys,
                               ~Can't believe all you see on the telly.~";

                       default: "~I am the one you should be talking about,
                               stuck here all by myself, not
                               you, who can go gadding about anytime
                               you like!~ says Gladys crossly.";
                       }

! topic 3
               'weather', 'rain', 'cloud':
                       (self.&asked-->3)++;
                       switch (self.&asked-->3) {
                       1:      "Gladys responds ~Hasn't it been wet?
                               I think it has rained every day this week.~";

                       2:      self.&known-->4 = 1;
                               "~All this damp isn't good for my joints~,
                               moans Gladys,
                               ~I got the rheumatics, you see.~";

                       3:      "Gladys answers ~Still bound to get better,
                               have you heard the forecast?  I think
                               it said it would clear up.~";

                       default: "~Well can't talk about the weather all
                               day, you know, much too english!~
                               twinkles Gladys.";
                       }

! topic 4
               'rheumatics', 'joints':
                       (self.&asked-->4)++;
                       if ( self.&known-->4 )
                               "~Thanks for asking, but they are not
                               too bad, really.  I get some physio
                               for them.~ responds Gladys.";
                       else
                               "~You been asking the staff?~ asks Gladys
                               suspiciously.";


! topic 5
               'party', 'trip', 'tea':
                       (self.&asked-->5)++;
                       switch (self.&asked-->5) {
                       1:      "~It was wonderful to go out and have
                               a good natter.~ Gladys enthuses,
                                ~I haven't seen some of my friends for over
                               a year.~";

                       2:      "~And we had some nice music and a good
                               tea - proper with sandwiches, cake and
                               all that.~ says Gladys.
                               ~Its my annual outing now, all I have
                               to look forward to.~";

                       3:      "Gladys answers ~Yes, it was a nice party,
                               the day centre is warm and all the balloons
                               livened it up.~";

                       default: "~Oh well, a year till the next one,
                               I hope you will be taking me?~
                               Gladys enquires.";
                       }

! topic 6
               'harold', 'husband':
                       (self.&asked-->6)++;
                       if ( self.&known-->6 )
                               switch (self.&asked-->6) {
                               1:      "~Harold, I met him at the end of
                               the war, the second you know. He worked
                               at the Kodak factory in Harrow.~ says Gladys.";
                               2:      "~He was a kind man, he loved Jane
                               and the grandchildren, always telling them
                               stories.  Keen gardener too ...~ remarks
                               Gladys.";
                               3:      "~He died not long after retiring,
                               lung cancer, he had always been a pipe
                               smoker, we didn't know in those days
                               ... still he didn't suffer much.~ muses
                               Gladys.";
                               default: "~I still miss him you know.~ says
                                       Gladys simply";
                               }
                       else
                               "~Sorry?~ asks Gladys";


! topic 7
               'jane', 'daughter':
                       (self.&asked-->7)++;
                       if ( self.&known-->7 )
                               switch (self.&asked-->7) {
                               1:      "~Jane was the apple of my eye, you
                               know.  I suppose it was being the only child.
                               We did want more, but never happened.~
                               says Gladys.";
                               2:      "~She was quite clever and went to
                               college, secretarial training.  It was at
                               her first and only job she met Iain.~ Gladys
                               says.";
                               3:      "~Well after they were married,
                               Iain was promoted and went back to Scotland,
                               where she and the children have lived ever
                               since.~ say Gladys with a hint of sadness.";
                               default: "~I still get the odd phone call
                               and of course birthday and christmas cards
                               from her and the family.~
                               says Gladys quietly.";
                               }
                       else
                               "~Who?~ asks Gladys.";


! topic 8
               'iain', 'son-in-law':
                       (self.&asked-->8)++;
                       if ( self.&known-->8 )
                               switch (self.&asked-->8) {
                               1:      "~He's a nice enough chap, quite
                               a catch for Jane, although I always found
                               him a bit reserved.~ says Gladys.";
                               2:      "~He has done well in the bank,
                               in the head office in Edinburgh I think.~
                               remarks Gladys.";
                               default: "~I wish he'd let Jane come
                                       here sometimes.~ says Gladys resignedly.";
                               }
                       else
                               "~Pardon?~ asks Gladys.";


! topic 9
               'roderick', 'grandson':
                       (self.&asked-->9)++;
                       if ( self.&known-->9 )
                               switch (self.&asked-->9) {
                               1:      "~He was my first grandchild,
                               I was so excited.  Spent a whole month
                               in Edinburgh helping Jane.  Not sure
                               Iain really approved ...~ sighs Gladys.";
                               2:      "~He went to University you know,
                               working with computers and whatnot.
                               He's now working in america, doing really
                               well Jane says.~ says Gladys with pride.";
                               default: "~He's a good lad, but I wish
                               he'd write more often.~ says Gladys.";
                               }
                       else
                               "~Ummm?~ murmurs Gladys.";


! topic 10
               'isobel', 'granddaughter':
                       (self.&asked-->10)++;
                       if ( self.&known-->10 )
                               switch (self.&asked-->10) {
                               1:      "~I was so glad when Isobel came along,
                               a little sister for Rodderick.  Harold wasn't
                               well when she was born and I didn't see so
                               much of her as Roderick.~ says Gladys.";
                               2:      "~She's just done her A levels,
                               and is hoping to go to University. I do
                               hope she comes to London.~ says Gladys with
                               feeling.";
                               default: "~She's a pretty girl, so like
                               her mother.~ says Gladys with pride.";
                               }
                       else
                               "~Sorry?~ asks Gladys.";


! topic 11
               'family', 'hardings', 'children':
                       (self.&asked-->11)++;
                       if ( self.&known-->7 )
! player knows basics of family
                               switch (self.&asked-->11) {
                               2:      "~We never been teribly close family,
                               I suppose it being that Harold and I were
                               only children. Also our parents died youngish.~
                               says Gladys.";
                               default: "~Still they keep in touch
                               a bit, you know.~ says
                                       Gladys resignedly.";
                               }
                       else
! give initial lowdown.
                               self.&known-->6 = 1;
                               self.&known-->7 = 1;
                               self.&known-->8 = 1;
                               self.&known-->9 = 1;
                               self.&known-->10 = 1;
               "~Well there's Harold, my husband, and we had Jane,
               my only daughter, and she married Iain, and they had
               Roderick and Isobel, my lovely grandchildren~ remarks Gladys.";

! topic 12
               'london', 'acton', 'harrow', 'eastcote':
                       (self.&asked-->12)++;
                       switch (self.&asked-->12) {
                       1:      "Gladys replies ~I've lived in London all my
                               life.  Not in the same place mind you.
                               I was born and brought up in Acton.~";

                       2:      "~We were glad to move out from Acton,~
                               says Gladys,
                               ~Eastcote was practically countryside,
                               much cleaner air.~";

                       3:      "Gladys answers ~You know something,
                               I never been to the British Museum.
                               Still I did see a lot of lovely shows
                               in the West End.~";

                       default: "~Are you a Londoner?  You don't
                               sound it, but you can't tell these days.~
                               smiles Gladys.";
                       }

               }

! unknown - put player off
               switch (random(5)) {
               1: "~What are you going on about?~ wonders Gladys.";
               2: "~Sorry what were you saying?~ asks Gladys.";
               3: "Gladys does not respond at all, but blows her nose.";
               4: "~Err can't really say ...~ mumbles Gladys.";
               5: "Gladys ignores you and turns to look out the Window.";
               }

! not too interested in Tell, Answer & Order
               tell: "~Really, how interesting ...~ says Gladys, but
                       you can tell she is not really interested.";

               answer: "~You don't say~ responds Gladys";

               order:  "~Leave me be!~ snaps Gladys";

               ],

! make gladys a bit active - longer term ask questions
               each_turn
               [i;
               i = random(20);
               switch (i) {
                       1: "Gladys coughs alarmingly";
                       2: "Gladys looks towards the door.";
                       3: "Gladys glances at the window.";
                       3: "Gladys smiles at you.";
               }
               ],

       has animate female proper
;

! Give Gladys some component parts to allow player examination
!
! First set up a class:

Class GladysBits
       with
       before
       [ ;
               take, search, smell, taste, touch: "Gladys looks at you in bewilderment.";
       ],
       has scenery proper;

GladysBits Face "Gladys's face"
       with name "face" "eyes" "glasses" "gladys^s",
       description "Old and wrinkled with two bright eyes looking
                       attentively at you through glasses.";

GladysBits Hands "Gladys's hands"
       with name "hands" "hand" "finger" "ring" "gladys^s",
       description
       [ ;
! now know about husband
       gladys.&known-->6 = 1;
        "Bony with bent fingers, you can just see a wedding
                       ring on the left hand.";
       ];

GladysBits Clothes "Gladys's clothes"
       with name "clothes" "dress" "cardigan" "orange" "fawn" "gladys^s",
       description "Gladys wears an orange check dress with a fawn cardigan.
                       Both have seen better days, but are clean and in good
                       repair.";

GladysBits Shoes "Gladys's shoes"
       with name "shoes" "feet" "black" "shoe" "foot" "gladys^s",
       description "Gladys wears a pair of black shoes in need of a polish.";

[ Initialise;
 location = Room;
 notify_mode = 0;
"^^^^^You have just brought Gladys back to the Nursing Home.
       ^^~Won't you have a chat, dear~ says Gladys as she settles down
       in her chair.^^^^";
];

! add in a simple meta about and help type words

[ AboutSub; "This game is written for the Spring 2000 IF Art Show.^
       It is submitted for the portrait section and is my first game.^^

       The aim is to have a chat with Gladys and be her friend.^^

       The idea for the portrait came from the many elderly
       ladies I met doing voluntary work, and some of my
       Great Aunts.  I hope I have done them justice.^^

       Peter Polkinghorne, North Harrow, Middlesex, England^
       peter.polkinghorne@@64brunel.ac.uk";
];

[ HelpSub; "This game is basicly standard Inform.^
       To chat with Gladys, type:^^
       ask Gladys about TOPIC^
       where TOPIC is a suitable word.^^

       Gladys has multiple responses for most topics,
       and some notion of what has been said.^^

       In case of difficulty contact:
       peter.polkinghorne@@64brunel.ac.uk";
];

Verb meta       "about" "info" "credits" * -> About;
Verb meta       "help" "hint" * -> Help;

Include "Grammar";