def on_use(self, user, target): target_items = [item_dict['kind'] for item_dict in inventory.get_inventory(target)] if target_items: to_steal = random.choice(target_items) inventory.consume_item(target, to_steal) inventory.add_to_inventory(user, to_steal) to_steal_title = g.f2pitems[to_steal]['title'] item_title = self.item['title'] subject = "you've been robbed!" msg = ('%s used %s to steal your %s' % (user.name, item_title, to_steal_title)) send_system_message(target, subject, msg) subject = "you stole an item" msg = ("you used %s to steal %s from %s" % (item_title, to_steal_title, target.name)) send_system_message(user, subject, msg) self.apply_damage_and_log(user, target, [target])
def on_use(self, user, target): target_items = [ item_dict['kind'] for item_dict in inventory.get_inventory(target) ] if target_items: to_steal = random.choice(target_items) inventory.consume_item(target, to_steal) inventory.add_to_inventory(user, to_steal) to_steal_title = g.f2pitems[to_steal]['title'] item_title = self.item['title'] subject = "you've been robbed!" msg = ('%s used %s to steal your %s' % (user.name, item_title, to_steal_title)) send_system_message(target, subject, msg) subject = "you stole an item" msg = ("you used %s to steal %s from %s" % (item_title, to_steal_title, target.name)) send_system_message(user, subject, msg) self.apply_damage_and_log(user, target, [target])
def on_request(): is_html = response.content_type == "text/html" if is_html and check_for_banana() and random.random() < 0.04: request.environ["usable_error_content"] = Downtime().render() abort(503) scoreboard = scores.get_game_status() c.js_preload.set("#game_status", scoreboard) c.visible_effects = {} c.state_changes = { "status": scoreboard, "inventory": collections.defaultdict(list), "effects": collections.defaultdict(lambda: collections.defaultdict(list)), "myeffects": collections.defaultdict(list), } check_for_drops() if c.user_is_loggedin: find_effects([c.user._fullname]) c.js_preload.set("#myeffects", effects.get_my_effects(c.user)) c.js_preload.set("#inventory", inventory.get_inventory(c.user))
def on_request(): is_html = response.content_type == 'text/html' if is_html and check_for_banana() and random.random() < 0.04: request.environ["usable_error_content"] = Downtime().render() abort(503) scoreboard = scores.get_game_status() c.js_preload.set("#game_status", scoreboard) c.visible_effects = {} c.state_changes = { "status": scoreboard, "inventory": collections.defaultdict(list), "effects": collections.defaultdict(lambda: collections.defaultdict(list)), "myeffects": collections.defaultdict(list), } check_for_drops() if c.user_is_loggedin: find_effects([c.user._fullname]) c.js_preload.set("#myeffects", effects.get_my_effects(c.user)) c.js_preload.set("#inventory", inventory.get_inventory(c.user))