Inform - Resources - Examples

Back to List

Inventory
Complete

Backward
At End

Plain
Coloured
Gaudy

This code
in plain text

Browsing Alice3.inf

The kittens (lines 305-484)

305  Class   Kitten
306   has    animate
307          ! general if it's been described this turn
308   with   parse_name [ w ok n;
309              do {
310                  ok = 0;
311                  w = NextWord();
312                  if (w == 'kittens' or 'cats') {
313                      ok = 1; n++; parser_action=##PluralFound; 
314                  }
315                  if (w == 'kitten' or 'kitty' or 'cat' ||
316                      w == ((self.&name)-->0)) { 
317                      ok = 1; n++;
318                  }
319              } until (ok == 0);
320              return n;
321          ],
322   
323          state CHAIR_STATE,
324   
325          describe [ i;
326              switch (self.state) {
327               QUEEN_STATE:
328                  "^A ", (name) self, " is playing with the red queen.";
329               WOOL_STATE:
330                  "^A ", (name) self, " is playing with a ball of worsted.";
331               CHAIR_STATE:
332                  if (self has general) rtrue;
333                  if ((self.other_kitten).state == 3) {
334                      i = self.other_kitten;
335                      give i general;
336                      "^Two kittens, one white and one black, are playing
337                      together by the arm-chair.";
338                  }
339                  "^A ", (name) self, " is playing by the arm-chair.";
340               default: rtrue;
341              }
342          ],
343          description [;
344              "What a beautiful kitten ", (the) self, " is. Why,
345              it's quite definitely your favourite of the pair, and
346              much prettier than that naughty ",
347              (name) self.other_kitten, ".";
348          ],
349          life [;
350           Ask,Answer,Order:
351              print_ret (The) self, " twitches its whiskers and looks at
352                  you with such a clever expression that you are certain it
353                  understands every word you are saying.";
354           Kiss: 
355              "You give ", (the) self, " a little kiss on its
356              nose, and it looks sweetly and demurely at you.";
357           Attack: "You would never do such a beastly thing to such
358              a defenceless little animal!";
359           Show: 
360              print_ret (The) self, " bats a paw at ", (the) noun, ".";
361           Give,ThrowAt:
362              if (noun ~= red_queen or worsted) {
363                  if (action == ##ThrowAt) {
364                      move noun to Drawing_Room;
365                      print "You toss ", (the) noun, " onto the floor, but ",
366                          (the) self;
367                  }
368                  else print (The) self;
369                  " just examines ", (the) noun,
370                  " with a quizzical expression.";
371              }
372              print "You toss ", (the) noun, " onto the floor and ", (the) self;
373              if (self in player)
374                  print " squirms out of your grasp and";
375              move noun to Drawing_Room;
376              move self to Drawing_Room;
377              print " scampers after it";
378              if (noun == worsted) {
379                  give worsted general;
380                  self.state = WOOL_STATE;
381                  print ", quickly turning the neat ball into a tangle";
382              }
383              else self.state = QUEEN_STATE;
384              ".";
385          ],
386          before [;
387           Take:
388              if (self.other_kitten in player)
389                  "You can't hold two kittens at once!";
390              self.state = HELD_STATE;
391              move self to player;
392              "You pick up ", (the) self,
393              ". What a beautiful creature it is!";
394           Touch, Rub: print_ret (The) self, " rubs its head against you and purrs softly.";
395          ],
396          after [;
397           Drop:
398              self.state = CHAIR_STATE;
399              move self to Drawing_Room;
400              print_ret (The) self, " squirms out of your arms and scampers
401                  away.";
402           Transfer,PutOn,Insert:
403              self.state = CHAIR_STATE;
404              print (The) self, " jumps off ", (the) parent(self);
405              move self to Drawing_Room;
406              ", landing lightly on the floor before scampering away.";
407          ],
408          daemon [ i;
409              give self ~general;
410              self.this_kittens_turn = 1 - self.this_kittens_turn;
411              if (self.this_kittens_turn == false || random(3) == 2) rtrue;
412              new_line;
413              print (The) self;
414              switch (self.state) {
415               HELD_STATE:
416                  switch(random(5)) {
417                   1: " mews plaintively.";
418                   2: " purrs quietly to itself.";
419                   3: " purrs contentedly to itself.";
420                   4: " rubs its ears against you.";
421                   5: move self to Drawing_Room;
422                      self.state = CHAIR_STATE;
423                      " squirms out of your arms and scampers away.";
424                  }
425               QUEEN_STATE:
426                  switch (random(5)) {
427                   1: " bats at the red queen with its paw.";
428                   2: " stops playing and sits up, pretending to be
429                      innocent of any kittenish tendancies.";
430                   3: " knocks the red queen across the floor and chases
431                      after it.";
432                   4: " stops to wash itself.";
433                   5: " bites the red queen and shakes it to make sure that
434                      it's dead.";
435                  }
436               WOOL_STATE:
437                  give worsted general;
438                  switch (random(5)) {
439                   1: " bats at the ball of worsted with its paw.";
440                   2: " pushes the ball of worsted across the floor and
441                      chases after it.";
442                   3: " leaps onto the ball of worsted and grapples bravely
443                      with it.";
444                   4: " jumps into the ball of worsted and gets tangled up
445                      in a mess of threads.";
446                   5: " stops playing and scratches its ears.";
447                  }
448               CHAIR_STATE:
449                  if ((self.other_kitten).state == CHAIR_STATE && random(2) == 1) {
450                      i = random(5);
451                      switch (i) {    
452                       1: print " chases after ";
453                       2: print " jumps on top of ";
454                       3: print " washes ";
455                       4: print " scampers around the arm-chair and ";
456                       5: print " bats at ";
457                      }
458                      print (the) self.other_kitten;
459                      switch (i) {
460                       1,3: ".";
461                       2: " and they roll around on the floor.";
462                       4: " chases after it.";
463                       5: " with its paw.";
464                      }
465                  }
466                  switch (random(5)) {
467                   1: " scampers after a speck of dust.";
468                   2: " rolls around on the floor.";
469                   3: " sits up and washes its tail.";
470                   4: " scratches its head on the arm-chair.";
471                   5: " chases its tail.";
472                  }
473              }
474          ];
475   
476  Kitten  white_kitten "white kitten" Drawing_Room
477   with   name "white",
478          this_kittens_turn false,
479          other_kitten black_kitten;
480   
481  Kitten  black_kitten "black kitten" Drawing_Room
482   with   name "black",
483          this_kittens_turn true,
484          other_kitten white_kitten;


Last updated 23 June 2004. This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation. Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight.