コード例 #1
0
 def move(self, destination):
     if not self.acted and not self.asleep:
         if not self.location.isConnectedTo(destination):
             raise client_action.ActionError(
                 "NOTCONNECTED",
                 "Cannot move to destination, it is not connected to current location")
         elif len(destination.people) + 1 > len(destination.chairs + destination.stand):
             raise client_action.ActionError(
                 "ROOMISFULL",
                 "Cannot move to destination, it is full.")
         else:
             destination.addMember(self)
             self.location.removeMember(self)
             self.location = destination
         self.acted = "move"
     else:
         if self.acted:
             if self.acted == "distracted":
                 raise client_action.ActionError(
                     "DISTRACTED",
                     "You have been distracted this turn")
             raise client_action.ActionError(
                 "ALREADYACTED",
                 "Cannot move to destination, this player has already acted this turn")
         if self.asleep:
             raise client_action.ActionError(
                 "ASLEEP",
                 "Cannot move to destination, this player is asleep")
コード例 #2
0
 def view(self):
     self._can_move()
     if not self.location.isAvailable('PROJECTOR'):
         raise client_action.ActionError('NOPROJECTOR',
                                         "This room does not have a projector!")
     if not self.location.isAvailable('PRACTICE'):
         raise client_action.ActionError('NOPRACTICE',
                                         "The projector is not currently running practice games.")
     self.acted = "view"
コード例 #3
0
 def wake(self, victim):
     self._can_move()
     if victim.location != self.location:
         raise client_action.ActionError(
             "CANNOTWAKE", "Cannot wake someone who is in another room")
     if not victim.asleep:
         raise client_action.ActionError(
             "CANNOTWAKE", "Cannot wake someone who is not asleep")
     victim.asleep = False
     self.acted = "wake"
コード例 #4
0
 def _can_move(self):
     if self.acted != None:
         if self.acted == "distracted":
             raise client_action.ActionError(
                 "DISTRACTED", "You have been distracted this turn")
         raise client_action.ActionError(
             "ALREADYACTED", "This player has already acted this turn")
     if self.asleep:
         raise client_action.ActionError("ASLEEP", "This player is asleep")
     if self.hunger >= 100:
         raise client_action.ActionError(
             "HUNGRY",
             "This player is too hungry to think about anything but food")
コード例 #5
0
 def addMember(self, member):
     if member in self.people:
         raise client_action.ActionError(
             "ALREADYINROOM",
             "Cannot move to destination, you are in the room already")
     additionalpeople = 0
     if "PROFESSOR" in self.resources:
         additionalpeople += 1
     if len(self.people) + 1 + additionalpeople > len(self.chairs +
                                                      self.stand):
         raise client_action.ActionError(
             "ROOMISFULL", "Cannot move to destination, it is full.")
     self.people.add(member)
     member.sitting = False
コード例 #6
0
 def eat(self):
     if self.acted:
         raise client_action.ActionError(
             "ALREADYACTED", "This player has already acted this turn")
     if self.asleep:
         raise client_action.ActionError("ASLEEP", "This player is asleep")
     if not self.location.isAvailable('FOOD'):
         raise client_action.ActionError('NOFOODHERE',
                                         "This room does not contain food")
     self.hunger -= 10.0 * (100.0 / (8.0 * self.ticks_in_hour))
     if self.hunger < 0.0:
         self.hunger = 0.0
     self.acted = "eat"
     self.location.standUp(self)
コード例 #7
0
 def standUp(self, member):
     if not member in self.people:
         raise client_action.ActionError("NOTINROOM",
                                         "This person is not in this room")
     if member in self.sitting:
         self.sitting.remove(member)
         member.sitting = False
コード例 #8
0
 def sitDown(self, member):
     if not member in self.people:
         raise client_action.ActionError("NOTINROOM",
                                         "This person is not in this room")
     elif len(self.sitting) + 1 > len(self.chairs):
         return
     elif not member in self.sitting:
         self.sitting.add(member)
         member.sitting = True
コード例 #9
0
 def distract(self, victim):
     self._can_move()
     if victim.location != self.location:
         raise client_action.ActionError(
             "UNDISTRACTABLE",
             "Cannot distract someone who is in another room")
     if victim.asleep:
         raise client_action.ActionError(
             "UNDISTRACTABLE", "Cannot distract someone who is asleep")
     if victim.acted:
         raise client_action.ActionError(
             "UNDISTRACTABLE",
             "Distraction failed because they ignored you")
     if victim.hunger >= 100:
         raise client_action.ActionError(
             "UNDISTRACTABLE",
             "Cannot distract someone who is focused on food")
     victim.acted = "distracted"
     self.acted = "distract"