Exemplo n.º 1
0
def start(message):
    try:
        resources = int(message.text.split()[1])
        chat = chat_main.get_chat(message.chat.id)
        chat.add_resources(resources)
    except:
        return False
Exemplo n.º 2
0
 def __init__(self, chat, user_id, call=None, target_chat=None):
     ChatAction.__init__(self, chat, user_id, call=call)
     if target_chat is None:
         self.target_chat = get_chat(call.data.split('_')[-1])
     else:
         self.target_chat = target_chat
     from chat_wars.chat_war import current_war
     self.current_war = current_war
Exemplo n.º 3
0
 def handle(call):
     call_data = call.data.split('_')
     user_id = call.from_user.id
     chat = get_chat(call_data[1])
     action = call_data[2]
     if not chat.is_admin(user_id):
         answer_callback_query(call, 'Вы не админ в этом чате!')
         return False
     chat_action_dict[action](chat, user_id, call).func()
Exemplo n.º 4
0
    def handle(call):
        call_data = call.data.split('_')
        action = call_data[2]
        try:
            lobby = dynamic_dicts.lobby_list[call_data[1]]
        except:
            return False

        if action == 'startlobby':
            dynamic_dicts.lobby_list[call_data[1]].start()

        elif action == 'equipment':
            user_id = call.from_user.id
            unit_dict = lobby[user_id]['unit_dict']
            user = get_user(call.from_user.id)
            chat = get_chat(lobby.chat_id)
            item_type = call_data[3]
            item_name = call_data[-1]
            item = standart_actions.object_dict[item_name]() if item_name not in ['reset', 'ready'] else None
            if item_name == 'reset':
                if item_type == 'armor':
                    for armor in unit_dict['armor']:
                        chat.delete_used_item(armor['name'])
                    unit_dict['armor'] = []
                elif item_type == 'item':
                    for item_unit in unit_dict['inventory'].values():
                        chat.delete_used_item(item_unit[0]['name'], value=item_unit[1])
                    unit_dict['inventory'] = {}
                user.send_equipment_choice(call_data[1], chat.chat_id, item_type, message_id=call.message.message_id)
            elif item_name == 'ready':
                lobby[user_id]['equipment_choice'].pop()
                lobby.run_next_step(user_id, message_id=call.message.message_id)

            elif item_name not in chat.get_free_armory():
                bot_methods.answer_callback_query(call, 'Этого предмета уже нет на складе')
                user.send_equipment_choice(call_data[1], chat.chat_id, item_type, message_id=call.message.message_id)
            elif not item.try_placement(unit_dict):
                bot_methods.answer_callback_query(call, 'Вы не можете это экипировать.')

            elif item_type == 'weapon':
                chat.use_item(item_name)
                unit_dict['weapon'] = item.to_dict()
                lobby[user_id]['equipment_choice'].pop()
                lobby.run_next_step(user_id, message_id=call.message.message_id)
            elif item_type == 'armor':
                chat.use_item(item_name)
                unit_dict['armor'].append(item.to_dict())
                user.send_equipment_choice(call_data[1], chat.chat_id, item_type, message_id=call.message.message_id)
            elif item_type == 'item':
                chat.use_item(item_name)
                test = list(k for k, v in unit_dict['inventory'].items() if v[0]['name'] == item['name'])
                if test:
                    unit_dict['inventory'][test[0]][1] += 1
                else:
                    unit_dict['inventory'][engine.rand_id()] = [item.to_dict(), 1]
                user.send_equipment_choice(call_data[1], chat.chat_id, item_type, message_id=call.message.message_id)
Exemplo n.º 5
0
 def __init__(self, chat, user_id, call=None):
     ChatAction.__init__(self, chat, user_id, call=call)
     self.target_chat = get_chat(call.data.split('_')[-2])
     self.current_war_id = call.data.split('_')[-1]
     from chat_wars.chat_war import current_war
     self.current_war = current_war
Exemplo n.º 6
0
 def __init__(self, chat, user_id, call=None, target_chat=None):
     ChatMenuPage.__init__(self, chat, user_id, call=call)
     if target_chat is None:
         self.target_chat = get_chat(call.data.split('_')[-1])
     else:
         self.target_chat = target_chat
Exemplo n.º 7
0
def start(message):
    chat = chat_main.get_chat(message.chat.id)
    chat.ask_craft(message.from_user.id)
Exemplo n.º 8
0
def start(message):
    chat = chat_main.get_chat(message.chat.id)
    chat.print_items()
Exemplo n.º 9
0
def start(message):
    chat = chat_main.get_chat(message.chat.id)
    chat.print_receipts()
Exemplo n.º 10
0
def start(message):
    chat = chat_main.get_chat(message.chat.id)
    chat.add_resources(500)
Exemplo n.º 11
0
def start(message):
    chat = chat_main.get_chat(message.chat.id)
    chat.print_resources()
Exemplo n.º 12
0
def start(message):
    chat = chat_main.get_chat(message.chat.id)
    chat_menu.chat_action_dict['main'](chat, message.from_user.id,
                                       call=None).func()
Exemplo n.º 13
0
def start(message):
    chat = chat_main.get_chat(message.chat.id)
    chat.show_chat_stats('rus')