def go(direction): exit = world.my_avatar.location.find_exit_in_direction(direction) if exit: world.my_avatar.take_exit(exit) else: messaging.narrate(["No exit in", direction, "direction"], world.my_avatar)
def move_drop(mobile_thing, from_bag, to_place, actor): former_holder = from_bag.holder if former_holder is actor: narrate([actor, "drops", mobile_thing], actor) else: narrate([actor, "takes", mobile_thing, "from", former_holder, "and drops it"], actor) say(former_holder, ["What did you do that for?"]) move_internal(mobile_thing, from_bag, to_place)
def move_take(mobile_thing, from_place, to_bag, actor): new_holder = to_bag.holder if actor is new_holder: narrate([actor, "picks up", mobile_thing], actor) else: narrate([actor, "picks up", mobile_thing, "and gives it to", new_holder], actor) say(new_holder, ["Whoa! Thanks, dude!"]) move_internal(mobile_thing, from_place, to_bag)
def eat_people(self): if flip_coin(self.hunger): people = self.people_here() if not people: narrate([possessive(self), "belly rumbles"], self) else: victim = random_choice(people) narrate([self, "takes a bite out of", victim], self) victim.suffer(random_number(3))
def move_person(person, src, dst, actor): if src is world.heaven or dst is world.heaven: move_internal(person, src, dst) exit = src.find_exit(dst) if not exit: tell(["There is no exit from", src, "to", dst], actor) elif person is actor: narrate([person, "leaves via the", exit.direction, "exit"], src) move_internal(person, src, dst) else: narrate(["You can't force", person, "to move!"], actor)
def irritate_students(self): students = [ person for person in self.people_here() if is_student(person) ] if flip_coin(self.irritability): if students: say(self, [ "What are you doing still up?", "Everyone back to their rooms!" ]) for student in students: narrate([student, "goes home to", student.origin], student) move(student, student.origin, student) else: say(self, ["Grrr... When I catch those students..."]) else: if students: say(self, ["I'll let you off this once..."])
def move_steal(mobile_thing, from_bag, to_bag, actor): former_holder = from_bag.holder new_holder = to_bag.holder if from_bag is to_bag: tell([new_holder, "is already carrying", mobile_thing], actor) elif actor is former_holder: narrate([actor, "gives", mobile_thing, "to", new_holder], actor) elif actor is new_holder: narrate([actor, "takes", mobile_thing, "from", former_holder], actor) else: narrate([actor, "takes", mobile_thing, "from", former_holder, "and gives it to", new_holder], actor) if actor is not former_holder: say(former_holder, ["Yaaaah! I am upset!"]) if actor is not new_holder: say(new_holder, ["Whoa! Where'd you get this?"]) if from_bag is not to_bag: move_internal(mobile_thing, from_bag, to_bag)
def enter_place(self): super().enter_place() narrate([self, "enters", self.location], self) people = self.people_here() if people: say(self, ["Hi", *people])