Separate blackjack cards for each chann

This commit is contained in:
Nikolaj Danger
2020-07-30 17:42:48 +02:00
parent d807afe36d
commit 796b209a5b
4 changed files with 50 additions and 46 deletions

View File

@ -8,6 +8,7 @@ import string
import json
import random
import math
import os
from funcs import *
@ -415,13 +416,14 @@ async def parseCommands(message,content):
# Starts the game
if content == "blackjack" or content == "blackjack ":
cardsLeft = 0
with open("resources/games/blackjackCards.txt","r") as f:
for line in f:
cardsLeft += 1
if os.path.exists("resources/games/blackjackCards/"+str(message.channel)+".txt"):
with open("resources/games/blackjackCards/"+str(message.channel)+".txt","r") as f:
for line in f:
cardsLeft += 1
# Shuffles if not enough cards
if cardsLeft < blackjackMinCards:
blackjackShuffle(blackjackDecks)
blackjackShuffle(blackjackDecks,str(message.channel))
logThis("Shuffling the blackjack deck...",str(message.channel))
await message.channel.send("Shuffling the deck...")
@ -560,21 +562,27 @@ async def parseCommands(message,content):
# Returning current hi-lo value
elif content.startswith("blackjack hilo") and message.author.display_name == "Nikolaj":
with open("resources/games/hilo.txt", "r") as f:
data = f.read()
if os.path.exists("resources/games/blackjackCards/"+str(message.channel)+".txt"):
with open("resources/games/hilo/"+str(message.channel)+".txt", "r") as f:
data = f.read()
else:
data = "0"
await message.channel.send(data)
# Shuffles the blackjack deck
elif content.startswith("blackjack shuffle"):
blackjackShuffle(blackjackDecks)
blackjackShuffle(blackjackDecks,str(message.channel))
logThis("Shuffling the blackjack deck...",str(message.channel))
await message.channel.send("Shuffling the deck...")
# Tells you the amount of cards left
elif content.startswith("blackjack cards"):
cardsLeft = 0
with open("resources/games/blackjackCards.txt","r") as f:
for line in f:
cardsLeft += 1
if os.path.exists("resources/games/blackjackCards/"+str(message.channel)+".txt"):
with open("resources/games/blackjackCards/"+str(message.channel)+".txt","r") as f:
for line in f:
cardsLeft += 1
decksLeft = round(cardsLeft/52,1)
await message.channel.send(str(cardsLeft)+" cards, "+str(decksLeft)+" decks")
@ -618,9 +626,6 @@ async def parseCommands(message,content):
# Makes files if they don't exist yet
makeFiles()
# Shuffling cards
blackjackShuffle(4)
# Gets secret bot token
with open("token.txt","r") as f:
token = f.read().replace("\n","")