diff --git a/Acronymbot.py b/Acronymbot.py index 069d021..966a956 100644 --- a/Acronymbot.py +++ b/Acronymbot.py @@ -1,9 +1,9 @@ import discord from discord import app_commands +from BlackJack import BlackJack botIntents = discord.Intents.all() - client = discord.Client(intents=botIntents) tree = app_commands.CommandTree(client) @@ -41,7 +41,21 @@ class Buttons(discord.ui.View): for child in self.children: child.disabled = True await interaction.response.edit_message(content=f"Ouch!", view=self) - +@tree.command(description="Play Black Jack!") +async def bj(interaction: discord.Interaction): + discinput = lambda m: discordInput(interaction, m) + discoutput = lambda m: discordOutput(interaction, m) + blackJack = BlackJack(discinput, discoutput) + blackJack.play_game(100) + +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(interaction, message): + await interaction.response.send_message(message) client.run('NzgwNzg4NDIwMjkzMDM0MDA0.GEKkUB.Bbl09D3lWMGea_mcIESPMLUyGlkW-6N53BPFjI') \ No newline at end of file diff --git a/BlackJackBot/BlackJack.py b/BlackJack.py similarity index 99% rename from BlackJackBot/BlackJack.py rename to BlackJack.py index 500e066..a3e5a59 100644 --- a/BlackJackBot/BlackJack.py +++ b/BlackJack.py @@ -263,6 +263,7 @@ class BlackJack: with open("ledger.txt", "a") as ledger: ledger.write("{ID}:{Money}:0:0\n".format(ID=ID, Money=starterCash)) + def main(): terminput = lambda message: input(message) termoutput = lambda message: print(message) diff --git a/BlackJackBot/BJBot.py b/BlackJackBot/BJBot.py index dc94e74..3f00a85 100644 --- a/BlackJackBot/BJBot.py +++ b/BlackJackBot/BJBot.py @@ -1,10 +1,17 @@ -from discord import * -from discord.ext import commands +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(): @@ -12,6 +19,8 @@ async def on_ready(): @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 @@ -32,8 +41,7 @@ async def play_game(ctx, arg): gameOver = bj.checkGameOver(dealerWinState) if gameOver: continue - await ctx.send("Players hand = " + str(getHandTotal(bj.playerHand)) + ": " + handNumbersToCards( - bj.playerHand) + "\n" + "Dealers hand = ??: " + convertNumberToCard(bj.dealerHand[0]) + "??") + await ctx.send("Hit or Stand? (h/s)") diff --git a/BlackJackBot/__pycache__/BlackJack.cpython-310.pyc b/BlackJackBot/__pycache__/BlackJack.cpython-310.pyc new file mode 100644 index 0000000..13c9feb Binary files /dev/null and b/BlackJackBot/__pycache__/BlackJack.cpython-310.pyc differ diff --git a/__pycache__/BlackJack.cpython-310.pyc b/__pycache__/BlackJack.cpython-310.pyc new file mode 100644 index 0000000..2351a17 Binary files /dev/null and b/__pycache__/BlackJack.cpython-310.pyc differ