🧹 Last bit of cleaning up before pushing

This commit is contained in:
NikolajDanger
2021-03-31 01:02:32 +02:00
parent b345720468
commit 6c1a1cf626
37 changed files with 125 additions and 118 deletions

View File

@ -35,7 +35,7 @@ class Blackjack():
# Calculates the value of a blackjack hand
def calcHandValue(self, hand : list):
self.bot.log("Calculating hand value", level = 10)
self.bot.log("Calculating hand value")
values = []
values.append(0)
@ -58,13 +58,13 @@ class Blackjack():
if value <= 21:
handValue = value
self.bot.log("Calculated "+str(hand)+" to be "+str(handValue), level = 10)
self.bot.log("Calculated "+str(hand)+" to be "+str(handValue))
return handValue
# Draws a card from the deck
def drawCard(self, channel):
self.bot.log("drawing a card", level = 10)
self.bot.log("drawing a card")
drawnCard = self.bot.database["blackjack cards"].find_one({"_id":channel})["cards"][0]
self.bot.database["blackjack cards"].update_one({"_id":channel},{"$pop":{"cards":-1}})
@ -97,7 +97,7 @@ class Blackjack():
# Goes to the next round and calculates some stuff
def blackjackContinue(self, channel):
self.bot.log("Continuing blackjack game", level = 10)
self.bot.log("Continuing blackjack game")
game = self.bot.database["blackjack games"].find_one({"_id":channel})
done = False
@ -116,7 +116,7 @@ class Blackjack():
game = self.bot.database["blackjack games"].find_one({"_id":channel})
self.bot.log("Testing if all are standing", level = 10)
self.bot.log("Testing if all are standing")
for user in game["user hands"]:
try:
newUser, allStanding, preAllStanding = self.testIfStanding(game["user hands"][user],allStanding,preAllStanding,True)
@ -141,10 +141,10 @@ class Blackjack():
return "", True, done
else:
if game["round"] == 1:
firstRoundMessage = ". You can also double down with \"!blackjack double\" or split with \"!blackjack split\""
firstRoundMessage = ". You can also double down with \"/blackjack double\" or split with \"/blackjack split\""
else:
firstRoundMessage = ""
return "You have 2 minutes to either hit or stand with \"!blackjack hit\" or \"!blackjack stand\""+firstRoundMessage+". It's assumed you're standing if you don't make a choice.", False, done
return "You have 2 minutes to either hit or stand with \"/blackjack hit\" or \"/blackjack stand\""+firstRoundMessage+". It's assumed you're standing if you don't make a choice.", False, done
def testIfStanding(self, hand,allStanding,preAllStanding,topLevel):
if hand["hit"] == False:
@ -430,7 +430,7 @@ class Blackjack():
roundDone = self.isRoundDone(self.bot.database["blackjack games"].find_one({"_id":channel}))
return "Splitting "+self.bot.databaseFuncs.getName(user)+"'s hand into 2. Adding their original bet to the second hand. You can use \"!Blackjack hit/stand/double 1\" and \"!Blackjack hit/stand/double 2\" to play the different hands.",str(roundDone)[0] + str(game["round"])
return "Splitting "+self.bot.databaseFuncs.getName(user)+"'s hand into 2. Adding their original bet to the second hand. You can use \"/blackjack hit/stand/double 1\" and \"/blackjack hit/stand/double 2\" to play the different hands.",str(roundDone)[0] + str(game["round"])
else:
self.bot.log(user+" doesn't have enough GwendoBucks")
return "You don't have enough GwendoBucks",""
@ -564,7 +564,7 @@ class Blackjack():
def calcWinnings(self,hand, dealerValue, topLevel, dealerBlackjack, dealerBusted):
self.bot.log("Calculating winnings", level = 10)
self.bot.log("Calculating winnings")
reason = ""
bet = hand["bet"]
winnings = -1 * bet
@ -659,14 +659,14 @@ class Blackjack():
# Loop of blackjack game rounds
async def blackjackLoop(self,channel,gameRound,gameID):
self.bot.log("Loop "+str(gameRound),str(channel.id), level = 10)
self.bot.log("Loop "+str(gameRound),str(channel.id))
with open("resources/games/oldImages/blackjack"+str(channel.id), "r") as f:
oldImage = await channel.fetch_message(int(f.read()))
new_message, allStanding, gamedone = self.blackjackContinue(str(channel.id))
if new_message != "":
self.bot.log(new_message,str(channel.id), level = 10)
self.bot.log(new_message,str(channel.id))
await channel.send(new_message)
if gamedone == False:
await oldImage.delete()
@ -699,9 +699,9 @@ class Blackjack():
self.bot.log("Something fucked up (error code 1310)")
await channel.send(new_message)
else:
self.bot.log("Ending loop on round "+str(gameRound),str(channel.id), level = 10)
self.bot.log("Ending loop on round "+str(gameRound),str(channel.id))
else:
self.bot.log("Ending loop on round "+str(gameRound),str(channel.id), level = 10)
self.bot.log("Ending loop on round "+str(gameRound),str(channel.id))
async def parseBlackjack(self,content, ctx):
# Blackjack shuffle variables
@ -726,7 +726,7 @@ class Blackjack():
new_message = self.blackjackStart(str(channel))
if new_message == "started":
new_message = "Blackjack game started. Use \"!blackjack bet [amount]\" to enter the game within the next 30 seconds."
new_message = "Blackjack game started. Use \"/blackjack bet [amount]\" to enter the game within the next 30 seconds."
await ctx.channel.send(new_message)
oldImage = await ctx.channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(channel)+".png"))
@ -746,7 +746,7 @@ class Blackjack():
# Loop of game rounds
if gamedone == False:
self.bot.log("!blackjack calling self.blackjackLoop()",str(channel))
self.bot.log("/blackjack calling self.blackjackLoop()",str(channel))
await self.blackjackLoop(ctx.channel,1,gameID)
else:
new_message = self.blackjackFinish(str(channel))