def on_take(self, handler: Handler, item: Item, new_holder: Holder): if not isinstance(new_holder, Player): # If something else took the item we don't care. However, it's possible that this causes bugs so be careful return player = new_holder if isinstance(item, Wallet): if player[EventsObject].been_introduced_to_furry: handler.get_livings(OtherPerson, 1)[0].tell(player, "Hey that's not yours!") player.send_message("You set the wallet back on the ground.") player.items.remove(item) item.change_holder(player, player.location) return friend = player[PlayerFriend] player[EventsObject].been_introduced_to_furry = True # has now been introduced player.send_message(Message("You throw all of {}'s cash at the furry monster.", named_variables=[friend])) player.send_wait(0.2) player.send_message("The furry monster fainted. You ga-") friend.tell(player, "THANK YOU, THANK YOU!!! You just saved my life from the furry monster!") friend.tell(player, "You can keep my wallet. It doesn't have much left anyway.") friend.tell(player, "Oh, and I met this really awesome person. If you go west past the double doors," " you'll find her.") player.send_wait(0.5) friend.tell(player, "She's pretty shy so you can use the yell command to yell out to her.") friend.tell(player, "Well, 'shy' isn't really the word. Good luck.")
def on_item_use(self, handler: Handler, player: Player, item: Item): if isinstance(item, Sword): can_use = item.can_use(player) if not can_use[0]: player.send_message(can_use[1]) return result = item.use_item(handler, player, does_custom_action=True) if result[0]: self.do_player_clear(player) else: player.send_message(result[1]) else: super().on_item_use(handler, player, item)
def on_item_use(self, handler: Handler, player: Player, item: Item) -> None: """ Should be called by the UseCommandHandler. If overridden, it's recommended that you call the super method (this method) Note that this method should automatically check can_use, however, you should check item.can_reference\ before you call this method :param handler: The handler object :param player: The player object :param item: The weapon that is being 'used' :return: None because the this Location should choose how it wants to handle the using of this weapon """ can_use = item.can_use(player) if not can_use[0]: player.send_message(can_use[1]) return result = item.use_item(handler, player, does_custom_action=False) if not result[0]: player.send_message( result[1] ) # send the player a message if they failed in some way
def can_sense(self, item: Item, player: Player): return item.can_taste(player)
def can_sense(self, item: Item, player: Player): return item.can_smell(player)
def can_sense(self, item: Item, player: Player) -> CanDo: return item.can_listen(player)