This commit is contained in:
NikolajDanger
2020-08-20 15:28:43 +02:00
parent f9cfe77d86
commit 0e4bdea3c7
3 changed files with 49 additions and 24 deletions

View File

@ -5,10 +5,11 @@ from funcs import logThis
from PIL import Image, ImageDraw
w, h = 1440, 1440
largeSpace = 191
largeSpace = 190
smallSpace = math.floor((w - 2*largeSpace)/9)
avatarSize = 50
avatarHalf = math.floor(avatarSize/2)
avatarBuffer = 10
class DrawMonopoly():
def __init__(self,bot):
@ -20,19 +21,27 @@ class DrawMonopoly():
board = Image.open("resources/games/monopolyBoard.png")
d = ImageDraw.Draw(board,"RGBA")
places = {}
for key, value in list(game["players"].items()):
logThis("Drawing "+key)
try:
x, y = self.getPosition(value["position"])
except:
logThis("Error getting position (error code 1641)")
d.ellipse([(x-avatarHalf,y-avatarHalf),(x+avatarHalf,y+avatarHalf)],fill=(255,0,0))
if value["position"] in places:
places[value["position"]].append(key)
else:
places[value["position"]] = [key]
for key, value in list(places.items()):
for number, player in enumerate(value):
try:
x, y = self.getPosition(key,number)
except:
logThis("Error getting position (error code 1641)")
d.ellipse([(x-avatarHalf,y-avatarHalf),(x+avatarHalf,y+avatarHalf)],fill=(255,0,0))
board.save("resources/games/monopolyBoards/monopolyBoard"+channel+".png")
def getPosition(self, positionNumber):
def getPosition(self, positionNumber, number):
x, y = 0, 0
if positionNumber == 0 or positionNumber >= 30:
x = math.floor(largeSpace/2)
@ -52,6 +61,16 @@ class DrawMonopoly():
elif positionNumber > 30:
y = h - math.floor(largeSpace - (smallSpace/2)) - (smallSpace*(positionNumber - 30))
if number%2 == 1:
x -= avatarBuffer + avatarSize
if math.floor(number/2) == 1:
y += avatarBuffer + avatarSize
elif math.floor(number/2) == 2:
y -= avatarBuffer + avatarSize
x += avatarSize
return x, y