Commits

Brandon Rhodes committed bbfd860

Thoroughly tested and debugged locking/unlocking, lighting, and extinguishing.

  • Participants
  • Parent commits c49257b

Comments (0)

Files changed (2)

File adventure/game.py

                         self.write_message(173)
                     elif self.chain.prop != 0:
                         self.write_message(34)
-                    self.chain.prop = 2
-                    if self.chain.is_toting:
-                        self.chain.drop(self.loc)
-                    self.chain.is_fixed = True
-                    self.write_message(172)
+                    else:
+                        self.chain.prop = 2
+                        if self.chain.is_toting:
+                            self.chain.drop(self.loc)
+                        self.chain.is_fixed = True
+                        self.write_message(172)
             elif self.is_closing:
                 if not self.panic:
                     self.clock2 = 15
                 obj.prop = 0 if verb == 'lock' else 1
                 self.write_message(34 + oldprop + 2 * obj.prop)
         else:
-            self.write(verb.names)
-            self.write(obj.names)
             self.write(verb.default_message)
         self.finish_turn()
 
     def t_light(self, verb, obj=None):  #9070
         if not self.is_here(self.lamp):
             self.write(verb.default_message)
-        elif self.lamp_turns == 0:
+        elif self.lamp_turns <= 0:
             self.write_message(184)
         else:
             self.lamp.prop = 1

File adventure/tests/vignettes.txt

 THERE IS A BOTTLE OF WATER HERE.
 <BLANKLINE>
 
->>> restart(room=94, objects=[oyster])
+>>> restart(room=94, objects=[clam])
 >>> look
 YOU ARE AT ONE END OF AN IMMENSE NORTH/SOUTH PASSAGE.
 <BLANKLINE>
 THE WAY NORTH IS BARRED BY A MASSIVE, RUSTY, IRON DOOR.
 <BLANKLINE>
-THERE IS AN ENORMOUS OYSTER HERE WITH ITS SHELL TIGHTLY CLOSED.
+THERE IS AN ENORMOUS CLAM HERE WITH ITS SHELL TIGHTLY CLOSED.
 <BLANKLINE>
 >>> unlock                      # two unlockable objects are present
 UNLOCK WHAT?
 THERE IS NOTHING HERE WITH A LOCK!
 <BLANKLINE>
 
+>>> restart(room=103, objects=[trident])
+>>> lock(clam)
+WHAT?
+<BLANKLINE>
+>>> quiet(get(clam), get(trident))
+>>> unlock
+I ADVISE YOU TO PUT DOWN THE CLAM BEFORE OPENING IT.  >STRAIN!<
+<BLANKLINE>
+>>> quiet(drop(clam))
+>>> unlock
+A GLISTENING PEARL FALLS OUT OF THE CLAM AND ROLLS AWAY.  GOODNESS,
+THIS MUST REALLY BE AN OYSTER.  (I NEVER WAS VERY GOOD AT IDENTIFYING
+BIVALVES.)  WHATEVER IT IS, IT HAS NOW SNAPPED SHUT AGAIN.
+<BLANKLINE>
+>>> unlock
+THE OYSTER CREAKS OPEN, REVEALING NOTHING BUT OYSTER INSIDE.  IT
+PROMPTLY SNAPS SHUT AGAIN.
+<BLANKLINE>
+
+>>> restart(room=94)
+>>> look
+YOU ARE AT ONE END OF AN IMMENSE NORTH/SOUTH PASSAGE.
+<BLANKLINE>
+THE WAY NORTH IS BARRED BY A MASSIVE, RUSTY, IRON DOOR.
+<BLANKLINE>
+>>> unlock
+THE DOOR IS EXTREMELY RUSTY AND REFUSES TO OPEN.
+<BLANKLINE>
+
+>>> restart()
+>>> unlock(keys)
+YOU CAN'T UNLOCK THE KEYS.
+<BLANKLINE>
+>>> quiet(get(keys), get(food), goto(10))
+>>> unlock(cage)
+IT HAS NO LOCK.
+<BLANKLINE>
+>>> quiet(goto(130))
+>>> lock(chain)
+IT WAS ALREADY LOCKED.
+<BLANKLINE>
+>>> unlock(chain)
+THERE IS NO WAY TO GET PAST THE BEAR TO UNLOCK THE CHAIN, WHICH IS
+PROBABLY JUST AS WELL.
+<BLANKLINE>
+>>> quiet(throw(food), unlock(chain))
+>>> unlock(chain)
+IT WAS ALREADY UNLOCKED.
+<BLANKLINE>
+>>> quiet(get(chain), w)
+>>> lock(chain)
+THERE IS NOTHING HERE TO WHICH THE CHAIN CAN BE LOCKED.
+<BLANKLINE>
+>>> quiet(e)
+>>> lock(chain)
+THE CHAIN IS NOW LOCKED.
+<BLANKLINE>
+>>> get(chain)
+THE CHAIN IS STILL LOCKED.
+<BLANKLINE>
+>>> lock(bear)
+I DON'T KNOW HOW TO LOCK OR UNLOCK SUCH A THING.
+<BLANKLINE>
+
+>>> restart()
+>>> off
+YOUR LAMP IS NOW OFF.
+<BLANKLINE>
+>>> quiet(drop(lamp), leave)
+>>> on
+YOU HAVE NO SOURCE OF LIGHT.
+<BLANKLINE>
+>>> off
+YOU HAVE NO SOURCE OF LIGHT.
+<BLANKLINE>
+>>> quiet(enter, get(lamp), on, plugh)
+>>> off
+YOUR LAMP IS NOW OFF.
+<BLANKLINE>
+IT IS NOW PITCH DARK.  IF YOU PROCEED YOU WILL LIKELY FALL INTO A PIT.
+<BLANKLINE>
+>>> quiet(on)
+>>> game.lamp_turns = 2
+>>> quiet(look)
+>>> look
+YOUR LAMP HAS RUN OUT OF POWER.
+<BLANKLINE>
+IT IS NOW PITCH DARK.  IF YOU PROCEED YOU WILL LIKELY FALL INTO A PIT.
+<BLANKLINE>
+>>> on
+YOUR LAMP HAS RUN OUT OF POWER.
+<BLANKLINE>
 
 
 todo: test plant2 in repository