✨ Fully converted to slash commands
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import math
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from funcs import logThis
|
||||
|
||||
# Defining all the variables
|
||||
CANVAS_WIDTH = 2400
|
||||
@ -13,7 +12,7 @@ HEXAGONWIDTH = math.sqrt(3) * SIDELENGTH # the whole width of one hexagon
|
||||
HEXAGONHEIGHT = 1.5 * SIDELENGTH # not really the entire height, but the height difference between two layers
|
||||
FONTSIZE = 45
|
||||
TEXTCOLOR = (0,0,0)
|
||||
fnt = ImageFont.truetype('resources/futura-bold.ttf', FONTSIZE)
|
||||
fnt = ImageFont.truetype('resources/fonts/futura-bold.ttf', FONTSIZE)
|
||||
|
||||
LINETHICKNESS = 15
|
||||
HEXTHICKNESS = 6 # This is half the width of the background lining between every hex
|
||||
@ -29,7 +28,7 @@ COLX_THICKNESS = COLHEXTHICKNESS * math.cos(math.pi/6)
|
||||
COLY_THICKNESS = COLHEXTHICKNESS * math.sin(math.pi/6)
|
||||
# The Name display things:
|
||||
NAMESIZE = 60
|
||||
NAME_fnt = ImageFont.truetype('resources/futura-bold.ttf', NAMESIZE)
|
||||
NAME_fnt = ImageFont.truetype('resources/fonts/futura-bold.ttf', NAMESIZE)
|
||||
X_NAME = {1:175, 2:CANVAS_WIDTH-100}
|
||||
Y_NAME = {1:CANVAS_HEIGHT-150, 2:150}
|
||||
NAMEHEXPADDING = 90
|
||||
@ -41,7 +40,7 @@ class DrawHex():
|
||||
self.bot = bot
|
||||
|
||||
def drawBoard(self, channel):
|
||||
logThis("Drawing empty Hex board")
|
||||
self.bot.log("Drawing empty Hex board")
|
||||
|
||||
# Creates the empty image
|
||||
im = Image.new('RGB', size=(CANVAS_WIDTH, CANVAS_HEIGHT),color = BACKGROUND_COLOR)
|
||||
@ -99,7 +98,7 @@ class DrawHex():
|
||||
game = self.bot.database["hex games"].find_one({"_id":channel})
|
||||
|
||||
for p in [1,2]:
|
||||
playername = self.bot.funcs.getName(game["players"][p-1])
|
||||
playername = self.bot.databaseFuncs.getName(game["players"][p-1])
|
||||
# Draw name
|
||||
x = X_NAME[p]
|
||||
x -= NAME_fnt.getsize(playername)[0] if p==2 else 0 # player2's name is right-aligned
|
||||
@ -123,7 +122,7 @@ class DrawHex():
|
||||
|
||||
def drawHexPlacement(self, channel,player,position):
|
||||
FILEPATH = "resources/games/hexBoards/board"+channel+".png"
|
||||
logThis("Drawing a newly placed hex. Filepath: "+FILEPATH)
|
||||
self.bot.log("Drawing a newly placed hex. Filepath: "+FILEPATH)
|
||||
|
||||
# Translates position
|
||||
# We don't need to error-check, because the position is already checked in placeOnHexBoard()
|
||||
@ -151,7 +150,7 @@ class DrawHex():
|
||||
# Save
|
||||
im.save(FILEPATH)
|
||||
except:
|
||||
logThis("Error drawing new hex on board (error code 1541")
|
||||
self.bot.log("Error drawing new hex on board (error code 1541")
|
||||
|
||||
def drawSwap(self, channel):
|
||||
FILEPATH = "resources/games/hexBoards/board"+channel+".png"
|
||||
@ -163,7 +162,7 @@ class DrawHex():
|
||||
|
||||
# Write player names and color
|
||||
for p in [1,2]:
|
||||
playername = self.bot.funcs.getName(game["players"][p%2])
|
||||
playername = self.bot.databaseFuncs.getName(game["players"][p%2])
|
||||
|
||||
x = X_NAME[p]
|
||||
x -= NAME_fnt.getsize(playername)[0] if p==2 else 0 # player2's name is right-aligned
|
||||
@ -183,4 +182,4 @@ class DrawHex():
|
||||
# Save
|
||||
im.save(FILEPATH)
|
||||
except:
|
||||
logThis("Error drawing swap (error code 1542)")
|
||||
self.bot.log("Error drawing swap (error code 1542)")
|
||||
|
Reference in New Issue
Block a user