def add_item(cid, weapon_name): return datahandler.add_item(cid, weapon_name)
def add_item(cid, weapon_name): return datahandler.add_item(cid, weapon_name)
def action(call): if call.message: print("Получено.") if call.data == '1': bot.send_message(call.from_user.id, call.message.text) game = utils.get_game_from_player(call.from_user.id) if game is not None: print("Игра найдена.") found = True actor = None try: actor = game.player_dict[call.from_user.id] except: print('xatolik') found = False if game.gamestate == game.gamestates[0]: print('Guruh jamlanishi.') for p in game.pending_players: if call.from_user.id == p.chat_id: print('O`yinchi topildi') if call.data == 'team1': print('Guruh-1') game.pending_team1.append(p) bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Siz guruhga qo`shildingiz " + game.pending_team1[0].name) bot.send_message( game.cid, p.name + ' quyidagi tomonda jang qiladi: ' + game.pending_team1[0].name) if call.data == 'team2': print('Guruh-2') game.pending_team2.append(p) bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Siz guruhga qo`shildingiz " + game.pending_team2[0].name) bot.send_message( game.cid, p.name + ' quyidagi tomonda jang qiladi: ' + game.pending_team2[0].name) elif game.gamestate == 'weapon' and found: if call.data[0] == 'a' and call.data[0:1] != 'at': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Qurollar tanlandi: " + (call.data[1:])) for w in Weapon_list.fullweaponlist: if w.name == call.data[1:]: actor.weapon = w break game.weaponcounter -= 1 print(actor.name + ' qurol tanladi.') elif game.gamestate == 'ability' and found: if call.data[0] == 'i' and len(call.data) < 4: bot.send_message( call.from_user.id, special_abilities.abilities[int(call.data[1:])].info) if call.data[:8] == 'unique_i': bot.send_message( call.from_user.id, special_abilities.unique_abilities[int( call.data[8:])].info) elif call.data[0] == 'a' and len(call.data) < 4: bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Qobiliyatlar tanlandi: " + special_abilities.abilities[int(call.data[1:])].name) actor.abilities.append(special_abilities.abilities[int( call.data[1:])]) if actor.maxabilities > \ len(actor.abilities): utils.get_ability(actor) else: try: game.abilitycounter -= 1 print(actor.name + ' qobiliyat tanladi.') except: pass elif call.data[:8] == 'unique_a': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Qobiliyat tanlandi: " + special_abilities.unique_abilities[int( call.data[8:])].name) actor.abilities.append(special_abilities.unique_abilities[int( call.data[8:])]) if actor.maxabilities > \ len(actor.abilities): utils.get_ability(actor) else: try: game.abilitycounter -= 1 print(actor.name + ' qobiliyatlarni tanladi.') except: pass elif game.gamestate == game.gamestates[3] and found: if actor in game.fight.playerpool: if call.data[0:4] == 'item': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Yurish " + str(actor.fight.round) + ': ' + Item_list.items[call.data[0:7]].name) if call.data[0:4] == 'vint': if call.data[0:8] == 'vintinfo': bot.send_message( call.from_user.id, special_abilities.abilities[int( call.data[8:])].info) else: bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Vaqtinchalik qobiliyat tanlandi: " + special_abilities.abilities[int( call.data[4:])].name) x = len(actor.abilities) actor.abilities.append(special_abilities.abilities[int( call.data[4:])]) while x == len(actor.abilities): pass actor.abilities[-1].aquare(actor.abilities[-1], actor) Fighting.send_action(actor, actor.fight) elif call.data[0:4] == 'move': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Yurish " + str(actor.fight.round) + ": Yaqinlashish.") actor.turn = 'move' actor.fight.playerpool.remove(actor) elif call.data[0:9] == 'inventory': bot.delete_message(chat_id=call.message.chat.id, message_id=call.message.message_id) utils.send_inventory(actor) elif call.data[0:6] == 'skills': bot.delete_message(chat_id=call.message.chat.id, message_id=call.message.message_id) utils.send_skills(actor) elif call.data[0:6] == 'cancel': bot.delete_message(chat_id=call.message.chat.id, message_id=call.message.message_id) Fighting.send_action(actor, actor.fight) elif call.data[0:3] == 'aim': print(actor.name + ' nishonga oldi.') bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Maxsus harakatlar.") actor.weapon.special(actor, call) actor.turn = 'aim' actor.fight.playerpool.remove(actor) elif call.data == 'take' + str(actor.fight.round): print(actor.name + ' qurolni oldi.') bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Yurish " + str(actor.fight.round) + ": Qurolni olish.") actor.turn = 'take' + str(actor.fight.round) actor.fight.playerpool.remove(actor) elif call.data[0:13] == 'weaponspecial': print(actor.name + ' nishonga oldi.') bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Maxsus hujum.") actor.weapon.special(actor, call.data[13:]) actor.turn = 'weaponspecial' actor.fight.playerpool.remove(actor) elif call.data[0:4] == 'draw': print(actor.name + ' nishonga oldi.') if actor.bonusaccuracy == 1: bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text= 'Siz kamon ipini cho`zayabsiz. Kamon kuchi ortdi!' ' Dushmanni karaxt qilib qo`yish imkoni paydo bo`ldi!' ) else: bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text= "Siz kamon ipini cho`zayabsiz. Kamon kuchi ortdi!") actor.weapon.special(actor, call) actor.turn = 'draw' actor.fight.playerpool.remove(actor) elif call.data[0:4] == 'info': if call.data == 'info': bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Ma`lumot jo`natildi.") utils.player_info(actor) else: if call.data[4:] == 'cancel': bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Bekor qilindi") else: bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Ma`lumot jo`natildi.") utils.player_info(utils.actor_from_id( call.data[4:], actor.game), cid=actor.chat_id) actor.itemlist.remove(Item_list.mental) actor.mentalrefresh = actor.fight.round + 2 Fighting.send_action(actor, actor.fight) elif call.data[0:2] == 'op': if call.data[2:] == 'cancel': bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Bekor qilindi") Fighting.send_action(actor, actor.fight) else: print(actor.name + ' raqibni tanlash.') actor.target = utils.actor_from_id(call.data[2:], game) bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Raqib tanlandi: " + actor.target.name) try: actor.fight.playerpool.remove(actor) except: print('O`yinchini nishonda chiqarib bo`lmadi.') pass elif call.data[0:5] == 'itemh': Item_list.items[call.data[0:7]].useact(actor) Fighting.send_action(actor, actor.fight) elif call.data[0:7] == 'release': actor.bonusaccuracy = 0 actor.Armed = False bot.delete_message(actor.chat_id, actor.choicemessage) bot.send_message(actor.chat_id, 'Siz ipni cho`zishni to`xtatdingiz.') Fighting.send_action(actor, actor.fight) elif call.data[0:5] == 'items': Item_list.items[call.data[0:7]].useact(actor) elif call.data[0:5] == 'itemt' or call.data[0:6] == 'itemat': actor.turn = call.data print( str(actor.turn) + ' ' + str(actor.fight.round) + ' ' + str(actor.name)) Item_list.items[call.data[0:7]].useact(actor) elif call.data[0:6] == 'spitem': if call.data[6:] == 'cancel': bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Bekor qilindi") Fighting.send_action(actor, actor.fight) else: actor.itemtarget = utils.actor_from_id( call.data[6:], actor.game) bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Nishon - " + actor.itemtarget.name) actor.fight.playerpool.remove(actor) elif call.data[0:5] == 'mitem': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Qabul qilindi.") Item_list.items[call.data[0:7]].useact(actor) elif call.data[0:6] == 'attack': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Yurish " + str(actor.fight.round) + ": Hujum.") actor.weapon.get_action(actor, call) else: actor.turn = call.data try: actor.fight.playerpool.remove(actor) except: print( 'O`yinchini nishonda chiqarib bo`lmadi(oddiy yurish).' ) pass print( str(actor.turn) + ' ' + str(actor.fight.round) + ' ' + str(actor.name)) if call.data[:4] == 'skip': bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Yurish " + str(actor.fight.round) + ": Yurish o`tkazib yuborish.") elif call.data == 'reload' + str(actor.fight.round): if actor.weapon.Melee: bot.edit_message_text( chat_id=actor.chat_id, message_id=actor.choicemessage.message_id, text="Yurish " + str(actor.fight.round) + ': ' + 'Dam olish') else: bot.edit_message_text( chat_id=actor.chat_id, message_id=actor.choicemessage.message_id, text="Yurish " + str(actor.fight.round) + ': ' + 'Qayta o`qlash') elif call.data == 'evade' + str(actor.fight.round): bot.edit_message_text( chat_id=actor.chat_id, message_id=actor.choicemessage.message_id, text="Yurish " + str(actor.fight.round) + ': ' + 'Chetlashmoq') else: if call.data == 'change_weapon': data = bot_handlers.weapon_menu(call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data == 'change_items': data = bot_handlers.items_menu(call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data == 'change_skills': data = bot_handlers.skills_menu(call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data == 'change_string': bot_handlers.change_string(call.from_user.id) bot.delete_message(chat_id=call.message.chat.id, message_id=call.message.message_id) data = bot_handlers.player_menu(call.from_user.first_name, call.from_user.id) bot.send_message(call.from_user.id, data[0], reply_markup=data[1]) elif call.data[:10] == 'new_weapon': weapon = call.data[10:] datahandler.change_weapon(call.message.chat.id, weapon) data = bot_handlers.player_menu(call.from_user.first_name, call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data[:8] == 'add_item': item_id = call.data[8:] changed = datahandler.add_item(call.message.chat.id, item_id) data = bot_handlers.items_menu(call.from_user.id) if changed: bot.answer_callback_query(callback_query_id=call.id, show_alert=False, text="Invertor o`zgardi!") bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) else: bot.answer_callback_query( callback_query_id=call.id, show_alert=True, text="Oldin hozirgi narsalarni o`zgartiring.") elif call.data[:11] == 'delete_item': print('1') item_id = call.data[11:] true = datahandler.delete_item(call.message.chat.id, item_id) data = bot_handlers.items_menu(call.from_user.id) if true: bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data[:9] == 'add_skill': skill_name = call.data[9:] changed = datahandler.add_skill(call.message.chat.id, skill_name) data = bot_handlers.skills_menu(call.from_user.id) if changed: bot.answer_callback_query(callback_query_id=call.id, show_alert=False, text="Qobiliyatlar o`zgartirildi!") bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) else: bot.answer_callback_query( callback_query_id=call.id, show_alert=True, text="Oldin hozirgi qobiliyatlarni o`zgartiring.") elif call.data[:12] == 'delete_skill': print('1') skill_name = call.data[12:] true = datahandler.delete_skill(call.message.chat.id, skill_name) data = bot_handlers.skills_menu(call.from_user.id) if true: bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data == 'accept_player': data = bot_handlers.player_menu(call.from_user.first_name, call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1])
def action(call): if call.message: print("Получено.") if call.data == '1': bot.send_message(call.from_user.id, call.message.text) game = utils.get_game_from_player(call.from_user.id) if game is not None: print("Игра найдена.") found = True actor = None try: actor = game.player_dict[call.from_user.id] except: print('ошибка') found = False if game.gamestate == game.gamestates[0]: print('Подбор команды.') for p in game.pending_players: if call.from_user.id == p.chat_id: print('Игрок найден') if call.data == 'team1': print('Команда 1') game.pending_team1.append(p) bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Вы присоединились к команде " + game.pending_team1[0].name) bot.send_message( game.cid, p.name + ' вступает в бой на стороне ' + game.pending_team1[0].name) if call.data == 'team2': print('Команда 2') game.pending_team2.append(p) bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Вы присоединились к команде " + game.pending_team2[0].name) bot.send_message( game.cid, p.name + ' вступает в бой на стороне ' + game.pending_team2[0].name) elif game.gamestate == 'weapon' and found: if call.data[0] == 'a' and call.data[0:1] != 'at': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Оружие выбрано: " + (call.data[1:])) for w in Weapon_list.fullweaponlist: if w.name == call.data[1:]: actor.weapon = w break game.weaponcounter -= 1 print(actor.name + ' выбрал оружие.') elif game.gamestate == 'ability' and found: if call.data[0] == 'i' and len(call.data) < 4: bot.send_message( call.from_user.id, special_abilities.abilities[int(call.data[1:])].info) elif call.data[:7] == 'sec-wep': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Способность выбрана: Оружейник") for w in Weapon_list.fullweaponlist: if w.name == call.data[7:]: actor.sec_weapon = w break if actor.maxabilities > \ len(actor.abilities): utils.get_ability(actor) else: try: game.abilitycounter -= 1 print(actor.name + ' выбрал способности.') except: pass elif call.data[:8] == 'unique_i': bot.send_message( call.from_user.id, special_abilities.unique_abilities[int( call.data[8:])].info) elif call.data[0] == 'a' and len(call.data) < 4: choice_num = int(call.data[1:]) print(int(call.data[1:])) print( special_abilities.abilities.index( (special_abilities.WeaponMaster))) if choice_num != special_abilities.abilities.index( (special_abilities.WeaponMaster)): bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Способность выбрана: " + special_abilities.abilities[int(call.data[1:])].name) actor.abilities.append( special_abilities.abilities[choice_num]) if actor.maxabilities > \ len(actor.abilities): utils.get_ability(actor) else: try: game.abilitycounter -= 1 print(actor.name + ' выбрал способности.') except: pass else: actor.abilities.append( special_abilities.abilities[choice_num]) special_abilities.WeaponMaster.set(call, actor) elif call.data[:8] == 'unique_a': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Способность выбрана: " + special_abilities.unique_abilities[int( call.data[8:])].name) actor.abilities.append(special_abilities.unique_abilities[int( call.data[8:])]) if actor.maxabilities > \ len(actor.abilities): utils.get_ability(actor) else: try: game.abilitycounter -= 1 print(actor.name + ' выбрал способности.') except: pass elif game.gamestate == game.gamestates[3] and found: if actor in game.fight.playerpool: if call.data[0:4] == 'item': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Ход " + str(actor.fight.round) + ': ' + Item_list.items[call.data[0:7]].name) if call.data[0:4] == 'vint': if call.data[0:8] == 'vintinfo': bot.send_message( call.from_user.id, special_abilities.abilities[int( call.data[8:])].info) else: bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Временная способность выбрана: " + special_abilities.abilities[int( call.data[4:])].name) x = len(actor.abilities) actor.abilities.append(special_abilities.abilities[int( call.data[4:])]) while x == len(actor.abilities): pass actor.abilities[-1].aquare(actor.abilities[-1], actor) Fighting.send_action(actor, actor.fight) elif call.data[0:4] == 'move': bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Ход " + str(actor.fight.round) + ": Подойти.") actor.turn = 'move' actor.fight.playerpool.remove(actor) elif call.data[0:9] == 'inventory': bot.delete_message(chat_id=call.message.chat.id, message_id=call.message.message_id) utils.send_inventory(actor) elif call.data[0:6] == 'skills': bot.delete_message(chat_id=call.message.chat.id, message_id=call.message.message_id) utils.send_skills(actor) elif call.data[0:6] == 'cancel': bot.delete_message(chat_id=call.message.chat.id, message_id=call.message.message_id) Fighting.send_action(actor, actor.fight) elif call.data[0:3] == 'aim': print(actor.name + ' целится.') bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Особое действие.") actor.weapon.special(actor, call) actor.turn = 'aim' actor.fight.playerpool.remove(actor) elif call.data == 'take' + str(actor.fight.round): print(actor.name + ' подбирает оружие.') bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Ход " + str(actor.fight.round) + ": Подобрать оружие.") actor.turn = 'take' + str(actor.fight.round) actor.fight.playerpool.remove(actor) elif call.data[0:13] == 'weaponspecial': print(actor.name + ' целится.') bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Особая атака.") actor.weapon.special(actor, call.data[13:]) actor.turn = 'weaponspecial' actor.fight.playerpool.remove(actor) elif call.data[0:4] == 'draw': print(actor.name + ' целится.') if actor.bonusaccuracy == 1: bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text= 'Вы натягиваете тетиву Лука. Характеристики лука увеличены!' ' Появился шанс оглушить противника!') else: bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text= "Вы натягиваете тетиву Лука. Характеристики лука увеличены!" ) actor.weapon.special(actor, call) actor.turn = 'draw' actor.fight.playerpool.remove(actor) elif call.data[0:4] == 'info': if call.data == 'info': bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Информация выслана.") utils.player_info(actor) else: if call.data[4:] == 'cancel': bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Отменено") else: bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Информация выслана.") utils.player_info(utils.actor_from_id( call.data[4:], actor.game), cid=actor.chat_id) actor.itemlist.remove(Item_list.mental) actor.mentalrefresh = actor.fight.round + 2 Fighting.send_action(actor, actor.fight) elif call.data[0:2] == 'op': if call.data[2:] == 'cancel': bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Отменено") Fighting.send_action(actor, actor.fight) else: print(actor.name + ' выбор противника.') actor.target = utils.actor_from_id(call.data[2:], game) bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Противник принят: " + actor.target.name) try: actor.fight.playerpool.remove(actor) except: print('Не удалось удалить игрока из пула(прицел).') pass elif call.data[0:5] == 'itemh' or call.data[0:6] == 'itemah': Item_list.items[call.data[0:7]].useact(actor) Fighting.send_action(actor, actor.fight) elif call.data[0:7] == 'release': actor.bonusaccuracy = 0 actor.Armed = False bot.delete_message(actor.chat_id, actor.choicemessage) bot.send_message(actor.chat_id, 'Вы перестали натягивать тетиву.') Fighting.send_action(actor, actor.fight) elif call.data[0:5] == 'items': Item_list.items[call.data[0:7]].useact(actor) elif call.data[0:5] == 'itemt' or call.data[0:6] == 'itemat': actor.turn = call.data print( str(actor.turn) + ' ' + str(actor.fight.round) + ' ' + str(actor.name)) Item_list.items[call.data[0:7]].useact(actor) elif call.data[0:6] == 'spitem': if call.data[6:] == 'cancel': bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Отменено") Fighting.send_action(actor, actor.fight) else: actor.itemtarget = utils.actor_from_id( call.data[6:], actor.game) bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Цель - " + actor.itemtarget.name) actor.fight.playerpool.remove(actor) elif call.data[0:5] == 'mitem': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Принято.") Item_list.items[call.data[0:7]].useact(actor) elif call.data[0:6] == 'attack': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Ход " + str(actor.fight.round) + ": Атака.") actor.weapon.get_action(actor, call) else: actor.turn = call.data try: actor.fight.playerpool.remove(actor) except: print( 'Не удалось удалить игрока из пула(обычный ход).') pass print( str(actor.turn) + ' ' + str(actor.fight.round) + ' ' + str(actor.name)) if call.data[:4] == 'skip': bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="Ход " + str(actor.fight.round) + ": Пропуск хода.") elif call.data == 'reload' + str(actor.fight.round): if actor.weapon.Melee: bot.edit_message_text( chat_id=actor.chat_id, message_id=actor.choicemessage.message_id, text="Ход " + str(actor.fight.round) + ': ' + 'Отдых') else: bot.edit_message_text( chat_id=actor.chat_id, message_id=actor.choicemessage.message_id, text="Ход " + str(actor.fight.round) + ': ' + 'Перезарядка') elif call.data == 'evade' + str(actor.fight.round): bot.edit_message_text( chat_id=actor.chat_id, message_id=actor.choicemessage.message_id, text="Ход " + str(actor.fight.round) + ': ' + 'Уворот') else: if call.data == 'change_weapon': data = bot_handlers.weapon_menu(call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data == 'change_items': data = bot_handlers.items_menu(call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data == 'change_skills': data = bot_handlers.skills_menu(call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data == 'change_string': bot_handlers.change_string(call.from_user.id) bot.delete_message(chat_id=call.message.chat.id, message_id=call.message.message_id) data = bot_handlers.player_menu(call.from_user.first_name, call.from_user.id) bot.send_message(call.from_user.id, data[0], reply_markup=data[1]) elif call.data[:10] == 'new_weapon': weapon = call.data[10:] datahandler.change_weapon(call.message.chat.id, weapon) data = bot_handlers.player_menu(call.from_user.first_name, call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data[:8] == 'add_item': item_id = call.data[8:] changed = datahandler.add_item(call.message.chat.id, item_id) data = bot_handlers.items_menu(call.from_user.id) if changed: bot.answer_callback_query(callback_query_id=call.id, show_alert=False, text="Инвентарь изменен!") bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) else: bot.answer_callback_query(callback_query_id=call.id, show_alert=True, text="Сначала уберите текущие вещи.") elif call.data[:11] == 'delete_item': print('1') item_id = call.data[11:] true = datahandler.delete_item(call.message.chat.id, item_id) data = bot_handlers.items_menu(call.from_user.id) if true: bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data[:9] == 'add_skill': skill_name = call.data[9:] changed = datahandler.add_skill(call.message.chat.id, skill_name) data = bot_handlers.skills_menu(call.from_user.id) if changed: bot.answer_callback_query(callback_query_id=call.id, show_alert=False, text="Навыки изменены!") bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) else: bot.answer_callback_query( callback_query_id=call.id, show_alert=True, text="Сначала уберите текущие навыки.") elif call.data[:12] == 'delete_skill': print('1') skill_name = call.data[12:] true = datahandler.delete_skill(call.message.chat.id, skill_name) data = bot_handlers.skills_menu(call.from_user.id) if true: bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data == 'accept_player': data = bot_handlers.player_menu(call.from_user.first_name, call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1])
def action(call): if call.message: print("Получено.") if call.data == '1': bot.send_message(call.from_user.id, call.message.text) game = utils.get_game_from_player(call.from_user.id) if game is not None: print("Игра найдена.") found = True actor = None try: actor = game.player_dict[call.from_user.id] except: print('ошибка') found = False if game.gamestate == game.gamestates[0] : print('Подбор команды.') for p in game.pending_players: if call.from_user.id == p.chat_id: print('Игрок найден') if call.data == 'team1': print('Команда 1') game.pending_team1.append(p) bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Вы присоединились к команде " + game.pending_team1[0].name) bot.send_message(game.cid, p.name + ' вступает в бой на стороне ' + game.pending_team1[0].name) if call.data == 'team2': print('Команда 2') game.pending_team2.append(p) bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Вы присоединились к команде " + game.pending_team2[0].name) bot.send_message(game.cid, p.name + ' вступает в бой на стороне ' + game.pending_team2[0].name) elif game.gamestate == 'weapon' and found: if call.data[0] == 'a' and call.data[0:1] != 'at': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Оружие выбрано: " + (call.data[1:])) for w in Weapon_list.fullweaponlist: if w.name == call.data[1:]: actor.weapon = w break game.weaponcounter -= 1 print(actor.name + ' выбрал оружие.') elif game.gamestate == 'ability' and found: if call.data[0] == 'i'and len(call.data) < 4: bot.send_message(call.from_user.id,special_abilities.abilities[int(call.data[1:])].info) if call.data[:8] == 'unique_i': bot.send_message(call.from_user.id,special_abilities.unique_abilities[int(call.data[8:])].info) elif call.data[0] == 'a' and len(call.data) < 4: bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Способность выбрана: " + special_abilities.abilities[int(call.data[1:])].name) actor.abilities.append(special_abilities.abilities[int(call.data[1:])]) if actor.maxabilities > \ len(actor.abilities): utils.get_ability(actor) else: try: game.abilitycounter -= 1 print (actor.name + ' выбрал способности.') except: pass elif call.data[:8] == 'unique_a': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Способность выбрана: " + special_abilities.unique_abilities[int(call.data[8:])].name) actor.abilities.append(special_abilities.unique_abilities[int(call.data[8:])]) if actor.maxabilities > \ len(actor.abilities): utils.get_ability(actor) else: try: game.abilitycounter -= 1 print (actor.name + ' выбрал способности.') except: pass elif game.gamestate == game.gamestates[3] and found: if actor in game.fight.playerpool: if call.data[0:4] == 'item': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Ход " + str(actor.fight.round) + ': ' + Item_list.items[ call.data[0:7]].name) if call.data[0:4] == 'vint': if call.data[0:8] == 'vintinfo': bot.send_message(call.from_user.id, special_abilities.abilities[int(call.data[8:])].info) else: bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Временная способность выбрана: " + special_abilities.abilities[ int(call.data[4:])].name) x = len(actor.abilities) actor.abilities.append(special_abilities.abilities[int(call.data[4:])]) while x == len(actor.abilities): pass actor.abilities[-1].aquare(actor.abilities[-1], actor) Fighting.send_action(actor, actor.fight) elif call.data[0:4] == 'move': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Ход " + str(actor.fight.round) + ": Подойти.") actor.turn = 'move' actor.fight.playerpool.remove(actor) elif call.data[0:9] == 'inventory': bot.delete_message(chat_id=call.message.chat.id, message_id=call.message.message_id) utils.send_inventory(actor) elif call.data[0:6] == 'skills': bot.delete_message(chat_id=call.message.chat.id, message_id=call.message.message_id) utils.send_skills(actor) elif call.data[0:6] == 'cancel': bot.delete_message(chat_id=call.message.chat.id, message_id=call.message.message_id) Fighting.send_action(actor, actor.fight) elif call.data[0:3] == 'aim': print(actor.name + ' целится.') bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Особое действие.") actor.weapon.special(actor, call) actor.turn = 'aim' actor.fight.playerpool.remove(actor) elif call.data == 'take' + str(actor.fight.round): print(actor.name + ' подбирает оружие.') bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Ход " + str(actor.fight.round) + ": Подобрать оружие.") actor.turn = 'take' + str(actor.fight.round) actor.fight.playerpool.remove(actor) elif call.data[0:13] == 'weaponspecial': print(actor.name + ' целится.') bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Особая атака.") actor.weapon.special(actor, call.data[13:]) actor.turn = 'weaponspecial' actor.fight.playerpool.remove(actor) elif call.data[0:4] == 'draw': print(actor.name + ' целится.') if actor.bonusaccuracy == 1: bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text='Вы натягиваете тетиву Лука. Характеристики лука увеличены!' ' Появился шанс оглушить противника!') else: bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Вы натягиваете тетиву Лука. Характеристики лука увеличены!") actor.weapon.special(actor, call) actor.turn = 'draw' actor.fight.playerpool.remove(actor) elif call.data[0:4] == 'info': if call.data == 'info': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Информация выслана.") utils.player_info(actor) else: if call.data[4:] == 'cancel': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Отменено") else: bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Информация выслана.") utils.player_info(utils.actor_from_id(call.data[4:], actor.game),cid=actor.chat_id) actor.itemlist.remove(Item_list.mental) actor.mentalrefresh = actor.fight.round + 2 Fighting.send_action(actor, actor.fight) elif call.data[0:2] == 'op': if call.data[2:] == 'cancel': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Отменено") Fighting.send_action(actor, actor.fight) else: print(actor.name + ' выбор противника.') actor.target = utils.actor_from_id(call.data[2:], game) bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Противник принят: " + actor.target.name) try: actor.fight.playerpool.remove(actor) except: print('Не удалось удалить игрока из пула(прицел).') pass elif call.data[0:5] == 'itemh': Item_list.items[call.data[0:7]].useact(actor) Fighting.send_action(actor, actor.fight) elif call.data[0:7] == 'release': actor.bonusaccuracy = 0 actor.Armed = False bot.delete_message(actor.chat_id, actor.choicemessage) bot.send_message(actor.chat_id, 'Вы перестали натягивать тетиву.') Fighting.send_action(actor, actor.fight) elif call.data[0:5] == 'items':Item_list.items[call.data[0:7]].useact(actor) elif call.data[0:5] == 'itemt' or call.data[0:6] == 'itemat': actor.turn = call.data print(str(actor.turn) + ' ' + str(actor.fight.round) + ' ' + str(actor.name)) Item_list.items[call.data[0:7]].useact(actor) elif call.data[0:6] == 'spitem': if call.data[6:] == 'cancel': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Отменено") Fighting.send_action(actor, actor.fight) else: actor.itemtarget = utils.actor_from_id(call.data[6:], actor.game) bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Цель - " + actor.itemtarget.name) actor.fight.playerpool.remove(actor) elif call.data[0:5] == 'mitem': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Принято.") Item_list.items[call.data[0:7]].useact(actor) elif call.data[0:6] == 'attack': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Ход " + str(actor.fight.round) + ": Атака.") actor.weapon.get_action(actor, call) else: actor.turn = call.data try: actor.fight.playerpool.remove(actor) except: print('Не удалось удалить игрока из пула(обычный ход).') pass print(str(actor.turn) + ' ' + str(actor.fight.round) + ' ' + str(actor.name)) if call.data[:4] == 'skip': bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Ход " + str(actor.fight.round) + ": Пропуск хода.") elif call.data == 'reload' + str(actor.fight.round): if actor.weapon.Melee: bot.edit_message_text(chat_id=actor.chat_id, message_id=actor.choicemessage.message_id, text="Ход " + str(actor.fight.round) + ': ' + 'Отдых') else: bot.edit_message_text(chat_id=actor.chat_id, message_id=actor.choicemessage.message_id, text="Ход " + str(actor.fight.round) + ': ' + 'Перезарядка') elif call.data == 'evade' + str(actor.fight.round): bot.edit_message_text(chat_id=actor.chat_id, message_id=actor.choicemessage.message_id, text="Ход " + str(actor.fight.round) + ': ' + 'Уворот') else: if call.data == 'change_weapon': data = bot_handlers.weapon_menu(call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data == 'change_items': data = bot_handlers.items_menu(call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data == 'change_skills': data = bot_handlers.skills_menu(call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data == 'change_string': bot_handlers.change_string(call.from_user.id) bot.delete_message(chat_id=call.message.chat.id, message_id=call.message.message_id) data = bot_handlers.player_menu(call.from_user.first_name, call.from_user.id) bot.send_message(call.from_user.id, data[0], reply_markup=data[1]) elif call.data[:10] == 'new_weapon': weapon = call.data[10:] datahandler.change_weapon(call.message.chat.id, weapon) data = bot_handlers.player_menu(call.from_user.first_name, call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data[:8] == 'add_item': item_id = call.data[8:] changed = datahandler.add_item(call.message.chat.id, item_id) data = bot_handlers.items_menu(call.from_user.id) if changed: bot.answer_callback_query(callback_query_id=call.id, show_alert=False, text="Инвентарь изменен!") bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) else: bot.answer_callback_query(callback_query_id=call.id, show_alert=True, text="Сначала уберите текущие вещи.") elif call.data[:11] == 'delete_item': print('1') item_id = call.data[11:] true = datahandler.delete_item(call.message.chat.id, item_id) data = bot_handlers.items_menu(call.from_user.id) if true: bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data[:9] == 'add_skill': skill_name = call.data[9:] changed = datahandler.add_skill(call.message.chat.id, skill_name) data = bot_handlers.skills_menu(call.from_user.id) if changed: bot.answer_callback_query(callback_query_id=call.id, show_alert=False, text="Навыки изменены!") bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) else: bot.answer_callback_query(callback_query_id=call.id, show_alert=True, text="Сначала уберите текущие навыки.") elif call.data[:12] == 'delete_skill': print('1') skill_name = call.data[12:] true = datahandler.delete_skill(call.message.chat.id, skill_name) data = bot_handlers.skills_menu(call.from_user.id) if true: bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1]) elif call.data == 'accept_player': data = bot_handlers.player_menu(call.from_user.first_name, call.from_user.id) bot.edit_message_text(data[0], chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=data[1])