forked from Cryz/battle_royale_sim
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from utils import logs as _log
 | |
| from bot_libs import simulation as _bot_sim
 | |
| 
 | |
| async def _loop_game(context):
 | |
|   chat_id = context.job.chat_id
 | |
|   _log.log_info(f'_loop_game: {chat_id} - run game simulation day')
 | |
|   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:
 | |
|     _log.log_info(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:
 | |
|     _log.log_info(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)
 | |
|   _log.log_info(f'start_loop_game: {chat_id} - Cron job started')
 | 
