def print_receipts(self): receipts = self.get_receipts() message = '' for key in receipts: name = standart_actions.get_name(key, 'rus') if receipts[key] == 'inf': value = 'Много' else: value = str(receipts[key]) message += name + ' - ' + value + '\n' self.send_message(message)
def create_choice_equipment(self, lobby_id, chat_id, equipment_type): buttons = [] equipment_list = get_chat(chat_id).get_free_equipment([equipment_type]) for equipment in equipment_list: buttons.append( keyboards.Button( standart_actions.get_name(equipment[0], self.lang) + ' x ' + str(equipment[1]), '_'.join([ 'lobby', lobby_id, 'equipment', equipment_type, equipment[0] ]))) return buttons
def handle(self, call): call_data = call.data.split('_') action = call_data[2] if action == 'craft': chat = get_chat(call_data[1]) item_name = call_data[-1] item_class = standart_actions.get_class(item_name) name = standart_actions.get_name(item_name, 'rus') chat.add_resources(-item_class.price) chat.add_item(item_name) chat.delete_receipt(item_name) edit_message(call.message.chat.id, call.message.message_id, name + ' - произведено.') elif action == 'cancel': delete_message(call.message.chat.id, call.message.message_id)
def on_enter(self): if not self.visited: victims = [ member for member in self.dungeon.party.members if not member.inventory.is_empty() ] if victims: victim = random.choice(victims) item = random.choice(victim.inventory.items()) victim.inventory.remove(item) self.dungeon.party.send_message( victim.name + ' потерял ' + str(standart_actions.get_name(item[0]['name'], 'rus'))) else: pass self.dungeon.update_map(new=True) else: self.dungeon.update_map()
def show_chat_stats(self, lang): receipts = self.get_receipts() message = '' for key in receipts: name = standart_actions.get_name(key, 'rus') if receipts[key] == 'inf': value = 'Много' else: value = str(receipts[key]) message += name + ' - ' + value + '\n' used_items = engine.ChatContainer(base_dict=self.get_free_armory()) lang_tuple = LangTuple('chatmanagement', 'chat_stats', format_dict={ 'resources': str(self.resources), 'items': used_items.to_string(lang, marked=True, emoted=True) }) self.send_message(lang_tuple.translate(lang))
def get_name(self): return get_name(self.get_item_object().name, 'rus')
def collect_receipt(self, name, amount, alarm=True): if alarm: name = standart_actions.get_name(name, 'rus') self.send_message('Вы находите рецепт на {}({})'.format( name, amount)) self.collected_receipts.put(name, value=amount)