updated end screen

This commit is contained in:
xereeto 2024-03-09 18:06:30 +00:00
parent 085beca867
commit 3c4cc86b26
1 changed files with 43 additions and 32 deletions

View File

@ -1,9 +1,10 @@
from colored import bg, fg, attr
from datetime import date
import datetime
import time
from getch import getch
import possible
colors = [bg("white")+fg("black"), bg("dark_gray")+fg("white"),bg("light_yellow")+fg("dark_gray"),bg("green")+fg("white")]
colors = [bg("white")+fg("black"), bg("dark_gray")+fg("white"),bg("light_yellow")+fg("dark_gray"),bg("green")+fg("white"),bg("light_gray")]
keycolors = [fg("white")+bg("black"), fg("dark_gray")+bg("black"),fg("light_yellow")+bg("black"),fg("green")+bg("black")]
reset = bg("black")+fg("white")
@ -14,6 +15,9 @@ class Wordle:
return False
else:
turn=self.turn
self.guesses[turn][0]=[4,4,4,4,4]
self.drawGuessLine(turn)
time.sleep(0.05)
self.guesses[turn][1] = word
processed=[]
for i,letter in enumerate(word):
@ -26,11 +30,11 @@ class Wordle:
processed.append(letter)
self.guesses[turn][0][i] = 2
if letter not in self.guessedKeys:
self.guessedKeys[letter] = 2
self.guessedKeys[letter] = 2
else:
self.guesses[turn][0][i] = max(self.guesses[turn][0][i],1)
self.guesses[turn][0][i] = max(self.guesses[turn][0][i]%4,1)
if letter not in self.guessedKeys:
self.guessedKeys[letter] = 1
self.guessedKeys[letter] = 1
self.drawGuessLine(self.turn)
self.turn +=1
self.drawStatusLine()
@ -56,7 +60,7 @@ class Wordle:
placeCursor(9,21)
put(reset+str(self.number))
placeCursor(34,21)
put("Turn: "+str(self.turn+1)+"/6"+colors[0])
put("Turn: "+str(min(self.turn+1,6))+"/6"+colors[0])
def drawKeyboard(self):
placeCursor(13,17)
@ -82,8 +86,8 @@ class Wordle:
put(colors[0])
def __init__(self):
start = date(2021,6,19)
number = (date.today()-start).days
start = datetime.date(2021,6,19)
number = (datetime.date.today()-start).days
self.number = number
self.turn = 0
self.curGuess=""
@ -127,7 +131,7 @@ def putCursorInside(guess,letter):
def main():
cursorLocation = 0
print(reset+"\033c")
screen=fg('green')+'''
screen="\x1b[?25l"+fg('green')+'''
@ -150,7 +154,6 @@ def main():
----------------------------------------
Game: XXX
'''
import time
goHome()
print(screen,end="")
goHome()
@ -166,6 +169,8 @@ def main():
char = getch().upper()
except OverflowError:
pass
if ord(char)==3:
return
prevchar = ord(char)
if char>="A" and char <="Z" and prevchar !=91:
if len(w.curGuess)<5:
@ -193,9 +198,15 @@ def main():
else:
w.updateError("You have to enter a real word!")
if w.wonGame():
w.updateError("You won!")
s="s"
if w.turn==1:
s=""
w.updateError("You won in "+str(w.turn)+" turn"+s+"!")
else:
w.updateError("You lost :(")
w.updateError("You lost :( The word was "+w.answer+"!")
time.sleep(2)
midnight = (datetime.datetime.now() + datetime.timedelta(days=1)).replace(hour=0, minute=0, microsecond=0, second=0)
w.updateError("Next WORDLE in: "+str(datetime.timedelta(seconds=(midnight-datetime.datetime.now()).seconds)))
time.sleep(2)
@ -207,4 +218,4 @@ try:
except KeyboardInterrupt:
pass
finally:
print("\033c"+reset+"Goodbye!")
print("\033c"+reset+"Goodbye!\x1b[?25h")