Black and isort final run
This commit is contained in:
parent
d318ce41a4
commit
8f8e951153
13 changed files with 261 additions and 125 deletions
Binary file not shown.
|
@ -7,8 +7,9 @@ import maze.modules.maze_saveandload as sl
|
||||||
import maze.modules.PlayerBase_func as database
|
import maze.modules.PlayerBase_func as database
|
||||||
import pong
|
import pong
|
||||||
import snake
|
import snake
|
||||||
from maze.modules.about import about
|
|
||||||
import wordle.wordle as wordlegame
|
import wordle.wordle as wordlegame
|
||||||
|
from maze.modules.about import about
|
||||||
|
|
||||||
|
|
||||||
def menu(screen):
|
def menu(screen):
|
||||||
exit = False
|
exit = False
|
||||||
|
|
|
@ -106,9 +106,13 @@ def screenhandler(screen): # MAIN MENU
|
||||||
global loggedin, U, gamerid
|
global loggedin, U, gamerid
|
||||||
screen.clear()
|
screen.clear()
|
||||||
screen.refresh()
|
screen.refresh()
|
||||||
screen.addstr(1, w // 2 - 8, "ACCOUNT SETTINGS", curses.color_pair(3) | curses.A_BOLD)
|
screen.addstr(
|
||||||
|
1, w // 2 - 8, "ACCOUNT SETTINGS", curses.color_pair(3) | curses.A_BOLD
|
||||||
|
)
|
||||||
if loggedin:
|
if loggedin:
|
||||||
screen.addstr(2, w // 2 - 8, f"Logged in as: {U}", curses.color_pair(6) | curses.A_BOLD)
|
screen.addstr(
|
||||||
|
2, w // 2 - 8, f"Logged in as: {U}", curses.color_pair(6) | curses.A_BOLD
|
||||||
|
)
|
||||||
screen.addstr(h // 2 - 3, w // 2 - 4, "1. Login")
|
screen.addstr(h // 2 - 3, w // 2 - 4, "1. Login")
|
||||||
screen.addstr(h // 2 - 2, w // 2 - 8, "2. Create Account")
|
screen.addstr(h // 2 - 2, w // 2 - 8, "2. Create Account")
|
||||||
screen.addstr(h // 2 - 1, w // 2 - 12, "3. Modify account details")
|
screen.addstr(h // 2 - 1, w // 2 - 12, "3. Modify account details")
|
||||||
|
@ -253,9 +257,19 @@ def login(screen, calledby=None): # Function to log in
|
||||||
loggedin = True
|
loggedin = True
|
||||||
gamerid = res[0][1]
|
gamerid = res[0][1]
|
||||||
U = inputU
|
U = inputU
|
||||||
screen.addstr(y // 2 + 3, x // 2 - 9, "Login Successful!", curses.color_pair(6) | curses.A_BOLD)
|
screen.addstr(
|
||||||
|
y // 2 + 3,
|
||||||
|
x // 2 - 9,
|
||||||
|
"Login Successful!",
|
||||||
|
curses.color_pair(6) | curses.A_BOLD,
|
||||||
|
)
|
||||||
if calledby is not None:
|
if calledby is not None:
|
||||||
screen.addstr(y // 2 + 4, x // 2 - 8, "Updating score...", curses.color_pair(6) | curses.A_BOLD)
|
screen.addstr(
|
||||||
|
y // 2 + 4,
|
||||||
|
x // 2 - 8,
|
||||||
|
"Updating score...",
|
||||||
|
curses.color_pair(6) | curses.A_BOLD,
|
||||||
|
)
|
||||||
screen.refresh()
|
screen.refresh()
|
||||||
sleep(3)
|
sleep(3)
|
||||||
Update_score(calledby[0], calledby[1])
|
Update_score(calledby[0], calledby[1])
|
||||||
|
@ -397,7 +411,9 @@ def new_add(screen, calledby=None):
|
||||||
screen.border()
|
screen.border()
|
||||||
y, x = screen.getmaxyx()
|
y, x = screen.getmaxyx()
|
||||||
global quitting
|
global quitting
|
||||||
screen.addstr(1, x // 2 - 8, "ACCOUNT CREATION", curses.color_pair(3) | curses.A_BOLD)
|
screen.addstr(
|
||||||
|
1, x // 2 - 8, "ACCOUNT CREATION", curses.color_pair(3) | curses.A_BOLD
|
||||||
|
)
|
||||||
add_name = user(
|
add_name = user(
|
||||||
screen, y // 2 - 4, x // 2 - 10
|
screen, y // 2 - 4, x // 2 - 10
|
||||||
) # calling fn user for username, password and email
|
) # calling fn user for username, password and email
|
||||||
|
@ -452,7 +468,9 @@ def modify_account(screen):
|
||||||
screen.border()
|
screen.border()
|
||||||
y, x = screen.getmaxyx()
|
y, x = screen.getmaxyx()
|
||||||
global loggedin, quitting, U
|
global loggedin, quitting, U
|
||||||
screen.addstr(1, x // 2 - 8, "MODIFY ACCOUNT SETTINGS", curses.color_pair(3) | curses.A_BOLD)
|
screen.addstr(
|
||||||
|
1, x // 2 - 8, "MODIFY ACCOUNT SETTINGS", curses.color_pair(3) | curses.A_BOLD
|
||||||
|
)
|
||||||
if loggedin == False:
|
if loggedin == False:
|
||||||
screen.addstr(
|
screen.addstr(
|
||||||
y // 2,
|
y // 2,
|
||||||
|
@ -522,7 +540,9 @@ def view_account(screen):
|
||||||
screen.clear()
|
screen.clear()
|
||||||
screen.refresh()
|
screen.refresh()
|
||||||
screen.border()
|
screen.border()
|
||||||
screen.addstr(1, x // 2 - 9, "VIEW ACCOUNT DETAILS", curses.color_pair(3) | curses.A_BOLD)
|
screen.addstr(
|
||||||
|
1, x // 2 - 9, "VIEW ACCOUNT DETAILS", curses.color_pair(3) | curses.A_BOLD
|
||||||
|
)
|
||||||
if not loggedin:
|
if not loggedin:
|
||||||
screen.addstr(
|
screen.addstr(
|
||||||
y // 2,
|
y // 2,
|
||||||
|
@ -540,16 +560,32 @@ def view_account(screen):
|
||||||
)
|
)
|
||||||
screen.addstr(3, x // 2 - 7, "Gamer ID: " + player_details[0][0])
|
screen.addstr(3, x // 2 - 7, "Gamer ID: " + player_details[0][0])
|
||||||
screen.addstr(5, x // 2 - 8, "Username: " + player_details[0][1])
|
screen.addstr(5, x // 2 - 8, "Username: " + player_details[0][1])
|
||||||
screen.addstr(7, x// 2 - 9, "Email: " + player_details[0][2])
|
screen.addstr(7, x // 2 - 9, "Email: " + player_details[0][2])
|
||||||
j = 0
|
j = 0
|
||||||
for i, tablename in enumerate(["maze_scores", "pong_scores", "snake_scores", "wordle_scores"]):
|
for i, tablename in enumerate(
|
||||||
|
["maze_scores", "pong_scores", "snake_scores", "wordle_scores"]
|
||||||
|
):
|
||||||
score_details = get(f"SELECT * FROM {tablename} WHERE gamerid = '{gamerid}'")
|
score_details = get(f"SELECT * FROM {tablename} WHERE gamerid = '{gamerid}'")
|
||||||
if not score_details:
|
if not score_details:
|
||||||
score_details.append(("Bruh",) + ("Not yet available.",) * 3)
|
score_details.append(("Bruh",) + ("Not yet available.",) * 3)
|
||||||
screen.addstr(8 + 3 * i + j + 1, x // 2 - 15, f"{tablename.split('_')[0].capitalize()}: ", curses.color_pair(3))
|
screen.addstr(
|
||||||
screen.addstr(8 + 3 * i + 1 + j, x // 2 - 7, "High Score: " + str(score_details[0][1]), curses.color_pair(2))
|
8 + 3 * i + j + 1,
|
||||||
screen.addstr(9 + 3 * i + 1 + j, x // 2 - 7, "Last Played: " + str(score_details[0][2]))
|
x // 2 - 15,
|
||||||
screen.addstr(10 + 3 * i + 1 + j, x // 2 - 7, "Times Played: " + str(score_details[0][3]))
|
f"{tablename.split('_')[0].capitalize()}: ",
|
||||||
|
curses.color_pair(3),
|
||||||
|
)
|
||||||
|
screen.addstr(
|
||||||
|
8 + 3 * i + 1 + j,
|
||||||
|
x // 2 - 7,
|
||||||
|
"High Score: " + str(score_details[0][1]),
|
||||||
|
curses.color_pair(2),
|
||||||
|
)
|
||||||
|
screen.addstr(
|
||||||
|
9 + 3 * i + 1 + j, x // 2 - 7, "Last Played: " + str(score_details[0][2])
|
||||||
|
)
|
||||||
|
screen.addstr(
|
||||||
|
10 + 3 * i + 1 + j, x // 2 - 7, "Times Played: " + str(score_details[0][3])
|
||||||
|
)
|
||||||
j += 1
|
j += 1
|
||||||
|
|
||||||
screen.addstr(y - 1, 5, "Press esc to return to main menu.")
|
screen.addstr(y - 1, 5, "Press esc to return to main menu.")
|
||||||
|
@ -605,13 +641,15 @@ def delete(screen):
|
||||||
|
|
||||||
|
|
||||||
def Update_score(score, game):
|
def Update_score(score, game):
|
||||||
tablename = game + '_scores'
|
tablename = game + "_scores"
|
||||||
global U, gamerid, loggedin
|
global U, gamerid, loggedin
|
||||||
if not loggedin:
|
if not loggedin:
|
||||||
return "guest"
|
return "guest"
|
||||||
res = get(f"SELECT * FROM {tablename} WHERE gamerid = '{gamerid}'")
|
res = get(f"SELECT * FROM {tablename} WHERE gamerid = '{gamerid}'")
|
||||||
if not res:
|
if not res:
|
||||||
post(f"INSERT INTO {tablename} (gamerid, highscore, lastscore, timesplayed) VALUES ('{gamerid}',0, 0, 0)")
|
post(
|
||||||
|
f"INSERT INTO {tablename} (gamerid, highscore, lastscore, timesplayed) VALUES ('{gamerid}',0, 0, 0)"
|
||||||
|
)
|
||||||
res = get(f"SELECT * FROM {tablename} WHERE gamerid = '{gamerid}'")
|
res = get(f"SELECT * FROM {tablename} WHERE gamerid = '{gamerid}'")
|
||||||
# implement to ask whether to update
|
# implement to ask whether to update
|
||||||
if res[0][1] < score:
|
if res[0][1] < score:
|
||||||
|
@ -646,7 +684,9 @@ def forgotpassword(screen):
|
||||||
screen.clear()
|
screen.clear()
|
||||||
screen.refresh()
|
screen.refresh()
|
||||||
y, x = screen.getmaxyx()
|
y, x = screen.getmaxyx()
|
||||||
screen.addstr(1, x // 2 - 7, "FORGOT PASSWORD", curses.color_pair(3) | curses.A_BOLD)
|
screen.addstr(
|
||||||
|
1, x // 2 - 7, "FORGOT PASSWORD", curses.color_pair(3) | curses.A_BOLD
|
||||||
|
)
|
||||||
screen.refresh()
|
screen.refresh()
|
||||||
global quitting
|
global quitting
|
||||||
usernamelist = list_getter("username")
|
usernamelist = list_getter("username")
|
||||||
|
@ -770,7 +810,7 @@ def logout(screen):
|
||||||
y, x = screen.getmaxyx()
|
y, x = screen.getmaxyx()
|
||||||
screen.clear()
|
screen.clear()
|
||||||
screen.refresh()
|
screen.refresh()
|
||||||
scree.border()
|
screen.border()
|
||||||
screen.addstr(1, x // 2 - 2, "LOGOUT", curses.color_pair(3) | curses.A_BOLD)
|
screen.addstr(1, x // 2 - 2, "LOGOUT", curses.color_pair(3) | curses.A_BOLD)
|
||||||
screen.addstr(y // 2, 5, "Logging out of your account...")
|
screen.addstr(y // 2, 5, "Logging out of your account...")
|
||||||
global loggedin, U, gamerid
|
global loggedin, U, gamerid
|
||||||
|
@ -790,14 +830,21 @@ def leaderboard(screen):
|
||||||
curses.init_pair(6, curses.COLOR_CYAN, curses.COLOR_BLACK)
|
curses.init_pair(6, curses.COLOR_CYAN, curses.COLOR_BLACK)
|
||||||
screen.keypad(True)
|
screen.keypad(True)
|
||||||
leaderboardquit = True
|
leaderboardquit = True
|
||||||
tables = {0:"maze_scores", 1:"pong_scores", 2:"snake_scores", 3:"wordle_scores"}
|
tables = {0: "maze_scores", 1: "pong_scores", 2: "snake_scores", 3: "wordle_scores"}
|
||||||
current_page = 0
|
current_page = 0
|
||||||
while leaderboardquit:
|
while leaderboardquit:
|
||||||
screen.clear()
|
screen.clear()
|
||||||
screen.border()
|
screen.border()
|
||||||
screen.refresh()
|
screen.refresh()
|
||||||
screen.addstr(1, x // 2 - 5, "LEADERBOARD", curses.color_pair(3) | curses.A_BOLD)
|
screen.addstr(
|
||||||
screen.addstr(3, x // 2 - 2, f"{tables[current_page].split('_')[0].upper()}", curses.color_pair(6) | curses.A_BOLD)
|
1, x // 2 - 5, "LEADERBOARD", curses.color_pair(3) | curses.A_BOLD
|
||||||
|
)
|
||||||
|
screen.addstr(
|
||||||
|
3,
|
||||||
|
x // 2 - 2,
|
||||||
|
f"{tables[current_page].split('_')[0].upper()}",
|
||||||
|
curses.color_pair(6) | curses.A_BOLD,
|
||||||
|
)
|
||||||
res = get(
|
res = get(
|
||||||
f"SELECT p.gamerid,\
|
f"SELECT p.gamerid,\
|
||||||
p.username,\
|
p.username,\
|
||||||
|
@ -807,7 +854,7 @@ def leaderboard(screen):
|
||||||
WHERE p.gamerid = s.gamerid "
|
WHERE p.gamerid = s.gamerid "
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(len(res) - 1): # Sorting
|
for i in range(len(res) - 1): # Sorting
|
||||||
for j in range(len(res) - 1 - i):
|
for j in range(len(res) - 1 - i):
|
||||||
if res[j][2] < res[j + 1][2]:
|
if res[j][2] < res[j + 1][2]:
|
||||||
res[j], res[j + 1] = res[j + 1], res[j]
|
res[j], res[j + 1] = res[j + 1], res[j]
|
||||||
|
@ -822,7 +869,9 @@ def leaderboard(screen):
|
||||||
screen.addstr(sy, 50, str(i[2]), curses.color_pair(2) | curses.A_BOLD)
|
screen.addstr(sy, 50, str(i[2]), curses.color_pair(2) | curses.A_BOLD)
|
||||||
sy += 1
|
sy += 1
|
||||||
screen.addstr(y - 2, 2, "Use arrow keys for different pages.", curses.A_DIM)
|
screen.addstr(y - 2, 2, "Use arrow keys for different pages.", curses.A_DIM)
|
||||||
screen.addstr(y - 2, x - 36, "Press [esc] to return to main menu.", curses.A_DIM)
|
screen.addstr(
|
||||||
|
y - 2, x - 36, "Press [esc] to return to main menu.", curses.A_DIM
|
||||||
|
)
|
||||||
while True:
|
while True:
|
||||||
key = screen.getch()
|
key = screen.getch()
|
||||||
if key == 27:
|
if key == 27:
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import maze.menu
|
|
||||||
import curses
|
import curses
|
||||||
|
|
||||||
|
import maze.menu
|
||||||
|
|
||||||
|
|
||||||
def about(screen):
|
def about(screen):
|
||||||
y, x = screen.getmaxyx()
|
y, x = screen.getmaxyx()
|
||||||
screen.clear()
|
screen.clear()
|
||||||
|
@ -21,9 +23,13 @@ def about(screen):
|
||||||
"There are a series of retro games namely the maze, pong, snake and wordle.",
|
"There are a series of retro games namely the maze, pong, snake and wordle.",
|
||||||
)
|
)
|
||||||
screen.addstr(
|
screen.addstr(
|
||||||
10, 5, "The maze is generated which always has a path towards the right bottom corner by using "
|
10,
|
||||||
|
5,
|
||||||
|
"The maze is generated which always has a path towards the right bottom corner by using ",
|
||||||
|
)
|
||||||
|
screen.addstr(
|
||||||
|
11, 5, "a famous generation algorithm named Depth First Search (DFS)."
|
||||||
)
|
)
|
||||||
screen.addstr(11, 5, "a famous generation algorithm named Depth First Search (DFS).")
|
|
||||||
screen.addstr(
|
screen.addstr(
|
||||||
13,
|
13,
|
||||||
5,
|
5,
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import curses
|
import curses
|
||||||
import random
|
import random
|
||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from itertools import tee
|
from itertools import tee
|
||||||
|
@ -253,8 +252,8 @@ def pathfinding_demo(
|
||||||
reset(finish, cell, curses.color_pair(2))
|
reset(finish, cell, curses.color_pair(2))
|
||||||
reset(start, (0, 0), curses.color_pair(2))
|
reset(start, (0, 0), curses.color_pair(2))
|
||||||
else:
|
else:
|
||||||
current_coords = [maxy - 5, maxx - 27]
|
# current_coords = [maxy - 5, maxx - 27]
|
||||||
# current_coords = [1, 1]
|
current_coords = [1, 1]
|
||||||
screen.addstr(current_coords[0], current_coords[1], "█", curses.color_pair(2))
|
screen.addstr(current_coords[0], current_coords[1], "█", curses.color_pair(2))
|
||||||
WALL = ["═", "║", "╗", "╚", "╝", "╔", "╠", "╣", "╦", "╩", "╬", "═", "═", "║", "║"]
|
WALL = ["═", "║", "╗", "╚", "╝", "╔", "╠", "╣", "╦", "╩", "╬", "═", "═", "║", "║"]
|
||||||
pause_elapsed = 0
|
pause_elapsed = 0
|
||||||
|
@ -297,12 +296,7 @@ def pathfinding_demo(
|
||||||
\t\t\t ████ ██ ██ ██ ██ ██ █ ██ ██ ██ ██ ██ ██ ██
|
\t\t\t ████ ██ ██ ██ ██ ██ █ ██ ██ ██ ██ ██ ██ ██
|
||||||
\t\t\t ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██
|
\t\t\t ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██
|
||||||
\t\t\t ██ ██████ ██████ ███ ███ ██████ ██ ████ ██"""
|
\t\t\t ██ ██████ ██████ ███ ███ ██████ ██ ████ ██"""
|
||||||
screen.addstr(
|
screen.addstr(maxy // 2 - 5, maxx // 2 - 31, winmsg, curses.color_pair(5))
|
||||||
maxy // 2 - 5,
|
|
||||||
maxx // 2 - 31,
|
|
||||||
winmsg,
|
|
||||||
curses.color_pair(5)
|
|
||||||
)
|
|
||||||
screen.border()
|
screen.border()
|
||||||
screen.refresh()
|
screen.refresh()
|
||||||
global WON
|
global WON
|
||||||
|
@ -416,7 +410,7 @@ def play(
|
||||||
loadedtime=0,
|
loadedtime=0,
|
||||||
executeguest=False,
|
executeguest=False,
|
||||||
outerscore=0,
|
outerscore=0,
|
||||||
outergame=False
|
outergame=False,
|
||||||
):
|
):
|
||||||
y, x = screen.getmaxyx()
|
y, x = screen.getmaxyx()
|
||||||
height, width = int((y - 2) / 2), int((x - 2) / 2)
|
height, width = int((y - 2) / 2), int((x - 2) / 2)
|
||||||
|
@ -425,18 +419,25 @@ def play(
|
||||||
screen.clear()
|
screen.clear()
|
||||||
screen.refresh()
|
screen.refresh()
|
||||||
screen.border()
|
screen.border()
|
||||||
screen.addstr(y // 2 - 5, x // 2 - 7, str("Your score is: " + str(int(score))), curses.color_pair(3) | curses.A_BOLD)
|
screen.addstr(
|
||||||
|
y // 2 - 5,
|
||||||
|
x // 2 - 7,
|
||||||
|
str("Your score is: " + str(int(score))),
|
||||||
|
curses.color_pair(3) | curses.A_BOLD,
|
||||||
|
)
|
||||||
res = database.Update_score(int(score), game)
|
res = database.Update_score(int(score), game)
|
||||||
if res == "guest":
|
if res == "guest":
|
||||||
screen.addstr(
|
screen.addstr(
|
||||||
height - 1,
|
height - 1,
|
||||||
31,
|
31,
|
||||||
"You are not signed in. You will lose your score if you proceed.",
|
"You are not signed in. You will lose your score if you proceed.",
|
||||||
curses.color_pair(1) | curses.A_BOLD
|
curses.color_pair(1) | curses.A_BOLD,
|
||||||
)
|
)
|
||||||
screen.addstr(
|
screen.addstr(
|
||||||
height, 37, "Do you want to login and save your progress? (y/n)",
|
height,
|
||||||
curses.color_pair(1) | curses.A_BOLD
|
37,
|
||||||
|
"Do you want to login and save your progress? (y/n)",
|
||||||
|
curses.color_pair(1) | curses.A_BOLD,
|
||||||
)
|
)
|
||||||
while True:
|
while True:
|
||||||
key = screen.getch()
|
key = screen.getch()
|
||||||
|
@ -495,6 +496,7 @@ def play(
|
||||||
|
|
||||||
guestswitch(score, game="maze")
|
guestswitch(score, game="maze")
|
||||||
|
|
||||||
|
|
||||||
def main(screen):
|
def main(screen):
|
||||||
screen.nodelay(True)
|
screen.nodelay(True)
|
||||||
curses.curs_set(False)
|
curses.curs_set(False)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
import curses
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import curses
|
|
||||||
|
|
||||||
import maze.menu as m
|
import maze.menu as m
|
||||||
|
|
||||||
|
@ -57,11 +57,7 @@ def load(screen):
|
||||||
sy = 5
|
sy = 5
|
||||||
for i in range(len(mazes)):
|
for i in range(len(mazes)):
|
||||||
msg = f"{str(i + 1)}. Maze {((mazes[i].replace('.maze', '')).split('_'))[1]} - {((mazes[i].replace('.maze', '')).split('_'))[2]}"
|
msg = f"{str(i + 1)}. Maze {((mazes[i].replace('.maze', '')).split('_'))[1]} - {((mazes[i].replace('.maze', '')).split('_'))[2]}"
|
||||||
screen.addstr(
|
screen.addstr(sy, x // 2 - len(msg) // 2, msg)
|
||||||
sy,
|
|
||||||
x // 2 - len(msg) // 2,
|
|
||||||
msg
|
|
||||||
)
|
|
||||||
sy += 1
|
sy += 1
|
||||||
while True:
|
while True:
|
||||||
screen.addstr(y // 2 + 5, x // 2 - 15, "Enter preferred maze number: ")
|
screen.addstr(y // 2 + 5, x // 2 - 15, "Enter preferred maze number: ")
|
||||||
|
@ -76,7 +72,12 @@ def load(screen):
|
||||||
if num < len(mazes):
|
if num < len(mazes):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
screen.addstr(y - 5, x // 2 - 23, "Entered maze doesn't exist. Please try again.", curses.color_pair(1))
|
screen.addstr(
|
||||||
|
y - 5,
|
||||||
|
x // 2 - 23,
|
||||||
|
"Entered maze doesn't exist. Please try again.",
|
||||||
|
curses.color_pair(1),
|
||||||
|
)
|
||||||
while True:
|
while True:
|
||||||
key = screen.getch()
|
key = screen.getch()
|
||||||
if key == 10:
|
if key == 10:
|
||||||
|
|
14
pong.py
14
pong.py
|
@ -155,8 +155,18 @@ def ball_movement(screen, ball, score):
|
||||||
collision = ball_coords[2]
|
collision = ball_coords[2]
|
||||||
if collision == "OVER":
|
if collision == "OVER":
|
||||||
finalscore = score.score
|
finalscore = score.score
|
||||||
screen.addstr(y // 2 - 1, x // 2 - 3, "GAME OVER!", curses.color_pair(1) | curses.A_BOLD)
|
screen.addstr(
|
||||||
screen.addstr(y // 2, x // 2 - 5, "The Score is: " + str(finalscore), curses.color_pair(3) | curses.A_BOLD)
|
y // 2 - 1,
|
||||||
|
x // 2 - 3,
|
||||||
|
"GAME OVER!",
|
||||||
|
curses.color_pair(1) | curses.A_BOLD,
|
||||||
|
)
|
||||||
|
screen.addstr(
|
||||||
|
y // 2,
|
||||||
|
x // 2 - 5,
|
||||||
|
"The Score is: " + str(finalscore),
|
||||||
|
curses.color_pair(3) | curses.A_BOLD,
|
||||||
|
)
|
||||||
time.sleep(0.25)
|
time.sleep(0.25)
|
||||||
quit.set()
|
quit.set()
|
||||||
time.sleep(1.75)
|
time.sleep(1.75)
|
||||||
|
|
18
snake.py
18
snake.py
|
@ -89,7 +89,9 @@ def main(stdscr):
|
||||||
new_head = [head[0] - 1, head[1]]
|
new_head = [head[0] - 1, head[1]]
|
||||||
|
|
||||||
# insert and print new head
|
# insert and print new head
|
||||||
stdscr.addstr(new_head[0], new_head[1], "█", curses.color_pair(3) | curses.A_BOLD)
|
stdscr.addstr(
|
||||||
|
new_head[0], new_head[1], "█", curses.color_pair(3) | curses.A_BOLD
|
||||||
|
)
|
||||||
snake.insert(0, new_head)
|
snake.insert(0, new_head)
|
||||||
|
|
||||||
# if sanke head is on food
|
# if sanke head is on food
|
||||||
|
@ -117,8 +119,18 @@ def main(stdscr):
|
||||||
or snake[0] in snake[1:]
|
or snake[0] in snake[1:]
|
||||||
):
|
):
|
||||||
msg = "Game Over!"
|
msg = "Game Over!"
|
||||||
stdscr.addstr(sh // 2, sw // 2 - len(msg) // 2, msg, curses.color_pair(1) | curses.A_BOLD)
|
stdscr.addstr(
|
||||||
stdscr.addstr(sh // 2 + 1, sw // 2 - 8, "The Score is: "+str(score), curses.color_pair(3) | curses.A_BOLD)
|
sh // 2,
|
||||||
|
sw // 2 - len(msg) // 2,
|
||||||
|
msg,
|
||||||
|
curses.color_pair(1) | curses.A_BOLD,
|
||||||
|
)
|
||||||
|
stdscr.addstr(
|
||||||
|
sh // 2 + 1,
|
||||||
|
sw // 2 - 8,
|
||||||
|
"The Score is: " + str(score),
|
||||||
|
curses.color_pair(3) | curses.A_BOLD,
|
||||||
|
)
|
||||||
while stdscr.getch() == -1:
|
while stdscr.getch() == -1:
|
||||||
pass
|
pass
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
|
@ -3,8 +3,8 @@ import pickle
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from maze.modules import bruh
|
|
||||||
import maze.modules.PlayerBase_func as player
|
import maze.modules.PlayerBase_func as player
|
||||||
|
from maze.modules import bruh
|
||||||
|
|
||||||
user = password = None
|
user = password = None
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,28 @@
|
||||||
|
import pickle
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
app_id = "4a8fca56"
|
with open("credentials.pickle", "rb") as f:
|
||||||
app_key = "85885b5929e5b14402e75fcb4898d7f5"
|
try:
|
||||||
|
while True:
|
||||||
|
d = pickle.load(f)
|
||||||
|
if d["credtype"] == "oxfordapi":
|
||||||
|
app_id = d["app_id"]
|
||||||
|
app_key = d["app_key"]
|
||||||
|
except EOFError:
|
||||||
|
pass
|
||||||
|
|
||||||
language = "en-us"
|
language = "en-us"
|
||||||
|
|
||||||
|
|
||||||
def defnsyn(w):
|
def defnsyn(w):
|
||||||
url = r"https://od-api.oxforddictionaries.com:443/api/v2/entries/" + language + "/" + w.lower()
|
url = (
|
||||||
r=requests.get(url, headers={"app_id": app_id, "app_key": app_key})
|
r"https://od-api.oxforddictionaries.com:443/api/v2/entries/"
|
||||||
|
+ language
|
||||||
|
+ "/"
|
||||||
|
+ w.lower()
|
||||||
|
)
|
||||||
|
r = requests.get(url, headers={"app_id": app_id, "app_key": app_key})
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
return None, None
|
return None, None
|
||||||
res = r.json()
|
res = r.json()
|
||||||
|
@ -14,43 +30,63 @@ def defnsyn(w):
|
||||||
lexicalCategories = []
|
lexicalCategories = []
|
||||||
synonyms = []
|
synonyms = []
|
||||||
defn = ""
|
defn = ""
|
||||||
if len(s1) > 1:
|
try:
|
||||||
for i in range(len(s1)):
|
if len(s1) > 1:
|
||||||
lexicalCategories.append(s1[i]["lexicalCategory"]['id'])
|
for i in range(len(s1)):
|
||||||
if "verb" in lexicalCategories:
|
lexicalCategories.append(s1[i]["lexicalCategory"]["id"])
|
||||||
baseindex = s1[lexicalCategories.index("verb")]['entries'][0]['senses'][0]
|
if "verb" in lexicalCategories:
|
||||||
defn = (baseindex['shortDefinitions'][0])
|
baseindex = s1[lexicalCategories.index("verb")]["entries"][0]["senses"][
|
||||||
if "synonyms" in baseindex:
|
0
|
||||||
no = 2 if len(baseindex["synonyms"]) > 3 else len(baseindex["synonyms"])
|
]
|
||||||
while no:
|
defn = baseindex["shortDefinitions"][0]
|
||||||
synonyms.append(baseindex["synonyms"][no]["text"])
|
if "synonyms" in baseindex:
|
||||||
no -= 1
|
no = (
|
||||||
synonyms.reverse()
|
2
|
||||||
elif "noun" in lexicalCategories:
|
if len(baseindex["synonyms"]) > 3
|
||||||
baseindex = s1[lexicalCategories.index("noun")]['entries'][0]['senses'][0]
|
else len(baseindex["synonyms"])
|
||||||
defn = (baseindex['shortDefinitions'][0])
|
)
|
||||||
if "synonyms" in baseindex:
|
while no:
|
||||||
no = 3 if len(baseindex["synonyms"]) > 3 else len(baseindex["synonyms"])
|
synonyms.append(baseindex["synonyms"][no]["text"])
|
||||||
while no:
|
no -= 1
|
||||||
synonyms.append(baseindex["synonyms"][no]["text"])
|
synonyms.reverse()
|
||||||
no -= 1
|
elif "noun" in lexicalCategories:
|
||||||
synonyms.reverse()
|
baseindex = s1[lexicalCategories.index("noun")]["entries"][0]["senses"][
|
||||||
|
0
|
||||||
|
]
|
||||||
|
defn = baseindex["shortDefinitions"][0]
|
||||||
|
if "synonyms" in baseindex:
|
||||||
|
no = (
|
||||||
|
3
|
||||||
|
if len(baseindex["synonyms"]) > 3
|
||||||
|
else len(baseindex["synonyms"])
|
||||||
|
)
|
||||||
|
while no:
|
||||||
|
synonyms.append(baseindex["synonyms"][no]["text"])
|
||||||
|
no -= 1
|
||||||
|
synonyms.reverse()
|
||||||
|
else:
|
||||||
|
baseindex = s1[0]["entries"][0]["senses"][0]
|
||||||
|
defn = baseindex["shortDefinitions"][0]
|
||||||
|
if "synonyms" in baseindex:
|
||||||
|
no = (
|
||||||
|
3
|
||||||
|
if len(baseindex["synonyms"]) > 3
|
||||||
|
else len(baseindex["synonyms"])
|
||||||
|
)
|
||||||
|
while no:
|
||||||
|
synonyms.append(baseindex["synonyms"][no]["text"])
|
||||||
|
no -= 1
|
||||||
|
synonyms.reverse()
|
||||||
else:
|
else:
|
||||||
baseindex = s1[0]['entries'][0]['senses'][0]
|
baseindex = s1[0]["entries"][0]["senses"][0]
|
||||||
defn = (baseindex['shortDefinitions'][0])
|
defn = baseindex["shortDefinitions"][0]
|
||||||
if "synonyms" in baseindex:
|
if "synonyms" in baseindex:
|
||||||
no = 3 if len(baseindex["synonyms"]) > 3 else len(baseindex["synonyms"])
|
no = 3 if len(baseindex["synonyms"]) > 3 else len(baseindex["synonyms"])
|
||||||
while no:
|
while no:
|
||||||
synonyms.append(baseindex["synonyms"][no]["text"])
|
synonyms.append(baseindex["synonyms"][no]["text"])
|
||||||
no -= 1
|
no -= 1
|
||||||
synonyms.reverse()
|
synonyms.reverse()
|
||||||
else:
|
except:
|
||||||
baseindex = s1[0]['entries'][0]['senses'][0]
|
print("err")
|
||||||
defn = (baseindex['shortDefinitions'][0])
|
defn = synonyms = ""
|
||||||
if "synonyms" in baseindex:
|
|
||||||
no = 3 if len(baseindex["synonyms"]) > 3 else len(baseindex["synonyms"])
|
|
||||||
while no:
|
|
||||||
synonyms.append(baseindex["synonyms"][no]["text"])
|
|
||||||
no -= 1
|
|
||||||
synonyms.reverse()
|
|
||||||
return defn, synonyms
|
return defn, synonyms
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
words = open("words.txt").read().split("\n")
|
words = open("words.txt").read().split("\n")
|
||||||
|
|
||||||
|
|
||||||
def partition(word, words):
|
def partition(word, words):
|
||||||
# Get how many words will remain for each possible response
|
# Get how many words will remain for each possible response
|
||||||
partitions = []
|
partitions = []
|
||||||
|
@ -8,9 +9,10 @@ def partition(word, words):
|
||||||
for c in "MCW":
|
for c in "MCW":
|
||||||
for d in "MCW":
|
for d in "MCW":
|
||||||
for e in "MCW":
|
for e in "MCW":
|
||||||
partitions.append(len(reduce(word, a+b+c+d+e, words)))
|
partitions.append(len(reduce(word, a + b + c + d + e, words)))
|
||||||
return partitions
|
return partitions
|
||||||
|
|
||||||
|
|
||||||
def reduce(word, result, words):
|
def reduce(word, result, words):
|
||||||
# word: 5-letter word (lowercase)
|
# word: 5-letter word (lowercase)
|
||||||
# result: 5-letter str consisting of M, C, W (misplaced, correct, wrong)
|
# result: 5-letter str consisting of M, C, W (misplaced, correct, wrong)
|
||||||
|
@ -19,16 +21,19 @@ def reduce(word, result, words):
|
||||||
nres = []
|
nres = []
|
||||||
for w in res:
|
for w in res:
|
||||||
if s == "M":
|
if s == "M":
|
||||||
if w[i] != word[i] and word[i] in w: nres.append(w)
|
if w[i] != word[i] and word[i] in w:
|
||||||
|
nres.append(w)
|
||||||
if s == "C":
|
if s == "C":
|
||||||
if w[i] == word[i]: nres.append(w)
|
if w[i] == word[i]:
|
||||||
|
nres.append(w)
|
||||||
if s == "W":
|
if s == "W":
|
||||||
if w[i] != word[i]:
|
if w[i] != word[i]:
|
||||||
if not(word[i] in w) or word.count(word[i]) > 1:
|
if not (word[i] in w) or word.count(word[i]) > 1:
|
||||||
nres.append(w)
|
nres.append(w)
|
||||||
res = nres
|
res = nres
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
print("WORDLE SOLVER")
|
print("WORDLE SOLVER")
|
||||||
print("=============")
|
print("=============")
|
||||||
# First guess is precomputed
|
# First guess is precomputed
|
||||||
|
@ -42,8 +47,8 @@ while result != "CCCCC":
|
||||||
opt_size = float("inf")
|
opt_size = float("inf")
|
||||||
for word in words:
|
for word in words:
|
||||||
p = partition(word, words)
|
p = partition(word, words)
|
||||||
avg_partition_size = sum(p)/len(p)
|
avg_partition_size = sum(p) / len(p)
|
||||||
if opt_size > avg_partition_size:
|
if opt_size > avg_partition_size:
|
||||||
opt_size = avg_partition_size
|
opt_size = avg_partition_size
|
||||||
opt = word
|
opt = word
|
||||||
# print(p)
|
# print(p)
|
||||||
|
|
|
@ -8,7 +8,9 @@ correctletters = ["-"] * 5
|
||||||
|
|
||||||
while maxguesses:
|
while maxguesses:
|
||||||
try:
|
try:
|
||||||
correctguess = input("\nEnter correct letter positions (use - for other letters): ").lower()
|
correctguess = input(
|
||||||
|
"\nEnter correct letter positions (use - for other letters): "
|
||||||
|
).lower()
|
||||||
uselessguess = input("Enter all incorrect letters without space: ").lower()
|
uselessguess = input("Enter all incorrect letters without space: ").lower()
|
||||||
wantedguess = input("Enter all letters of incorrect postiions: ").lower()
|
wantedguess = input("Enter all letters of incorrect postiions: ").lower()
|
||||||
|
|
||||||
|
@ -48,4 +50,4 @@ while maxguesses:
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("\n\nThe word was found!")
|
print("\n\nThe word was found!")
|
||||||
break
|
break
|
||||||
maxguesses -= 1
|
maxguesses -= 1
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
# A slightly more readable version of wordle-curses
|
import curses
|
||||||
|
import random
|
||||||
|
import time
|
||||||
|
|
||||||
import curses, random, time
|
|
||||||
from wordle.dictionary import defnsyn
|
|
||||||
import maze.menu
|
import maze.menu
|
||||||
import maze.modules.maze as m1
|
import maze.modules.maze as m1
|
||||||
|
from wordle.dictionary import defnsyn
|
||||||
|
|
||||||
quitwordle = False
|
quitwordle = False
|
||||||
words = open("wordle\\words.txt", "r").read().split("\n")
|
words = open("wordle\\words.txt", "r").read().split("\n")
|
||||||
|
@ -15,7 +16,7 @@ completionMessages = [
|
||||||
"Splendid!",
|
"Splendid!",
|
||||||
"Amazing!",
|
"Amazing!",
|
||||||
"Great!",
|
"Great!",
|
||||||
"Good!"
|
"Good!",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Draw one row of the board
|
# Draw one row of the board
|
||||||
|
@ -30,6 +31,7 @@ def writeWord(s, word, remark, y):
|
||||||
curses.color_pair(colorPairBindings[color]),
|
curses.color_pair(colorPairBindings[color]),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Score a word
|
# Score a word
|
||||||
def score(guess, word, alphabet):
|
def score(guess, word, alphabet):
|
||||||
res = [" "] * 5
|
res = [" "] * 5
|
||||||
|
@ -37,8 +39,12 @@ def score(guess, word, alphabet):
|
||||||
|
|
||||||
# First process correct letters
|
# First process correct letters
|
||||||
for i, c in enumerate(guess):
|
for i, c in enumerate(guess):
|
||||||
if c == word[i]: #checking if guess letter corresponds to letter of the same index in chosen word
|
if (
|
||||||
charIndex = ord(c) - 97 # 97 corresponds to a - gives alphabet number. (eg. h = 8)
|
c == word[i]
|
||||||
|
): # checking if guess letter corresponds to letter of the same index in chosen word
|
||||||
|
charIndex = (
|
||||||
|
ord(c) - 97
|
||||||
|
) # 97 corresponds to a - gives alphabet number. (eg. h = 8)
|
||||||
counts[charIndex] += 1
|
counts[charIndex] += 1
|
||||||
res[i] = "c" # correct spot
|
res[i] = "c" # correct spot
|
||||||
alphabet[charIndex] = "c"
|
alphabet[charIndex] = "c"
|
||||||
|
@ -48,7 +54,9 @@ def score(guess, word, alphabet):
|
||||||
if c != word[i]:
|
if c != word[i]:
|
||||||
charIndex = ord(c) - 97
|
charIndex = ord(c) - 97
|
||||||
counts[charIndex] += 1
|
counts[charIndex] += 1
|
||||||
if c in word and word.count(c) >= counts[charIndex]: # if freq of letters in guess lesser than freq in word
|
if (
|
||||||
|
c in word and word.count(c) >= counts[charIndex]
|
||||||
|
): # if freq of letters in guess lesser than freq in word
|
||||||
res[i] = "w" # wrong spot
|
res[i] = "w" # wrong spot
|
||||||
if alphabet[charIndex] != "c":
|
if alphabet[charIndex] != "c":
|
||||||
alphabet[charIndex] = "w"
|
alphabet[charIndex] = "w"
|
||||||
|
@ -58,6 +66,7 @@ def score(guess, word, alphabet):
|
||||||
|
|
||||||
return "".join(res), alphabet
|
return "".join(res), alphabet
|
||||||
|
|
||||||
|
|
||||||
# Render current board
|
# Render current board
|
||||||
# Updates alphabet use state + renders colours of guesses
|
# Updates alphabet use state + renders colours of guesses
|
||||||
def render(s, guesses, alphabet):
|
def render(s, guesses, alphabet):
|
||||||
|
@ -74,15 +83,16 @@ def render(s, guesses, alphabet):
|
||||||
writeWord(s, w, r, i * 2 + 7)
|
writeWord(s, w, r, i * 2 + 7)
|
||||||
s.addstr(len(guesses) * 2 + 10, 0, " ")
|
s.addstr(len(guesses) * 2 + 10, 0, " ")
|
||||||
|
|
||||||
|
|
||||||
# Accept word from user input
|
# Accept word from user input
|
||||||
def getWord(s, y):
|
def getWord(s, y):
|
||||||
word = ""
|
word = ""
|
||||||
while True:
|
while True:
|
||||||
writeWord(s, word, "u" * len(word), y) # u = default blue colour
|
writeWord(s, word, "u" * len(word), y) # u = default blue colour
|
||||||
k = s.getch()
|
k = s.getch()
|
||||||
if k == 8: # backspace
|
if k == 8: # backspace
|
||||||
word = word[:-1]
|
word = word[:-1]
|
||||||
elif k == 27: # esc
|
elif k == 27: # esc
|
||||||
global quitwordle
|
global quitwordle
|
||||||
quitwordle = True
|
quitwordle = True
|
||||||
return "hello"
|
return "hello"
|
||||||
|
@ -91,43 +101,42 @@ def getWord(s, y):
|
||||||
elif chr(k).isalpha() and len(word) < 5:
|
elif chr(k).isalpha() and len(word) < 5:
|
||||||
word += chr(k)
|
word += chr(k)
|
||||||
|
|
||||||
|
|
||||||
# Run one game of Wordle
|
# Run one game of Wordle
|
||||||
def run(s):
|
def run(s):
|
||||||
s.clear()
|
s.clear()
|
||||||
word = random.choice(words) #chosen word
|
word = random.choice(words) # chosen word
|
||||||
with open("log.txt", "a") as f:
|
with open("log.txt", "a") as f:
|
||||||
f.write("Chosen word: "+ word+"\n")
|
f.write("Chosen word: " + word + "\n")
|
||||||
defn, synonyms = defnsyn(word)
|
defn, synonyms = defnsyn(word)
|
||||||
guesses = [] # stores each guess and its result
|
guesses = [] # stores each guess and its result
|
||||||
alphabet = ["u"] * 26 # current status of each letter whether used or not
|
alphabet = ["u"] * 26 # current status of each letter whether used or not
|
||||||
# c = correct positon, w = correct letter but not position, n = wrong letter, u = not used
|
# c = correct positon, w = correct letter but not position, n = wrong letter, u = not used
|
||||||
# "ccccc" means all letters are in correct spot
|
# "ccccc" means all letters are in correct spot
|
||||||
while not (len(guesses)) or (guesses[-1][1] != "ccccc" and len(guesses) < 6):
|
while not (len(guesses)) or (guesses[-1][1] != "ccccc" and len(guesses) < 6):
|
||||||
if quitwordle:
|
if quitwordle:
|
||||||
return
|
return
|
||||||
render(s, guesses, alphabet) # Update current state of board from start
|
render(s, guesses, alphabet) # Update current state of board from start
|
||||||
guess = getWord(s, len(guesses) * 2 + 7).lower()
|
guess = getWord(s, len(guesses) * 2 + 7).lower()
|
||||||
if not (guess in words): # Check if given word is valid
|
if not (guess in words): # Check if given word is valid
|
||||||
s.addstr(len(guesses) * 2 + 10, 0, "INVALID WORD", curses.color_pair(1))
|
s.addstr(len(guesses) * 2 + 10, 0, "INVALID WORD", curses.color_pair(1))
|
||||||
s.refresh()
|
s.refresh()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
continue
|
continue
|
||||||
res, alphabet = score(guess, word, alphabet)
|
res, alphabet = score(guess, word, alphabet)
|
||||||
guesses.append([guess, res])
|
guesses.append([guess, res])
|
||||||
render(s, guesses, alphabet) #Renders final board
|
render(s, guesses, alphabet) # Renders final board
|
||||||
|
|
||||||
# Ending spiel
|
# Ending spiel
|
||||||
s.addstr(len(guesses) * 2 + 6, 0, "╰─┴─┴─┴─┴─╯")
|
s.addstr(len(guesses) * 2 + 6, 0, "╰─┴─┴─┴─┴─╯")
|
||||||
if guesses[-1][1] != "ccccc":
|
if guesses[-1][1] != "ccccc":
|
||||||
s.addstr(len(guesses) * 2 + 8, 0, "No more tries - the word was " + word.upper())
|
|
||||||
else:
|
|
||||||
s.addstr(
|
s.addstr(
|
||||||
len(guesses) * 2 + 8,
|
len(guesses) * 2 + 8, 0, "No more tries - the word was " + word.upper()
|
||||||
0,
|
|
||||||
completionMessages[len(guesses)]
|
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
s.addstr(len(guesses) * 2 + 8, 0, completionMessages[len(guesses)])
|
||||||
if defn and synonyms:
|
if defn and synonyms:
|
||||||
s.addstr(len(guesses) * 2 + 9, 0, word+": ", curses.color_pair(2))
|
s.addstr(len(guesses) * 2 + 9, 0, word + ": ", curses.color_pair(2))
|
||||||
synonyms = ", ".join(synonyms)
|
synonyms = ", ".join(synonyms)
|
||||||
s.addstr(len(guesses) * 2 + 9, 8, defn)
|
s.addstr(len(guesses) * 2 + 9, 8, defn)
|
||||||
s.addstr(len(guesses) * 2 + 10, 0, "Some synonyms: ", curses.color_pair(2))
|
s.addstr(len(guesses) * 2 + 10, 0, "Some synonyms: ", curses.color_pair(2))
|
||||||
|
@ -137,6 +146,7 @@ def run(s):
|
||||||
finalscore = allocatescore(guesses)
|
finalscore = allocatescore(guesses)
|
||||||
return finalscore
|
return finalscore
|
||||||
|
|
||||||
|
|
||||||
def allocatescore(guesses):
|
def allocatescore(guesses):
|
||||||
finalscore = 0
|
finalscore = 0
|
||||||
if len(guesses) <= 3:
|
if len(guesses) <= 3:
|
||||||
|
@ -149,6 +159,7 @@ def allocatescore(guesses):
|
||||||
finalscore = 20
|
finalscore = 20
|
||||||
return finalscore
|
return finalscore
|
||||||
|
|
||||||
|
|
||||||
# Main function
|
# Main function
|
||||||
def main(s):
|
def main(s):
|
||||||
# Initialize colors
|
# Initialize colors
|
||||||
|
@ -164,10 +175,11 @@ def main(s):
|
||||||
curses.init_pair(p[0], p[1], curses.COLOR_BLACK)
|
curses.init_pair(p[0], p[1], curses.COLOR_BLACK)
|
||||||
# Run game
|
# Run game
|
||||||
finalscore = run(s)
|
finalscore = run(s)
|
||||||
with open("log.txt", "a") as f:
|
if not finalscore:
|
||||||
f.write(str(finalscore)+"\n")
|
finalscore = 0
|
||||||
while s.getch() == -1:
|
else:
|
||||||
pass
|
while s.getch() == -1:
|
||||||
|
pass
|
||||||
m1.play(s, executeguest=True, outerscore=finalscore, outergame="wordle")
|
m1.play(s, executeguest=True, outerscore=finalscore, outergame="wordle")
|
||||||
maze.menu.menu(s)
|
maze.menu.menu(s)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue