forked from Cryz/battle_royale_sim
show winner player and break loop game if you executed the periodically game
This commit is contained in:
10
bot.py
10
bot.py
@@ -12,7 +12,14 @@ from bot_libs import syms as _botsyms
|
||||
async def simulate_day(context, chat_id):
|
||||
if 'arena' in context.application.bot_data:
|
||||
Arena= context.application.bot_data['arena']
|
||||
if len(Arena.get_alive_players()) <= 1: return # TODO break the loop
|
||||
if len(Arena.get_alive_players()) == 1:
|
||||
winner= Arena.get_alive_players()[0]
|
||||
try:
|
||||
context.job.schedule_removal()
|
||||
print(f'simulate_day: Loop removed')
|
||||
except: pass
|
||||
msg= f'{winner.get_name()} Vince la cruenta battaglia, e vive felice e contento con Guarino'
|
||||
return await context.bot.send_message(chat_id, msg)
|
||||
print(f'{chat_id}: Guarino ha trovato l\'arena')
|
||||
await context.bot.send_message(chat_id, f'Giorno #{Arena.day}')
|
||||
msg= _dbg.play_one_day_debug(Arena)
|
||||
@@ -23,6 +30,7 @@ async def simulate_day(context, chat_id):
|
||||
|
||||
async def loop_game(context):
|
||||
chat_id = context.job.chat_id
|
||||
print(f'loop_game: run on {chat_id}')
|
||||
return await simulate_day(context, chat_id)
|
||||
|
||||
async def bot_start(update, context):
|
||||
|
||||
Reference in New Issue
Block a user