🃏 Created blackjack game

This commit is contained in:
NikolajDanger
2020-07-28 01:58:04 +02:00
parent 5c31877656
commit 3db053be12
69 changed files with 530 additions and 24 deletions

View File

@ -8,6 +8,7 @@ import imdb # Used by movieFunc
import time # Used for logging
import logging # Used for... you know... logging
import wikia # Used by findWikiPage
import os
from .roll import dice
@ -139,14 +140,26 @@ def makeFiles():
# Creates games.json if it doesn't exist
try:
f = open("resources/games.json","r")
f = open("resources/games/games.json","r")
except:
logThis("games.json didn't exist. Making it now.")
data = {"trivia questions":{},"users":{}}
with open("resources/games.json","w") as f:
data = {"trivia questions":{},"blackjack games":{},"users":{}}
with open("resources/games/games.json","w") as f:
json.dump(data,f,indent = 4)
finally:
f.close()
# Creates blackjackCards.txt if it doesn't exist
try:
f = open("resources/games/blackjackCards.txt","r")
except:
logThis("blackjackCards.txt didn't exist. Making it now.")
data = ""
with open("resources/games/blackjackCards.txt","w") as f:
f.write(data)
finally:
f.close()
# Creates destinyPoints.txt if it doesn't exist
try:
@ -168,4 +181,21 @@ def makeFiles():
f.write(token)
finally:
f.close()
f.close()
try:
os.makedirs("resources/games/tables")
logThis("The tables directory didn't exist")
except:
logThis("The tables directory existed")
def replaceMultiple(mainString, toBeReplaces, newString):
# Iterate over the strings to be replaced
for elem in toBeReplaces :
# Check if string is in the main string
if elem in mainString :
# Replace the string
mainString = mainString.replace(elem, newString)
return mainString