nesau
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
from .util import (base64, FONT_SIZE, FONT_COLOR, IMAGE_BACKGROUND, IMAGE_SIZE,
|
||||
MARGINS, FONTS, read_file, write_file)
|
||||
MARGINS, FONTS, read_file, write_file, gen_id)
|
||||
from . import images
|
||||
from . import web
|
||||
from . import game
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,19 +1,15 @@
|
||||
import random
|
||||
import time
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
from font_game.images import gen_image
|
||||
from font_game import base64, FONTS, read_file, write_file
|
||||
from font_game import gen_id, FONTS, read_file, write_file
|
||||
|
||||
def purge_games():
|
||||
for root, _, files in os.walk("current_games"):
|
||||
for file in files:
|
||||
os.remove(os.path.join(root, file))
|
||||
|
||||
def gen_id():
|
||||
return base64(int(time.time()*10000))
|
||||
|
||||
def pick_fonts(game_length: int):
|
||||
weights = {key: 100 for key in FONTS}
|
||||
font_list = []
|
||||
@ -32,7 +28,6 @@ def start_game(game_length: int = 10) -> str:
|
||||
|
||||
game_id = gen_id()
|
||||
|
||||
|
||||
game_dict = {
|
||||
"points": "0",
|
||||
"i": "0",
|
||||
|
@ -1,9 +1,8 @@
|
||||
import os
|
||||
import time
|
||||
from PIL import Image, ImageFont, ImageDraw
|
||||
import lorem
|
||||
|
||||
from font_game import base64, IMAGE_SIZE, IMAGE_BACKGROUND, MARGINS, FONT_COLOR
|
||||
from font_game import gen_id, IMAGE_SIZE, IMAGE_BACKGROUND, MARGINS, FONT_COLOR
|
||||
|
||||
def gen_image(font: ImageFont.ImageFont) -> str:
|
||||
img = Image.new("RGB", IMAGE_SIZE, IMAGE_BACKGROUND)
|
||||
@ -29,7 +28,7 @@ def gen_image(font: ImageFont.ImageFont) -> str:
|
||||
spacing=30
|
||||
)
|
||||
|
||||
filename = base64(int(time.time() * 10000) % 0xffffff)
|
||||
filename = gen_id()
|
||||
|
||||
path = f"static/images/{filename}.png"
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import string
|
||||
import pathlib
|
||||
import time
|
||||
from PIL import ImageFont
|
||||
|
||||
BASE64_DIGITS = string.digits + string.ascii_letters + "+_"
|
||||
@ -29,12 +30,18 @@ def write_file(path: str, game: dict):
|
||||
|
||||
def base64(num: int) -> str:
|
||||
temp = ""
|
||||
while num > 0:
|
||||
for _ in range(10):
|
||||
temp = BASE64_DIGITS[num % 64] + temp
|
||||
num = num//64
|
||||
|
||||
if num > 0:
|
||||
raise Exception()
|
||||
|
||||
return temp
|
||||
|
||||
def gen_id() -> str:
|
||||
micro_seconds = int(time.time() * 1000000)
|
||||
return base64((micro_seconds * 9876534021204356789) % 0xfffffffffffffff)
|
||||
|
||||
def make_fonts():
|
||||
with open("font-list.txt", "r", encoding="utf-8") as file_pointer:
|
||||
|
@ -66,3 +66,7 @@ def start():
|
||||
|
||||
game_id = start_game(game_length)
|
||||
return flask.redirect(f"/fontgame?id={game_id}")
|
||||
|
||||
@app.route("/all")
|
||||
def all_fonts():
|
||||
pass
|
||||
|
Reference in New Issue
Block a user