~ubuntu-branches/ubuntu/vivid/inform/vivid

« back to all changes in this revision

Viewing changes to tutor/alice.inf

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2008-05-26 22:09:44 UTC
  • mfrom: (2.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080526220944-ba7phz0d1k4vo7wx
Tags: 6.31.1+dfsg-1
* Remove a considerable number of files from the package
  due to unacceptable licensing terms.
* Repair library symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
! Through the Looking-Glass
2
 
! An Inform tutorial by Gareth Rees
3
 
! All rights given away
4
 
! Version 3
5
 
!
6
 
! 5/1/2003 - Updated to Inform 6.21 Library 6/10
7
 
!
8
 
 
9
 
Constant Story "THROUGH THE LOOKING GLASS";
10
 
Constant Headline "^An Interactive Tutorial^by Gareth Rees^";
11
 
 
12
 
Include "parser";
13
 
Include "verblib";
14
 
Include "grammar";
15
 
 
16
 
[ Initialise;
17
 
    location = Drawing_Room;
18
 
    StartDaemon(white_kitten);
19
 
    StartDaemon(black_kitten);
20
 
    print "^^^^^It's a cold winter day outside, but in the
21
 
        looking-glass house it's summer. All you need to do is
22
 
        pretend there's a way of getting through into it
23
 
        somehow...^^";
24
 
];
25
 
 
26
 
[ UntangleSub; "What curious ideas you have!"; ];
27
 
 
28
 
[ ReflectSub;
29
 
    if (second ~= mirror) "What a strange idea!";
30
 
    if (noun == hearth or mirror || (player notin mantelpiece && 
31
 
        player notin armchair))
32
 
        "You can't see that in the looking-glass.";
33
 
    print "The looking-glass ";
34
 
    if (noun == player) print "Alice";
35
 
    else PrintShortName(noun);
36
 
    if (player in mantelpiece) " looks very misty and blurred.";
37
 
    print " looks just like the real ";
38
 
    if (noun == player) print "Alice";
39
 
    else PrintShortName(noun);
40
 
    " only all reversed, left for right.";
41
 
];
42
 
 
43
 
Extend "look"
44
 
    * "at" noun "in" noun -> Reflect;
45
 
 
46
 
Extend "examine"
47
 
    * noun "in" noun -> Reflect;
48
 
 
49
 
Verb "roll" "untangle" "wind"
50
 
    * noun -> Untangle
51
 
    * "up" noun -> Untangle
52
 
    * noun "up" -> Untangle;
53
 
 
54
 
Object  Drawing_Room "Drawing room"
55
 
 has    light
56
 
 with   name "snow",
57
 
        description "The gentle sound of snow against the window pane
58
 
            suggests that it's cold outside, and you're glad to be
59
 
            here in the warmth. The drawing-room is reflected in the
60
 
            large looking-glass on the wall above the mantelpiece,
61
 
            and a very comfortable room it is too, with a warm
62
 
            hearth, a soft rug and an arm-chair that you can curl up
63
 
            and sleep in.",
64
 
        before [;
65
 
            if (player in mantelpiece && (action == ##Exit || 
66
 
                (action == ##Go && noun == d_obj or out_obj)))
67
 
                "That's not the way to get down from a mantelpiece!";
68
 
            if (player in mantelpiece &&
69
 
                action ~= ##Examine or ##Enter or ##Go &&
70
 
                action ~= ##ThrownAt or ##ThrowAt or ##Reflect)
71
 
                if ((noun > 0 && noun notin mantelpiece &&
72
 
                    noun ~= mantelpiece or mirror && noun notin player) ||
73
 
                    (second > 0 && second notin mantelpiece &&
74
 
                    second ~= mantelpiece or mirror && second notin player))
75
 
                    "Not from up here you can't!";
76
 
        ];
77
 
 
78
 
Object  red_queen "red queen"
79
 
 has    female
80
 
 with   name "red" "queen",
81
 
        describe [;
82
 
            if (white_kitten.state == 1 || black_kitten.state == 1)
83
 
                rtrue;
84
 
        ],
85
 
        description "She's a fierce little chess piece.",
86
 
        after [;
87
 
         Take:
88
 
            if (white_kitten.state == 1) 
89
 
                white_kitten.state = 3;
90
 
            if (black_kitten.state == 1) 
91
 
                black_kitten.state = 3;
92
 
         PutOn,Transfer,Insert:
93
 
            if (second == chess_board)
94
 
                "Alone on the chess board, the red queen is monarch of
95
 
                all she surveys.";
96
 
        ];
97
 
 
98
 
Object  chess_board "chess board" Drawing_Room
99
 
 has    supporter
100
 
 with   name "chess" "board" "checker" "chequer" "chessboard",
101
 
        initial "An abandoned chess board lies on the floor.",
102
 
        description "It's left here from the game you were playing
103
 
            just now, but the pieces are all missing - the kittens
104
 
            will insist on playing with them.";
105
 
 
106
 
Object  hearth "hearth" Drawing_Room
107
 
 has    scenery
108
 
 with   name "hearth" "fire" "place" "fireplace";
109
 
 
110
 
Object  rug "rug" Drawing_Room
111
 
 has    concealed static supporter enterable
112
 
        ! general if you've found the red queen under it
113
 
 with   name "hearthrug" "hearth-rug" "rug" "indian" "arabian" "beautiful"
114
 
            "soft",
115
 
        description "It's a beautiful rug, made in some far off
116
 
            country, perhaps India or Araby, wherever those might
117
 
            be.",
118
 
        before [;
119
 
         Take: "The rug is much too large and heavy for you to carry.";
120
 
         Push,Pull: "But a hearth-rug is meant to be next to the
121
 
            hearth!";
122
 
         LookUnder:
123
 
            if (player in mantelpiece || player in armchair)
124
 
                "You're unable to reach the rug from here.";
125
 
            if (player in self)
126
 
                "You try to lift up a corner of the rug, but fail. After
127
 
                a while, you realise that this is because you are
128
 
                standing on it. How curious the world is!";
129
 
            if (self hasnt general) {
130
 
                give self general;
131
 
                move red_queen to player;
132
 
                "You lift up a corner of the rug and, peering
133
 
                underneath, discover the red queen from the chess
134
 
                set.";
135
 
            }
136
 
        ];
137
 
 
138
 
Object  armchair "arm-chair" Drawing_Room
139
 
 has    static concealed supporter enterable
140
 
        ! general if its by the mantelpiece
141
 
 with   name "arm" "chair" "armchair" "arm-chair",
142
 
        description [;
143
 
            print "It's a huge arm-chair, the perfect place for a kitten
144
 
                or a little girl to curl up in and doze. It has been
145
 
                pushed over to the ";
146
 
            if (self has general) "fireplace.";
147
 
            "window.";
148
 
        ],
149
 
        before [ i;
150
 
         Push,Pull:
151
 
            if (player notin Drawing_Room)
152
 
                print_ret "You'll have to get off ", (the) parent(player), 
153
 
                    " first.";
154
 
            if (white_kitten in player || black_kitten in player)
155
 
                "Not with a kitten in your arms!";
156
 
            if (white_kitten.state == 3) i = white_kitten;
157
 
            else if (black_kitten.state == 3) i = black_kitten;
158
 
            if (i ~= 0)
159
 
                print_ret "You are about to start moving the chair when you
160
 
                    notice that ", (the) i, " is right in the way. It's a
161
 
                    good thing you spotted it, or you would have squashed
162
 
                    flat the poor little thing.";
163
 
            if (self has general) {
164
 
                give self ~general;
165
 
                "You push the arm-chair away from the hearth.";
166
 
            }
167
 
            give self general;
168
 
            "You push the arm-chair over to the hearth.";
169
 
         Climb,Enter:
170
 
            move player to armchair;
171
 
            "You jump into the warm and comfortable arm-chair.";
172
 
        ];
173
 
 
174
 
Object  mantelpiece "mantelpiece" Drawing_Room
175
 
 has    concealed supporter enterable
176
 
 with   name "mantel" "mantelpiece",
177
 
        description "It's higher off the ground than your head, but
178
 
            it looks wide enough and sturdy enough to support you.",
179
 
        before [;
180
 
         Enter,Climb:
181
 
            if (player notin armchair)
182
 
                "The mantelpiece is much too high to climb up onto.";
183
 
            if (armchair hasnt general)
184
 
                "You can't reach the mantelpiece from here.";
185
 
            if (children(player) > 0)
186
 
                "Your hands are too full.";
187
 
            move player to mantelpiece;
188
 
            "You scramble up onto the mantelpiece.";
189
 
         PutOn,LetGo:
190
 
            if (player notin self && (player notin armchair || 
191
 
                armchair hasnt general))
192
 
                "The mantelpiece is so high that you can't reach.";
193
 
        ];
194
 
 
195
 
Object  mirror "looking-glass" Drawing_Room
196
 
 has    static concealed
197
 
 with   name "mirror" "looking" "glass" "looking-glass",
198
 
        description [;
199
 
            if (player in mantelpiece)
200
 
                "Strangely, the glass is beginning to melt away,
201
 
                just like a bright silvery mist.";
202
 
            if (player in armchair)
203
 
                "In the looking-glass you can see the drawing-room of
204
 
                the looking-glass house. What you can see is very
205
 
                much the same as this drawing-room, only all
206
 
                reversed, left for right. But you are sure that out
207
 
                of the corners of the glass, where you can't see, the
208
 
                looking-glass world is quite different from yours.";
209
 
            "In the looking-glass you can see the ceiling of the
210
 
            drawing-room of the looking-glass house. It looks much
211
 
            the same as the ceiling of your drawing-room.";
212
 
        ],
213
 
        before [;
214
 
            if (action ~= ##Examine or ##ThrownAt or ##Reflect &&
215
 
                player notin mantelpiece)
216
 
                "You can't reach the looking-glass from where you're
217
 
                standing.";
218
 
         Touch,Pull,Push:
219
 
            "Your hand goes right through the silvery mist!";
220
 
         ThrownAt: "You don't want seven years' bad luck, do you?";
221
 
         Enter:
222
 
            ! Really, move Alice to the looking-glass house.
223
 
            deadflag = 2;
224
 
            "Your hand goes right through the silvery mist, and in
225
 
            another moment the rest of you follows, and you are
226
 
            through the glass...";
227
 
        ];
228
 
 
229
 
Object  worsted "ball of worsted" Drawing_Room
230
 
        ! general if its in a tangle
231
 
 with   name "ball" "of" "worsted" "fine" "blue" "wool",
232
 
        describe [;
233
 
            if (white_kitten.state ~= 2 &&
234
 
                black_kitten.state ~= 2)
235
 
                "^A discarded ball of worsted lies on the floor here.";
236
 
            rtrue;
237
 
        ],
238
 
        description [;
239
 
            if (self has general)
240
 
                "It's in a terrible tangle. All that time you spent
241
 
                rolling it up, and now look at it!";
242
 
            "It's a ball of fine blue wool, all rolled up in preparation
243
 
            for some embroidery.";
244
 
        ],
245
 
        before [;
246
 
         Untangle: 
247
 
            give self ~general;
248
 
            "You're as quick as can be at rolling up balls of wool,
249
 
            though you say so yourself! Soon it's neat and tidy again.";
250
 
        ],
251
 
        after [;
252
 
         Take:
253
 
            if (white_kitten.state == 2) 
254
 
                white_kitten.state = 3;
255
 
            if (black_kitten.state == 2) 
256
 
                black_kitten.state = 3;
257
 
        ];
258
 
 
259
 
Object  chess_pieces "chess pieces" Drawing_Room
260
 
 has    scenery
261
 
 with   parse_name [ w colour n;
262
 
            w = NextWord();
263
 
            if (w == 'white' or 'red') {
264
 
                n ++;
265
 
                colour = w;
266
 
                w = NextWord();
267
 
            }
268
 
            if (w == 'pawn' or 'rook' or 'castle' ||
269
 
                w == 'knight' or 'horse' or 'bishop' ||
270
 
                w == 'king' || (w == 'queen' && 
271
 
                (colour == 'white' || rug hasnt general))) return n + 1;
272
 
            return 0;
273
 
        ],
274
 
        before [;
275
 
            "Alas, that chess piece seems to be missing. Those
276
 
            naughty kittens!";
277
 
        ];
278
 
 
279
 
Object  window "window" Drawing_Room
280
 
 has    scenery
281
 
 with   name "window" "pane",
282
 
        description "Outside the window it's snowing gently, and you're
283
 
            glad to be in here in the warmth.",
284
 
        before [;
285
 
         Open: "You wouldn't want to catch a chill, would you?  Better
286
 
            leave the window shut.";
287
 
         Search: <<Examine self>>;
288
 
        ];
289
 
 
290
 
Property other_kitten;
291
 
Property state; ! 1=red queen, 2=ball of wool, 3=arm-chair, 0=held
292
 
 
293
 
Class   Kitten_Class
294
 
 has    animate
295
 
        ! general if it's been described this turn
296
 
 with   parse_name [ w ok n;
297
 
            do {
298
 
                ok = 0;
299
 
                w = NextWord();
300
 
                if (w == 'kittens' or 'cats') {
301
 
                    ok = 1; n++; parser_action=##PluralFound; 
302
 
                }
303
 
                if (w == 'kitten' or 'kitty' or 'cat' ||
304
 
                    w == ((self.&name)-->0)) { 
305
 
                    ok = 1; n++;
306
 
                }
307
 
            } until (ok == 0);
308
 
            return n;
309
 
        ],
310
 
        state 3,
311
 
        describe [ i;
312
 
            switch (self.state) {
313
 
             1: print_ret "^A ", (name) self, " is playing with the red
314
 
                    queen.";
315
 
             2: print_ret "^A ", (name) self, " is playing with a ball of
316
 
                    worsted.";
317
 
             3: if (self has general) rtrue;
318
 
                if ((self.other_kitten).state == 3) {
319
 
                    i = self.other_kitten;
320
 
                    give i general;
321
 
                    "^Two kittens, one white and one black, are playing
322
 
                    together by the arm-chair.";
323
 
                }
324
 
                print_ret "^A ", (name) self, " is playing by the
325
 
                    arm-chair.";
326
 
             default: rtrue;
327
 
            }
328
 
        ],
329
 
        description [;
330
 
            print_ret "What a beautiful kitten ", (the) self, " is. Why,
331
 
                it's quite definitely your favourite of the pair, and
332
 
                much prettier than that naughty ", (name) 
333
 
                self.other_kitten, ".";
334
 
        ],
335
 
        life [;
336
 
         Ask,Answer,Order:
337
 
            print_ret (The) self, " twitches its whiskers and looks at
338
 
                you with such a clever expression that you are certain it
339
 
                understands every word you are saying.";
340
 
         Kiss: 
341
 
            print_ret "You give ", (the) self, " a little kiss on its
342
 
                nose, and it looks sweetly and demurely at you.";
343
 
         Attack: "You would never do such a beastly thing to such
344
 
            a defenceless little animal!";
345
 
         Show: 
346
 
            print_ret (The) self, " bats a paw at ", (the) noun, ".";
347
 
         Give,ThrowAt:
348
 
            if (noun ~= red_queen or worsted) {
349
 
                if (action == ##ThrowAt) {
350
 
                    move noun to Drawing_Room;
351
 
                    print "You toss ", (the) noun, " onto the floor, but ",
352
 
                        (the) self;
353
 
                }
354
 
                else print (The) self;
355
 
                print_ret " just examines ", (the) noun, " with a
356
 
                    quizzical expression.";
357
 
            }
358
 
            print "You toss ", (the) noun, " onto the floor and ", (the) self;
359
 
            if (self in player)
360
 
                print " squirms out of your grasp and";
361
 
            move noun to Drawing_Room;
362
 
            move self to Drawing_Room;
363
 
            print " scampers after it";
364
 
            if (noun == worsted) {
365
 
                give worsted general;
366
 
                self.state = 2;
367
 
                print ", quickly turning the neat ball into a tangle";
368
 
            }
369
 
            else self.state = 1;
370
 
            ".";
371
 
        ],
372
 
        before [;
373
 
         Take:
374
 
            if (self.other_kitten in player)
375
 
                "You can't hold two kittens at once!";
376
 
            self.state = 0;
377
 
            move self to player;
378
 
            print_ret "You pick up ", (the) self, ". What a beautiful
379
 
                creature it is!";
380
 
        ],
381
 
        after [;
382
 
         Drop:
383
 
            self.state = 3;
384
 
            move self to Drawing_Room;
385
 
            print_ret (The) self, " squirms out of your arms and scampers
386
 
                away.";
387
 
         Transfer,PutOn,Insert:
388
 
            self.state = 3;
389
 
            print (The) self, " jumps off ", (the) parent(self);
390
 
            move self to Drawing_Room;
391
 
            ", landing lightly on the floor before scampering away.";
392
 
        ],
393
 
        daemon [ i;
394
 
            give self ~general;
395
 
            self.number = 1 - self.number;
396
 
            if (self.number == 1 || random(3) == 2) rtrue;
397
 
            new_line;
398
 
            print (The) self;
399
 
            switch (self.state) {
400
 
             0: switch(random(5)) {
401
 
                 1: " mews plaintively.";
402
 
                 2: " purrs quietly to itself.";
403
 
                 3: " purrs contentedly to itself.";
404
 
                 4: " rubs its ears against you.";
405
 
                 5: move self to Drawing_Room;
406
 
                    self.state = 3;
407
 
                    " squirms out of your arms and scampers away.";
408
 
                }
409
 
             1: switch (random(5)) {
410
 
                 1: " bats at the red queen with its paw.";
411
 
                 2: " stops playing and sits up, pretending to be
412
 
                    innocent of any kittenish tendancies.";
413
 
                 3: " knocks the red queen across the floor and chases
414
 
                    after it.";
415
 
                 4: " stops to wash itself.";
416
 
                 5: " bites the red queen and shakes it to make sure that
417
 
                    it's dead.";
418
 
                }
419
 
             2: give worsted general;
420
 
                switch (random(5)) {
421
 
                 1: " bats at the ball of worsted with its paw.";
422
 
                 2: " pushes the ball of worsted across the floor and
423
 
                    chases after it.";
424
 
                 3: " leaps onto the ball of worsted and grapples bravely
425
 
                    with it.";
426
 
                 4: " jumps into the ball of worsted and gets tangled up
427
 
                    in a mess of threads.";
428
 
                 5: " stops playing and scratches its ears.";
429
 
                }
430
 
             3: if ((self.other_kitten).state == 3 && random(2) == 1) {
431
 
                    i = random(5);
432
 
                    switch (i) {    
433
 
                     1: print " chases after ";
434
 
                     2: print " jumps on top of ";
435
 
                     3: print " washes ";
436
 
                     4: print " scampers around the arm-chair and ";
437
 
                     5: print " bats at ";
438
 
                    }
439
 
                    print (the) self.other_kitten;
440
 
                    switch (i) {
441
 
                     1,3: ".";
442
 
                     2: " and they roll around on the floor.";
443
 
                     4: " chases after it.";
444
 
                     5: " with its paw.";
445
 
                    }
446
 
                }
447
 
                switch (random(5)) {
448
 
                 1: " scampers after a speck of dust.";
449
 
                 2: " rolls around on the floor.";
450
 
                 3: " sits up and washes its tail.";
451
 
                 4: " scratches its head on the arm-chair.";
452
 
                 5: " chases its tail.";
453
 
                }
454
 
            }
455
 
        ];
456
 
 
457
 
Object  white_kitten "white kitten" Drawing_Room
458
 
 class  Kitten_Class
459
 
 with   name "white",
460
 
        number 0,
461
 
        other_kitten black_kitten;
462
 
 
463
 
Object  black_kitten "black kitten" Drawing_Room
464
 
 class  Kitten_Class
465
 
 with   name "black",
466
 
        number 1,
467
 
        other_kitten white_kitten;
468
 
 
469
 
End;
 
 
b'\\ No newline at end of file'