import discord from BlackJack import * client = commands.Bot(command_prefix='~~') async def discordInput(interaction: discord.Interaction, message:str): await interaction.response.send_message(message) def check(m): return m.content in ["h", "s"] and m.channel == interaction.channel msg = await client.wait_for('message', check=check) async def discordOutput(ctx, message): await ctx.send(message) @client.event async def on_ready(): print("Let's pwn some scrubs") @client.command() async def play_game(ctx, arg): await ctx.send("Players hand = " + str(getHandTotal(bj.playerHand)) + ": " + handNumbersToCards( bj.playerHand) + "\n" + "Dealers hand = ??: " + convertNumberToCard(bj.dealerHand[0]) + "??") bj = BlackJack() gameOver = False playerStood = False ID = ctx.message.author.id IDFound = bj.findID(ID)[0] if IDFound: playerStats = bj.readLedger(ID)[1:] playerStats[0] = ID else: bj.addToLedger(ID) playerStats = (ID, 100, 0, 0) while not gameOver: playerWinState = bj.checkHandState(bj.playerHand) dealerWinState = bj.checkHandState(bj.dealerHand) gameOver = bj.checkGameOver(playerWinState) if gameOver: continue gameOver = bj.checkGameOver(dealerWinState) if gameOver: continue await ctx.send("Hit or Stand? (h/s)") def check(m): return m.content in ["h", "s"] and m.channel == ctx.channel msg = await client.wait_for('message', check=check) if msg == "h": bj.hit() elif msg == "s": bj.stand() playerStood = True playerWinState = bj.checkHandState(bj.playerHand) gameOver = bj.checkGameOver(playerWinState) if gameOver: continue # Dealers turn if playerStood: while dealerWinState == 'c': # Dealer hits bj.hit() # Player stands bj.stand() # Loop ends when game is over dealerWinState = bj.checkHandState(bj.dealerHand) else: bj.hit() dealerWinState = bj.checkHandState(bj.dealerHand) gameOver = bj.checkGameOver(dealerWinState) if gameOver: continue await ctx.send("Players hand = " + str(getHandTotal(bj.playerHand)) + ": " + handNumbersToCards(bj.playerHand) + "\n" + "Dealers hand = " + str(getHandTotal(bj.dealerHand)) + ": " + handNumbersToCards(bj.dealerHand)) bet = int(arg) if playerWinState == "w": await ctx.send("You won!") bj.writeLedger(ID, 2*bet, True) elif playerWinState == "l": await ctx.send("You busted!") bj.writeLedger(ID, -bet, False) elif dealerWinState == "w": await ctx.send("The Dealer reached 21 before you!") bj.writeLedger(ID, -bet, False) elif dealerWinState == "l": await ctx.send("The Dealer busted before you!") bj.writeLedger(ID, 2*bet, True) client.run('ODU0MjE5MDMzNzc0NTIyMzY4.YMgveA.laeIhhccTDvEbU81Y-RjSEMkaEY')