Esempio n. 1
0
    def checkKeyMatch(self, key):
        """ Check to see if the given key matches this object's lock.

        Raise a error.Failure if it does not.  Override this method to
        implement different key-matching mechanisms; by default, I will check
        that one of the key's lockTypes is in my list of lockTypes.
        """
        if not reflect.isinst(key, Key):
            error.Failure("That's not a key.")
        for type in key.lockTypes:
            if type in self.lockTypes:
                return
        error.Failure(key, " doesn't seem to fit.")
Esempio n. 2
0
 def verb_close(self, sentence):
     "I'm afraid I can't do that, dave."
     perp = sentence.subject()
     if not self.isOpen:
         error.Failure("It's already closed.")
     self.close(actor=perp)
     perp.hears("You close ", self, '.')
Esempio n. 3
0
 def verb_open(self, sentence):
     "Open the pod-bay doors, hal."
     perp = sentence.subject()
     if self.isOpen:
         error.Failure("It's already open.")
     self.open(actor=perp)
     perp.hears("You open ", self, '.')
Esempio n. 4
0
 def remove(self, actor):
     """ Remove a piece of clothing.
     """
     self._remove(actor)
     if self.wearer:
         wearer = self.wearer
         clothes = self.wearer.clothing
         for location in self.clothing_slots:
             cloth = clothes[location][-1]
             if cloth is not self:
                 raise error.Failure("You'd have to remove ", cloth,
                                     " first.")
         for location in self.clothing_slots:
             clothes[location].pop()
         self.component = 0
         self.wearer = None
         wearer.describe('clothing', clothing_descript(wearer))
Esempio n. 5
0
 def checkLock(self):
     "raise an appropriate exception if this is locked."
     if self.locked:
         error.Failure(self, " is locked.")
Esempio n. 6
0
 def verb_close(self, sentence):
     sentence.shouldOnlyHave('')
     if not self.isOpen:
         error.Failure("It's already closed.")
     else:
         self.action_Close(sentence.subject)
Esempio n. 7
0
 def verb_open(self, sentence):
     sentence.shouldOnlyHave('')
     if self.isOpen:
         error.Failure("It's already open.")
     else:
         self.action_Open(sentence.subject)
Esempio n. 8
0
 def verb_put_in(self, sentence):
     sentence.shouldOnlyHave('', 'in')
     if self.isOpen:
         sentence.directObject().move(self.contents, sentence.subject)
     else:
         error.Failure("It's closed.")
Esempio n. 9
0
 def _open(self, actor):
     if not actor.wizbit:
         error.Failure(self, " just doesn't seem to budge.")
Esempio n. 10
0
 def verb_remove(self, sentence):
     if sentence.subject is not self.wearer:
         error.Failure("You're not wearing that.")
     self.remove(sentence.subject)
Esempio n. 11
0
 def verb_wear(self, sentence):
     if self.wearer:
         error.Failure("That's already being worn.")
     self.wear(sentence.subject)