1
0

show winner player and break loop game if you executed the periodically game

This commit is contained in:
andrea
2025-07-26 11:52:01 +02:00
parent 888f22ac1b
commit a7c6dd25df

10
bot.py
View File

@@ -12,7 +12,14 @@ from bot_libs import syms as _botsyms
async def simulate_day(context, chat_id): async def simulate_day(context, chat_id):
if 'arena' in context.application.bot_data: if 'arena' in context.application.bot_data:
Arena= context.application.bot_data['arena'] 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') print(f'{chat_id}: Guarino ha trovato l\'arena')
await context.bot.send_message(chat_id, f'Giorno #{Arena.day}') await context.bot.send_message(chat_id, f'Giorno #{Arena.day}')
msg= _dbg.play_one_day_debug(Arena) msg= _dbg.play_one_day_debug(Arena)
@@ -23,6 +30,7 @@ async def simulate_day(context, chat_id):
async def loop_game(context): async def loop_game(context):
chat_id = context.job.chat_id chat_id = context.job.chat_id
print(f'loop_game: run on {chat_id}')
return await simulate_day(context, chat_id) return await simulate_day(context, chat_id)
async def bot_start(update, context): async def bot_start(update, context):