! This source is public domain

Constant Story "Pick Up the Phone Booth and Dye";
Constant Headline "^This game is public domain^
                  Eric Schmidt <eschimdt@@64safeaccess.com>^";

Release 2;
Serial "345678";

Constant MAX_SCORE = 20;

Include "Parser";
Include "VerbLib";

[ Initialise;
 location = field;
];

[ Boothdeath;
 deadflag = 1;
 "Unfortunately, you do not have enough hands to hold
  both the bucket and the phone booth. You drop the booth
  on top of yourself.";
];

CompassDirection ground "ground" compass
 with name 'ground', door_dir d_to;

Object field "Field" has light
 with description "This is just an ordinary field in the middle
                   of nowhere. You have no idea why you're here.";

Object -> booth "phone booth" has supporter enterable
 with name 'large' 'phone' 'booth',
      description [; if (dye notin self)
                   "The phone booth is large and has the word ~TELEPHONE~
                   in red in the front.";
                   "The phone booth is large and has dye splattered all
                    over it!";
                  ],
      before [; Open: "Try as you might, you cannot force the booth open!"; ],
      after [;
        Take:
          if (bucket in player) { Boothdeath(); rtrue; }
          print "You grasp the phone booth and slowly lift it up.";
            if (bucket in self) {
              move bucket to field;
              print " The bucket falls off the phone booth and hits
                     the ground.";
              if (dye in bucket) {
                remove dye;
                " The dye pours out of the bucket.";
              }
            }
            if (dye in self) {
              score = 20;
              deadflag = 2;
              "^^You have managed to pick up the phone booth
                and the dye at the same time. Congratulations!";
            }
            new_line;
            rtrue;
      ];

Object -> bucket "bucket" has container open
 with name 'white' 'bucket' 'pail',
      description "The bucket is all white.",
      before [;
        Take: if (player in booth && bucket notin booth)
                "You can't reach the bucket.";
        Pour: if (dye notin self)
                "The dye is no longer available.";
              <<Pour dye second>>;
        Receive: if (noun == player) "I don't think you'd fit.";
                 if (noun == booth) "That's impossible.";
      ],
      after [;
        Take: if (booth in player) { BoothDeath(); rtrue; }
        "You take the bucket.";
      ];

Object -> -> dye "dye"
 with name 'thin' 'blue' 'dye',
      article "some",
      description "The dye is thin and blue.",
      before [; Take: if (self notin bucket)
                  "You cannot hold the dye with your bare hands.";
                if (bucket in player) "You already have that.";
                  <<Take bucket>>;
                Remove:
                  "You cannot hold the dye with your bare hands.";
                Drop:
                  if (self in bucket) <<Drop bucket>>;
                Pour:
                  if (bucket notin player || self notin bucket)
                    "You don't have the dye.";
                  switch (second) {
                    booth:
                      move self to booth;
                      "You pour the dye all over the booth. It
                       soon dries up.";
                    sign:
                      move self to sign;
                      "You pour the dye over the sign. It soon
                       dries up.";
                    bucket, dye:
                      "How would you manage that?";
                    selfobj: "You comtemplate this, but decide
                              against it.";
                    d_obj, ground: remove self;
                           "You pour the dye into the ground.";
                    default: "Huh?";
                  }
                 PutOn: <<Pour self second>>;
                 Drink: remove self; "Well, that didn't taste half-bad.";
             ];

Object -> sign "sign" has static supporter
 with name 'sign',
      description [; if (dye notin self)
                       "The sign reads, ~To win the game, you must
                        be holding both the booth and the dye at the
                        same time.~";
                     "Some moron put dye all over the sign, and you can't
                      read it.";
                  ],
      before [;
        Receive:
          if (noun == bucket) {
            if (player in booth) "From way up here?";
            move bucket to field;
            print "You attempt to balance the bucket on the sign, but it
                   falls off.";
            if (dye in bucket) {
              remove dye;
              " The dye spills out of the bucket and soaks into the ground.";
            }
            new_line;
            rtrue;
          }
          if (noun == booth) "That doesn't seem very realistic, does it?";
      ];

Include "Grammar";

[PourSub;
 "You can't pour ", (the) noun, ".";
];

[XyzzySub;
 if (dye in sign or nothing) {
   move dye to bucket;
   "A chilly gale picks up, but recedes after a few seconds.";
 }
 "Nothing seems to happen.";
];

Verb 'pour' 'slosh' 'splatter'
 * noun 'over'/'on'/'onto' noun -> Pour;

Verb 'xyzzy' * -> Xyzzy;