Имеется TG-бот с мини-игрой.
Нужно настроить рандомную вероятность появлений бомб из-за того, что в игре присутствует подкрутка, рандом не работает, в исходе игры на данный момент есть 2 варианта:
1 - на каждом этапе хода нет шанса проиграть и это приводит к постоянному выигрышу
2 - на первом же ходе происходит проигрыш.
if call.data == 'mines':
cursor.execute("SELECT game_status FROM apple WHERE user_id = (?)", (us_id,))
game_status = cursor.fetchone()[0]
if game_status != 1111111110:
msg = bot.send_message(us_id, text=f'✏️ Введите количество мин (от 3 до 24)', reply_markup = mines_kolv_keyboard)
bot.register_next_step_handler(msg, get_mines)
else:
bot.send_message(us_id, text = '❌ Завершите предыдущую игру прежде чем начать новую', reply_markup = menu_keyboard(us_id))
if call.data.startswith('mines_'):
try:
mine_3 = [1.1, 1.26, 1.45, 1.68, 1.96, 2.3, 2.73, 3.28, 3.98, 4.9, 6.13, 7.8, 10.14, 13.52, 18.59, 26.56, 39.84, 63.74, 111.55, 223.1, 557.75, 2230]
mine_4 = [1.15, 1.39, 1.68, 2.05, 2.53, 3.17, 4.01, 5.16, 6.74, 8.99, 12.26, 17.16, 24.79, 37.18, 58.43, 97.38, 175.29, 350.58, 818.03, 2450, 12270]
mine_5 = [1.21, 1.53, 1.96, 2.53, 3.32, 4.43, 6.01, 8.33, 11.8, 17.16, 25.74, 40.04, 65.07, 111.55, 204.51, 409.02, 920.29, 2450, 8590, 51240]
mine_6 = [1.28, 1.7, 2.3, 3.17, 4.43, 6.33, 9.25, 13.88, 21.45, 34.32, 57.2, 100.11, 185.92, 371.83, 818.03, 2050, 6140, 24540, 172000]
mine_7 = [1.35, 1.9, 2.73, 4.01, 6.01, 9.25, 14.65, 23.98, 40.76, 72.46, 135.86, 271.72, 588.74, 1410, 3890, 12950, 58280, 466000,]
mine_8 = [1.43, 2.14, 3.28, 5.16, 8.33, 13.88, 23.98, 43.16, 81.52, 163.03, 349.36, 815.17, 2120, 6360, 23310, 117000, 1000000]
mine_9 = [1.51, 2,42, 3.98, 6.74, 11.8, 21.45, 40.76, 81.52, 173.22, 395.94, 989.85, 2770, 9010, 36030, 198000, 1980000]
mine_10 = [1.62, 2.77, 4.9, 8.9, 17, 34, 72, 163, 395, 1000, 3170, 11090, 48000, 288000, 3170000]
mine_11 = [1.73, 3.2, 6.1, 12.2, 25.7, 57.2, 135, 349, 989, 3170, 11880, 55430, 360000, 4320000]
mine_12 = [1.86, 3.7, 7.8, 17.1, 40, 100, 271, 815, 2700, 11000, 55000, 388000, 5000000]
mine_13 = [2.02, 4.4, 10.14, 24.7, 65, 185, 588, 2120, 9001, 48040, 360000, 5000000]
mine_14 = [2.2, 5.29, 13.52, 37.18, 111.55, 371.83, 1410, 6360, 36030, 288000, 4000000]
mine_15 = [2.42, 6.47, 18.5, 58.43, 204, 818, 3890, 23310, 198000, 3170000]
mine_16 = [2.69, 8, 26, 97, 409, 2050, 12950, 117000, 1980000]
mine_17 = [3, 10, 39, 175, 920, 6140, 58280, 1000000]
mine_18 = [3.46, 13.8, 63, 350, 2450, 24540, 466000]
mine_19 = [4.04, 19.4, 111.5, 818, 8590, 172000]
mine_20 = [4.85, 29.1, 223.1, 2450, 51400]
mine_21 = [6, 48.5, 557, 12270]
mine_22 = [8, 97, 2230]
mine_23 = [12.1, 291]
mine_24 = [24.9]
cursor.execute("SELECT mines_map_buttons FROM apple WHERE user_id = ('%s')"%(us_id,))
myresult = cursor.fetchone()
data = json.loads(myresult[0])
if data[call.data] != '':
cursor.execute("SELECT now_stavka FROM apple WHERE user_id = ('%s')"%(us_id,))
stavka = cursor.fetchone()[0]
cursor.execute("SELECT kassa FROM settings WHERE bot = 1")
kassa = cursor.fetchone()[0]
cursor.execute("SELECT now_state FROM apple WHERE user_id = ('%s')"%(us_id,))
now_state = cursor.fetchone()[0]
cursor.execute("SELECT how_mines FROM apple WHERE user_id = ('%s')"%(us_id,))
mines_kolv = cursor.fetchone()[0]
cursor.execute("SELECT antiminus FROM settings WHERE bot = 1")
antiminus = cursor.fetchone()[0]
cursor.execute("SELECT win_money FROM apple WHERE user_id = ('%s')"%(us_id,))
last_win_money = cursor.fetchone()[0]
x = eval(f"mine_{mines_kolv}[{now_state}]")
try:
next_x = eval(f"mine_{mines_kolv}[{now_state + 1}]")
except:
next_x = 0
now_state = now_state + 1
next_money = round(stavka *next_x, 2)
win_money = round(stavka *x, 2)
choice = random.randint(0,4)
cursor.execute('SELECT podkrutka FROM apple WHERE user_id = (?)', (us_id,))
podkrutka_user = cursor.fetchone()[0]
cursor.execute('SELECT all_podkrutka FROM settings WHERE bot = 1')
podkrutka_all = cursor.fetchone()[0]
if kassa - (win_money + last_win_money) > antiminus and choice != 1 or podkrutka_user == 1 or podkrutka_all == 1: