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")
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"
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"
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")
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
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)
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
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
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"