🃏 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

@ -0,0 +1,41 @@
import json
from PIL import Image
def drawImage(channel):
with open("resources/games/games.json", "r") as f:
data = json.load(f)
if data["blackjack games"][channel]["all standing"] == False:
dealerHand = drawHand(data["blackjack games"][channel]["dealer hand"],True)
else:
dealerHand = drawHand(data["blackjack games"][channel]["dealer hand"],False)
table = Image.open("resources/games/blackjackTable.png")
table.paste(dealerHand,(800,20),dealerHand)
for x in range(len(data["blackjack games"][channel]["user hands"])):
userHand = drawHand(list(data["blackjack games"][channel]["user hands"].values())[x]["hand"],False)
table.paste(userHand,(32+(384*x),700),userHand)
table.save("resources/games/tables/blackjackTable"+channel+".png")
return
def drawHand(hand, dealer):
length = len(hand)
background = Image.new("RGBA", (691+(125*(length-1)),1065),(0,0,0,0))
if dealer:
img = Image.open("resources/games/cards/"+hand[0].upper()+".png")
background.paste(img,(0,0),img)
img = Image.open("resources/games/cards/red_back.png")
background.paste(img,(125,0),img)
else:
for x in range(length):
img = Image.open("resources/games/cards/"+hand[x].upper()+".png")
background.paste(img,(x*125,0),img)
w, h = background.size
return background.resize((int(w/4),int(h/4)))