some things
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
import random
|
||||
import time
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
from font_game.images import gen_image
|
||||
from font_game import base64, FONTS
|
||||
from font_game import base64, FONTS, read_file, write_file
|
||||
|
||||
def purge_games():
|
||||
for root, _, files in os.walk("current_games"):
|
||||
@ -45,3 +46,16 @@ def start_game(game_length: int = 10) -> str:
|
||||
file.write(game)
|
||||
|
||||
return game_id
|
||||
|
||||
def test_game(game_id: str):
|
||||
return pathlib.Path(f"current_games/{game_id}").is_file()
|
||||
|
||||
def guess_font(game_id: str, font_guess: str):
|
||||
game_dict = read_file(f"current_games/{game_id}")
|
||||
i = int(game_dict['i'])
|
||||
font = game_dict['fonts'].split(',')[i]
|
||||
if font_guess == font:
|
||||
game_dict['points'] = str(int(game_dict['points']) + 1)
|
||||
|
||||
game_dict['i'] = str(i+1)
|
||||
write_file(f"current_games/{game_id}", game_dict)
|
||||
|
Reference in New Issue
Block a user