🗃️ UserID's instead of display names

This commit is contained in:
Nikolaj Danger
2020-08-04 16:59:13 +02:00
parent 4bcc8cbf59
commit 2ea11eb51f
11 changed files with 201 additions and 111 deletions

View File

@ -2,7 +2,7 @@ import json
import math
from PIL import Image, ImageDraw, ImageFont
from funcs import logThis
from funcs import logThis, getName
# Draws the whole thing
def drawImage(channel):
@ -32,6 +32,16 @@ def drawImage(channel):
pieceStartx = (border+gridBorder)+math.floor(placeGridSize[0]/2)-math.floor(placeSize/2)
pieceStarty = (border+gridBorder)+math.floor(placeGridSize[1]/2)-math.floor(placeSize/2)
if data["4 in a row games"][channel]["players"][0] == "Gwendolyn":
player1 = "Gwendolyn"
else:
player1 = getName(data["4 in a row games"][channel]["players"][0])
if data["4 in a row games"][channel]["players"][1] == "Gwendolyn":
player2 = "Gwendolyn"
else:
player2 = getName(data["4 in a row games"][channel]["players"][1])
background = Image.new("RGB", (w,h+bottomBorder),backgroundColor)
d = ImageDraw.Draw(background,"RGBA")
@ -124,11 +134,11 @@ def drawImage(channel):
exampleHeight = h - border + int((bottomBorder+border)/2) - int(exampleCircles/2)
d.ellipse([(border,exampleHeight),(border+exampleCircles),(exampleHeight+exampleCircles)],fill=(255,255,0),outline=(0,0,0),width=3)
d.text((border+exampleCircles+textPadding,exampleHeight),data["4 in a row games"][channel]["players"][0],font=fnt,fill=(0,0,0))
d.text((border+exampleCircles+textPadding,exampleHeight),player1,font=fnt,fill=(0,0,0))
textWidth = fnt.getsize(data["4 in a row games"][channel]["players"][1])[0]
textWidth = fnt.getsize(player2)[0]
d.ellipse([(w-border-exampleCircles-textWidth-textPadding,exampleHeight),(w-border-textWidth-textPadding),(exampleHeight+exampleCircles)],fill=(255,0,0),outline=(0,0,0),width=3)
d.text((w-border-textWidth,exampleHeight),data["4 in a row games"][channel]["players"][1],font=fnt,fill=(0,0,0))
d.text((w-border-textWidth,exampleHeight),player2,font=fnt,fill=(0,0,0))
background.save("resources/games/4InARowBoards/board"+channel+".png")