🧹 PEP updating

This commit is contained in:
Nikolaj
2021-06-14 21:00:10 +02:00
parent 8f6c8b06be
commit 8c253aca3d
43 changed files with 343 additions and 333 deletions

View File

@ -211,7 +211,7 @@ class Blackjack():
allStanding = True
preAllStanding = True
message = self.bot.longStrings["Blackjack all players standing"]
message = self.bot.long_strings["Blackjack all players standing"]
if game["all standing"]:
self.bot.log("All are standing")
@ -245,11 +245,11 @@ class Blackjack():
return "", True, done
else:
if game["round"] == 0:
firstRoundMsg = self.bot.longStrings["Blackjack first round"]
firstRoundMsg = self.bot.long_strings["Blackjack first round"]
else:
firstRoundMsg = ""
sendMessage = self.bot.longStrings["Blackjack commands"]
sendMessage = self.bot.long_strings["Blackjack commands"]
print(firstRoundMsg)
sendMessage = sendMessage.format(firstRoundMsg)
return sendMessage, False, done
@ -352,7 +352,7 @@ class Blackjack():
winningCalc = (self._calcWinnings(*_calcWinningsParams))
winnings, netWinnings, reason = winningCalc
userName = self.bot.databaseFuncs.getName(user)
userName = self.bot.database_funcs.getName(user)
if winnings < 0:
if winnings == -1:
@ -569,7 +569,7 @@ class Blackjack():
"""
self.bot.log("Loop "+str(gameRound), str(channel.id))
oldImagePath = f"resources/games/oldImages/blackjack{channel.id}"
oldImagePath = f"resources/games/old_images/blackjack{channel.id}"
with open(oldImagePath, "r") as f:
oldImage = await channel.fetch_message(int(f.read()))
@ -604,15 +604,15 @@ class Blackjack():
if rightRound:
if not gamedone:
logMessage = f"Loop {gameRound} calling self._blackjackLoop()"
self.bot.log(logMessage, str(channel.id))
log_message = f"Loop {gameRound} calling self._blackjackLoop()"
self.bot.log(log_message, str(channel.id))
await self._blackjackLoop(channel, gameRound+1, gameID)
else:
new_message = self._blackjackFinish(str(channel.id))
await channel.send(new_message)
else:
logMessage = f"Ending loop on round {gameRound}"
self.bot.log(logMessage, str(channel.id))
log_message = f"Ending loop on round {gameRound}"
self.bot.log(log_message, str(channel.id))
async def hit(self, ctx: discord_slash.context.SlashContext,
handNumber: int = 0):
@ -640,16 +640,16 @@ class Blackjack():
hand, handNumber = self._getHandNumber(userHands, handNumber)
if hand is None:
logMessage = "They didn't specify a hand"
log_message = "They didn't specify a hand"
sendMessage = "You need to specify a hand"
elif game["round"] <= 0:
logMessage = "They tried to hit on the 0th round"
log_message = "They tried to hit on the 0th round"
sendMessage = "You can't hit before you see your cards"
elif hand["hit"]:
logMessage = "They've already hit this round"
log_message = "They've already hit this round"
sendMessage = "You've already hit this round"
elif hand["standing"]:
logMessage = "They're already standing"
log_message = "They're already standing"
sendMessage = "You can't hit when you're standing"
else:
hand["hand"].append(self._drawCard(channel))
@ -675,13 +675,13 @@ class Blackjack():
roundDone = self._isRoundDone(game)
sendMessage = f"{ctx.author.display_name} hit"
logMessage = "They succeeded"
log_message = "They succeeded"
else:
logMessage = "They tried to hit without being in the game"
log_message = "They tried to hit without being in the game"
sendMessage = "You have to enter the game before you can hit"
await ctx.send(sendMessage)
self.bot.log(logMessage)
self.bot.log(log_message)
if roundDone:
gameID = game["gameID"]
@ -713,22 +713,22 @@ class Blackjack():
hand, handNumber = self._getHandNumber(*handParams)
if hand is None:
logMessage = "They didn't specify a hand"
log_message = "They didn't specify a hand"
sendMessage = "You need to specify a hand"
elif game["round"] <= 0:
logMessage = "They tried to hit on the 0th round"
log_message = "They tried to hit on the 0th round"
sendMessage = "You can't hit before you see your cards"
elif hand["hit"]:
logMessage = "They've already hit this round"
log_message = "They've already hit this round"
sendMessage = "You've already hit this round"
elif hand["standing"]:
logMessage = "They're already standing"
log_message = "They're already standing"
sendMessage = "You can't hit when you're standing"
elif len(hand["hand"]) != 2:
logMessage = "They tried to double after round 1"
log_message = "They tried to double after round 1"
sendMessage = "You can only double on the first round"
elif self.bot.money.checkBalance(user) < hand["bet"]:
logMessage = "They tried to double without being in the game"
log_message = "They tried to double without being in the game"
sendMessage = "You can't double when you're not in the game"
else:
bet = hand["bet"]
@ -759,16 +759,16 @@ class Blackjack():
game = blackjackGames.find_one({"_id": channel})
roundDone = self._isRoundDone(game)
sendMessage = self.bot.longStrings["Blackjack double"]
userName = self.bot.databaseFuncs.getName(user)
sendMessage = self.bot.long_strings["Blackjack double"]
userName = self.bot.database_funcs.getName(user)
sendMessage = sendMessage.format(bet, userName)
logMessage = "They succeeded"
log_message = "They succeeded"
else:
logMessage = "They tried to double without being in the game"
log_message = "They tried to double without being in the game"
sendMessage = "You can't double when you're not in the game"
await ctx.send(sendMessage)
self.bot.log(logMessage)
self.bot.log(log_message)
if roundDone:
gameID = game["gameID"]
@ -801,16 +801,16 @@ class Blackjack():
if hand is None:
sendMessage = "You need to specify which hand"
logMessage = "They didn't specify a hand"
log_message = "They didn't specify a hand"
elif game["round"] <= 0:
sendMessage = "You can't stand before you see your cards"
logMessage = "They tried to stand on round 0"
log_message = "They tried to stand on round 0"
elif hand["hit"]:
sendMessage = "You've already hit this round"
logMessage = "They'd already hit this round"
log_message = "They'd already hit this round"
elif hand["standing"]:
sendMessage = "You're already standing"
logMessage = "They're already standing"
log_message = "They're already standing"
else:
hand["standing"] = True
@ -829,14 +829,14 @@ class Blackjack():
roundDone = self._isRoundDone(game)
sendMessage = f"{ctx.author.display_name} is standing"
logMessage = "They succeeded"
log_message = "They succeeded"
else:
logMessage = "They tried to stand without being in the game"
log_message = "They tried to stand without being in the game"
sendMessage = "You have to enter the game before you can stand"
await ctx.send(sendMessage)
self.bot.log(logMessage)
self.bot.log(log_message)
if roundDone:
gameID = game["gameID"]
@ -887,33 +887,33 @@ class Blackjack():
otherHand = 4
if handNumberError:
logMessage = "They didn't specify a hand"
log_message = "They didn't specify a hand"
sendMessage = "You have to specify the hand you're hitting with"
elif game["round"] == 0:
logMessage = "They tried to split on round 0"
log_message = "They tried to split on round 0"
sendMessage = "You can't split before you see your cards"
elif game["user hands"][user]["split"] > 3:
logMessage = "They tried to split more than three times"
log_message = "They tried to split more than three times"
sendMessage = "You can only split 3 times"
elif hand["hit"]:
logMessage = "They've already hit"
log_message = "They've already hit"
sendMessage = "You've already hit or split this hand."
elif hand["standing"]:
logMessage = "They're already standing"
log_message = "They're already standing"
sendMessage = "You're already standing"
elif len(hand["hand"]) != 2:
logMessage = "They tried to split after the first round"
log_message = "They tried to split after the first round"
sendMessage = "You can only split on the first round"
else:
firstCard = self._calcHandValue([hand["hand"][0]])
secondCard = self._calcHandValue([hand["hand"][1]])
if firstCard != secondCard:
logMessage = "They tried to split two different cards"
sendMessage = self.bot.longStrings["Blackjack different cards"]
log_message = "They tried to split two different cards"
sendMessage = self.bot.long_strings["Blackjack different cards"]
else:
bet = hand["bet"]
if self.bot.money.checkBalance(user) < bet:
logMessage = "They didn't have enough GwendoBucks"
log_message = "They didn't have enough GwendoBucks"
sendMessage = "You don't have enough GwendoBucks"
else:
self.bot.money.addMoney(user, -1 * bet)
@ -972,13 +972,13 @@ class Blackjack():
game = blackjackGames.find_one({"_id": channel})
roundDone = self._isRoundDone(game)
sendMessage = self.bot.longStrings["Blackjack split"]
userName = self.bot.databaseFuncs.getName(user)
sendMessage = self.bot.long_strings["Blackjack split"]
userName = self.bot.database_funcs.getName(user)
sendMessage = sendMessage.format(userName)
logMessage = "They succeeded"
log_message = "They succeeded"
await ctx.send(sendMessage)
self.bot.log(logMessage)
self.bot.log(log_message)
if roundDone:
gameID = game["gameID"]
@ -1002,28 +1002,28 @@ class Blackjack():
user = f"#{ctx.author.id}"
collection = self.bot.database["blackjack games"]
game = collection.find_one({"_id": channel})
userName = self.bot.databaseFuncs.getName(user)
userName = self.bot.database_funcs.getName(user)
self.bot.log(f"{userName} is trying to join the Blackjack game")
if game is None:
sendMessage = "There is no game going on in this channel"
logMessage = sendMessage
log_message = sendMessage
elif user in game["user hands"]:
sendMessage = "You're already in the game!"
logMessage = "They're already in the game"
log_message = "They're already in the game"
elif len(game["user hands"]) >= 5:
sendMessage = "There can't be more than 5 players in a game"
logMessage = "There were already 5 players in the game"
log_message = "There were already 5 players in the game"
elif game["round"] != 0:
sendMessage = "The table is no longer taking bets"
logMessage = "They tried to join after the game begun"
log_message = "They tried to join after the game begun"
elif bet < 0:
sendMessage = "You can't bet a negative amount"
logMessage = "They tried to bet a negative amount"
log_message = "They tried to bet a negative amount"
elif self.bot.money.checkBalance(user) < bet:
sendMessage = "You don't have enough GwendoBucks"
logMessage = "They didn't have enough GwendoBucks"
log_message = "They didn't have enough GwendoBucks"
else:
self.bot.money.addMoney(user, -1 * bet)
playerHand = [self._drawCard(channel) for _ in range(2)]
@ -1048,9 +1048,9 @@ class Blackjack():
enterGameText = "entered the game with a bet of"
betText = f"{bet} GwendoBucks"
sendMessage = f"{userName} {enterGameText} {betText}"
logMessage = sendMessage
log_message = sendMessage
self.bot.log(logMessage)
self.bot.log(log_message)
await ctx.send(sendMessage)
async def start(self, ctx: discord_slash.context.SlashContext):
@ -1109,7 +1109,7 @@ class Blackjack():
gameStarted = True
if gameStarted:
sendMessage = self.bot.longStrings["Blackjack started"]
sendMessage = self.bot.long_strings["Blackjack started"]
await ctx.channel.send(sendMessage)
tableImagesPath = "resources/games/blackjackTables/"
@ -1117,7 +1117,7 @@ class Blackjack():
oldImage = await ctx.channel.send(file=discord.File(filePath))
with open("resources/games/oldImages/blackjack"+channel, "w") as f:
with open("resources/games/old_images/blackjack"+channel, "w") as f:
f.write(str(oldImage.id))
await asyncio.sleep(30)
@ -1142,7 +1142,7 @@ class Blackjack():
new_message = self._blackjackFinish(channel)
await ctx.channel.send(new_message)
else:
sendMessage = self.bot.longStrings["Blackjack going on"]
sendMessage = self.bot.long_strings["Blackjack going on"]
await ctx.channel.send(sendMessage)
self.bot.log("There was already a game going on")
@ -1267,7 +1267,7 @@ class DrawBlackjack():
for x in range(len(hands)):
key, value = list(hands.items())[x]
key = self.bot.databaseFuncs.getName(key)
key = self.bot.database_funcs.getName(key)
handParams = [
value["hand"],
False,