fix bot repeated names

This commit is contained in:
Giulio 2021-05-10 12:02:39 +02:00
parent 111aad0d44
commit de9a623e7e

View File

@ -194,7 +194,9 @@ def chat_message(sid, msg):
# ses.game.add_player(Player(f'AI_{random.randint(0,1000)}', 'bot', sio, bot=True)) # ses.game.add_player(Player(f'AI_{random.randint(0,1000)}', 'bot', sio, bot=True))
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'Only 1 bot at the time'}) sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'Only 1 bot at the time'})
else: else:
bot = Player(f'AI_{random.randint(0,1000)}', 'bot', sio, bot=True) bot = Player(f'AI_{random.randint(0,10)}', 'bot', sio, bot=True)
while any([p for p in ses.game.players if p.name == bot.name]):
bot = Player(f'AI_{random.randint(0,10)}', 'bot', sio, bot=True)
ses.game.add_player(bot) ses.game.add_player(bot)
bot.bot_spin() bot.bot_spin()
elif '/removebot' in msg and not ses.game.started: elif '/removebot' in msg and not ses.game.started: