Discord.py User Input для игры «камень, бумага, ножницы».
Я хотел бы создать бот Discord , способный играть на камнях, бумаге, ножницах. Я думаю, что базовый c код игры не сложен, но реализация discord.py сложна для меня. Проблема, вероятно, в этой строке кода player = await bot.wait_for('message')
. Я прочитал документацию по discord.py, но, похоже, она работает неправильно. Это мой код:
@bot.command(pass_context=True, aliases=['g', 'ga', 'gam'])
@commands.guild_only()
async def game(ctx):
await ctx.send(
'Hallo, wie gehts denn so ' + ctx.message.author.mention + '? Lust auf eine Runde Schere, Stein, Papier?')
wins = 0
losses = 0
ties = 0
while True:
await ctx.send('%s Siege, %s Niederlagen, %s Unentschieden \n' % (wins, losses, ties))
while True:
await ctx.send('Auf was setzt du? (s)tein, (p)apier, (sc)here oder (q)uit')
player = await bot.wait_for('message')
print(str(player))
if player == 'q':
return
if player == 's' or player == 'p' or player == 'sc':
break
await ctx.send('Schreib s, p, sc oder q!')
if player == 's':
await ctx.send('Stein gegen...')
elif player == 'p':
await ctx.send('Papier gegen...')
elif player == 'sc':
await ctx.send('Schere gegen...')
randomnum = random.randint(1, 3)
if randomnum == 1:
computer = 's'
await ctx.send('Stein!')
elif randomnum == 2:
computer = 'p'
await ctx.send('Papier!')
elif randomnum == 3:
computer = 'sc'
await ctx.send('Schere!')
if player == computer:
await ctx.send('Unentschieden!')
ties = ties + 1
elif player == 's' and computer == 'sc':
await ctx.send('Du gewinnst!')
wins = wins + 1
elif player == 's' and computer == 'p':
await ctx.send('Ich habe gewonnen!')
losses = losses + 1
elif player == 'p' and computer == 's':
await ctx.send('Du gewinnst!')
wins = wins + 1
elif player == 'p' and computer == 'sc':
losses = losses + 1
await ctx.send('Ich habe gewonnen!')
elif player == 'sc' and computer == 'p':
await ctx.send('Du gewinnst!')
wins = wins + 1
elif player == 'sc' and computer == 's':
await ctx.send('Ich habe gewonnen!')
losses = losses + 1