✨ Separate blackjack cards for each chann
This commit is contained in:
@ -9,7 +9,7 @@ from funcs import logThis, replaceMultiple
|
||||
from . import money, blackjackDraw
|
||||
|
||||
# Shuffles the blackjack cards
|
||||
def blackjackShuffle(decks):
|
||||
def blackjackShuffle(decks,channel):
|
||||
logThis("Shuffling the blackjack deck")
|
||||
|
||||
with open("resources/games/deckofCards.txt","r") as f:
|
||||
@ -19,13 +19,13 @@ def blackjackShuffle(decks):
|
||||
random.shuffle(allDecks)
|
||||
data = "\n".join(allDecks)
|
||||
|
||||
with open("resources/games/blackjackCards.txt","w") as f:
|
||||
with open("resources/games/blackjackCards/"+channel+".txt","w") as f:
|
||||
f.write(data)
|
||||
|
||||
# Creates hilo.txt
|
||||
logThis("creating hilo.txt.")
|
||||
# Creates hilo file
|
||||
logThis("creating hilo/"+channel+".txt.")
|
||||
data = "0"
|
||||
with open("resources/games/hilo.txt","w") as f:
|
||||
with open("resources/games/hilo/"+channel+".txt","w") as f:
|
||||
f.write(data)
|
||||
|
||||
return
|
||||
@ -59,11 +59,11 @@ def calcHandValue(hand : list):
|
||||
return handValue
|
||||
|
||||
# Draws a card from the deck
|
||||
def drawCard():
|
||||
def drawCard(channel):
|
||||
logThis("drawing a card")
|
||||
with open("resources/games/blackjackCards.txt","r") as f:
|
||||
with open("resources/games/blackjackCards/"+channel+".txt","r") as f:
|
||||
cards = f.read().split("\n")
|
||||
with open("resources/games/hilo.txt", "r") as f:
|
||||
with open("resources/games/hilo/"+channel+".txt", "r") as f:
|
||||
data = int(f.read())
|
||||
|
||||
drawnCard = cards.pop(0)
|
||||
@ -76,9 +76,9 @@ def drawCard():
|
||||
elif value >= 10:
|
||||
data -= 1
|
||||
|
||||
with open("resources/games/blackjackCards.txt","w") as f:
|
||||
with open("resources/games/blackjackCards/"+channel+".txt","w") as f:
|
||||
f.write(deck)
|
||||
with open("resources/games/hilo.txt", "w") as f:
|
||||
with open("resources/games/hilo/"+channel+".txt", "w") as f:
|
||||
f.write(str(data))
|
||||
|
||||
return drawnCard
|
||||
@ -92,7 +92,7 @@ def dealerDraw(channel):
|
||||
dealerHand = data["blackjack games"][channel]["dealer hand"]
|
||||
|
||||
if calcHandValue(dealerHand) < 17:
|
||||
data["blackjack games"][channel]["dealer hand"].append(drawCard())
|
||||
data["blackjack games"][channel]["dealer hand"].append(drawCard(channel))
|
||||
else:
|
||||
done = True
|
||||
|
||||
@ -211,7 +211,7 @@ def blackjackHit(channel,user,handNumber = 0):
|
||||
if data["blackjack games"][channel]["round"] > 0:
|
||||
if hand["hit"] == False:
|
||||
if hand["standing"] == False:
|
||||
hand["hand"].append(drawCard())
|
||||
hand["hand"].append(drawCard(channel))
|
||||
hand["hit"] = True
|
||||
|
||||
handValue = calcHandValue(hand["hand"])
|
||||
@ -289,7 +289,7 @@ def blackjackDouble(channel,user,handNumber = 0):
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
hand["hand"].append(drawCard())
|
||||
hand["hand"].append(drawCard(channel))
|
||||
hand["hit"] = True
|
||||
hand["doubled"] = True
|
||||
hand["bet"] += bet
|
||||
@ -418,8 +418,8 @@ def blackjackSplit(channel,user):
|
||||
data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"] = data["blackjack games"][channel]["user hands"][user]["bet"]
|
||||
|
||||
data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"].append(data["blackjack games"][channel]["user hands"][user]["hand"].pop(1))
|
||||
data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"].append(drawCard())
|
||||
data["blackjack games"][channel]["user hands"][user]["hand"].append(drawCard())
|
||||
data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"].append(drawCard(channel))
|
||||
data["blackjack games"][channel]["user hands"][user]["hand"].append(drawCard(channel))
|
||||
|
||||
handValue = calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"])
|
||||
otherHandValue = calcHandValue(data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"])
|
||||
@ -481,7 +481,7 @@ def blackjackPlayerDrawHand(channel,user,bet):
|
||||
if bet >= 0:
|
||||
if money.checkBalance(user) >= bet:
|
||||
money.addMoney(user,-1 * bet)
|
||||
playerHand = [drawCard(),drawCard()]
|
||||
playerHand = [drawCard(channel),drawCard(channel)]
|
||||
|
||||
handValue = calcHandValue(playerHand)
|
||||
|
||||
@ -534,7 +534,7 @@ def blackjackStart(channel:str):
|
||||
|
||||
if channel not in data["blackjack games"]:
|
||||
|
||||
dealerHand = [drawCard(),drawCard()]
|
||||
dealerHand = [drawCard(channel),drawCard(channel)]
|
||||
gameID = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
|
||||
|
||||
data["blackjack games"][channel] = {"dealer hand": dealerHand,"dealer busted":False,"dealer blackjack":False,"user hands": {},"all standing":False,"round":0,"id":gameID}
|
||||
|
Reference in New Issue
Block a user