24 lines
1.0 KiB
Python
24 lines
1.0 KiB
Python
from bot_libs import simulation as _bot_sim
|
|
|
|
async def _loop_game(context):
|
|
chat_id = context.job.chat_id
|
|
print(f'_loop_game: run on {chat_id}')
|
|
return await _bot_sim.simulate_day(context, chat_id)
|
|
|
|
async def start_loop_game(update, context, seconds):
|
|
await update.message.reply_text(f'Ok capo!! giochero\' per te ogni {seconds}s')
|
|
chat_id = update.effective_chat.id
|
|
if 'arena' not in context.application.bot_data:
|
|
print(f'start_loop_game: {chat_id} Arena not found')
|
|
await update.message.reply_text(f'Arena non trovata, avviare con /start')
|
|
return
|
|
|
|
Arena= context.application.bot_data['arena']
|
|
if len(Arena.get_players()) < 2:
|
|
print(f'start_loop_game: {chat_id} Not enough player to start the match')
|
|
await update.message.reply_text(f'Servono almeno 2 giocatori. Ecco i giocatori presenti nel mondo do gioco: \n{Arena.get_players()}')
|
|
return
|
|
|
|
context.job_queue.run_repeating(_loop_game, interval= seconds, first=1, chat_id= chat_id)
|
|
print(f'start_loop_game: Repeating Job created for: {chat_id}')
|