🃏 Created blackjack game
This commit is contained in:
41
funcs/games/blackjackDraw.py
Normal file
41
funcs/games/blackjackDraw.py
Normal 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)))
|
Reference in New Issue
Block a user