Reorganising
This commit is contained in:
@@ -12,35 +12,9 @@ async def on_ready():
|
|||||||
await tree.sync()
|
await tree.sync()
|
||||||
print('Itsa me Mario!')
|
print('Itsa me Mario!')
|
||||||
|
|
||||||
@tree.command(description="Lmao")
|
"""
|
||||||
async def test(interaction:discord.Interaction):
|
#### Test ####
|
||||||
print(f"{interaction.user} used command! Woohoo!")
|
"""
|
||||||
try:
|
|
||||||
await interaction.response.send_message("Pay $5 for a Mario Moment", view=Buttons())
|
|
||||||
except discord.app_commands.errors.CommandInvokeError:
|
|
||||||
print("Uh oh! It failed!")
|
|
||||||
|
|
||||||
class HitOrStand(discord.ui.View):
|
|
||||||
def __init__(self, *, timeout=180):
|
|
||||||
super().__init__(timeout=timeout)
|
|
||||||
self.content = None
|
|
||||||
|
|
||||||
@discord.ui.button(label="Hit", style=discord.ButtonStyle.green)
|
|
||||||
async def hit(self, interaction: discord.Interaction, button: discord.ui.Button):
|
|
||||||
self.content = "h"
|
|
||||||
for child in self.children:
|
|
||||||
child.disabled = True
|
|
||||||
await interaction.response.edit_message(content="You Hit!", view=self)
|
|
||||||
self.stop()
|
|
||||||
|
|
||||||
@discord.ui.button(label="Stand", style=discord.ButtonStyle.red)
|
|
||||||
async def stand(self, interaction: discord.Interaction, button: discord.ui.Button):
|
|
||||||
self.content = "s"
|
|
||||||
for child in self.children:
|
|
||||||
child.disabled = True
|
|
||||||
await interaction.response.edit_message(content="You stood!", view=self)
|
|
||||||
self.stop()
|
|
||||||
|
|
||||||
class Buttons(discord.ui.View):
|
class Buttons(discord.ui.View):
|
||||||
def __init__(self, *, timeout=180):
|
def __init__(self, *, timeout=180):
|
||||||
super().__init__(timeout=timeout)
|
super().__init__(timeout=timeout)
|
||||||
@@ -63,6 +37,38 @@ class Buttons(discord.ui.View):
|
|||||||
child.disabled = True
|
child.disabled = True
|
||||||
await interaction.response.edit_message(content=f"Ouch!", view=self)
|
await interaction.response.edit_message(content=f"Ouch!", view=self)
|
||||||
|
|
||||||
|
@tree.command(description="Lmao")
|
||||||
|
async def test(interaction:discord.Interaction):
|
||||||
|
print(f"{interaction.user} used command! Woohoo!")
|
||||||
|
try:
|
||||||
|
await interaction.response.send_message("Pay $5 for a Mario Moment", view=Buttons())
|
||||||
|
except discord.app_commands.errors.CommandInvokeError:
|
||||||
|
print("Uh oh! It failed!")
|
||||||
|
|
||||||
|
"""
|
||||||
|
#### Black Jack ####
|
||||||
|
"""
|
||||||
|
class HitOrStand(discord.ui.View):
|
||||||
|
def __init__(self, *, timeout=180):
|
||||||
|
super().__init__(timeout=timeout)
|
||||||
|
self.content = None
|
||||||
|
|
||||||
|
@discord.ui.button(label="Hit", style=discord.ButtonStyle.green)
|
||||||
|
async def hit(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
|
self.content = "h"
|
||||||
|
for child in self.children:
|
||||||
|
child.disabled = True
|
||||||
|
await interaction.response.edit_message(content="You Hit!", view=self)
|
||||||
|
self.stop()
|
||||||
|
|
||||||
|
@discord.ui.button(label="Stand", style=discord.ButtonStyle.red)
|
||||||
|
async def stand(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
|
self.content = "s"
|
||||||
|
for child in self.children:
|
||||||
|
child.disabled = True
|
||||||
|
await interaction.response.edit_message(content="You stood!", view=self)
|
||||||
|
self.stop()
|
||||||
|
|
||||||
@tree.command(description="Play Black Jack!")
|
@tree.command(description="Play Black Jack!")
|
||||||
async def bj(interaction: discord.Interaction):
|
async def bj(interaction: discord.Interaction):
|
||||||
discinput = lambda m: discordInput(interaction, m)
|
discinput = lambda m: discordInput(interaction, m)
|
||||||
@@ -80,4 +86,8 @@ async def discordInput(interaction: discord.Interaction, message:str):
|
|||||||
async def discordOutput(interaction: discord.Interaction, message):
|
async def discordOutput(interaction: discord.Interaction, message):
|
||||||
await interaction.followup.send(message)
|
await interaction.followup.send(message)
|
||||||
|
|
||||||
|
"""
|
||||||
|
#### Fin ####
|
||||||
|
"""
|
||||||
|
|
||||||
client.run('NzgwNzg4NDIwMjkzMDM0MDA0.GEKkUB.Bbl09D3lWMGea_mcIESPMLUyGlkW-6N53BPFjI')
|
client.run('NzgwNzg4NDIwMjkzMDM0MDA0.GEKkUB.Bbl09D3lWMGea_mcIESPMLUyGlkW-6N53BPFjI')
|
||||||
13
BlackJack.py
13
BlackJack.py
@@ -147,13 +147,10 @@ class BlackJack:
|
|||||||
while not gameOver:
|
while not gameOver:
|
||||||
playerWinState = self.checkHandState(self.playerHand)
|
playerWinState = self.checkHandState(self.playerHand)
|
||||||
dealerWinState = self.checkHandState(self.dealerHand)
|
dealerWinState = self.checkHandState(self.dealerHand)
|
||||||
gameOver = self.checkGameOver(playerWinState)
|
gameOver = self.checkGameOver(playerWinState) or self.checkGameOver(dealerWinState)
|
||||||
if gameOver:
|
if gameOver:
|
||||||
continue
|
continue
|
||||||
gameOver = self.checkGameOver(dealerWinState)
|
|
||||||
if gameOver:
|
|
||||||
continue
|
|
||||||
|
|
||||||
await self.send("Players hand = " + str(getHandTotal(self.playerHand)) + ": " + handNumbersToCards(
|
await self.send("Players hand = " + str(getHandTotal(self.playerHand)) + ": " + handNumbersToCards(
|
||||||
self.playerHand) + "\n" + "Dealers hand = ??: " + convertNumberToCard(self.dealerHand[0]) + "??")
|
self.playerHand) + "\n" + "Dealers hand = ??: " + convertNumberToCard(self.dealerHand[0]) + "??")
|
||||||
play = await self.recv("Hit or Stand? (h/s)")
|
play = await self.recv("Hit or Stand? (h/s)")
|
||||||
@@ -167,8 +164,7 @@ class BlackJack:
|
|||||||
playerStood = True
|
playerStood = True
|
||||||
|
|
||||||
playerWinState = self.checkHandState(self.playerHand)
|
playerWinState = self.checkHandState(self.playerHand)
|
||||||
gameOver = self.checkGameOver(playerWinState)
|
if self.checkGameOver(playerWinState):
|
||||||
if gameOver:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Dealers turn
|
# Dealers turn
|
||||||
@@ -184,8 +180,7 @@ class BlackJack:
|
|||||||
self.hit()
|
self.hit()
|
||||||
dealerWinState = self.checkHandState(self.dealerHand)
|
dealerWinState = self.checkHandState(self.dealerHand)
|
||||||
|
|
||||||
gameOver = self.checkGameOver(dealerWinState)
|
if self.checkGameOver(dealerWinState):
|
||||||
if gameOver:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
await self.send("Players hand = " + str(getHandTotal(self.playerHand)) + ": " + handNumbersToCards(self.playerHand) +
|
await self.send("Players hand = " + str(getHandTotal(self.playerHand)) + ": " + handNumbersToCards(self.playerHand) +
|
||||||
|
|||||||
Reference in New Issue
Block a user