updated end screen
This commit is contained in:
parent
085beca867
commit
3c4cc86b26
75
wordle.py
75
wordle.py
|
@ -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=""
|
||||
|
@ -120,39 +124,38 @@ def placeCursor(x,y):
|
|||
move("d",y)
|
||||
def putCursorInside(guess,letter):
|
||||
row = guess * 4 + 1;
|
||||
col = 48 + letter * 6;
|
||||
col = 48 + letter * 6;
|
||||
placeCursor(col,row);
|
||||
put(colors[0])
|
||||
|
||||
def main():
|
||||
cursorLocation = 0
|
||||
print(reset+"\033c")
|
||||
screen=fg('green')+'''
|
||||
████████████████████████████████████████
|
||||
█▄─█▀▀▀█─▄█─▄▄─█▄─▄▄▀█▄─▄▄▀█▄─▄███▄─▄▄─█
|
||||
screen="\x1b[?25l"+fg('green')+'''
|
||||
████████████████████████████████████████
|
||||
█▄─█▀▀▀█─▄█─▄▄─█▄─▄▄▀█▄─▄▄▀█▄─▄███▄─▄▄─█
|
||||
██─█─█─█─██─██─██─▄─▄██─██─██─██▀██─▄█▀█
|
||||
▀▀▄▄▄▀▄▄▄▀▀▄▄▄▄▀▄▄▀▄▄▀▄▄▄▄▀▀▄▄▄▄▄▀▄▄▄▄▄▀
|
||||
clone by xereeto
|
||||
original by josh wardle'''+fg('white')+'''
|
||||
▀▀▄▄▄▀▄▄▄▀▀▄▄▄▄▀▄▄▀▄▄▀▄▄▄▄▀▀▄▄▄▄▄▀▄▄▄▄▄▀
|
||||
clone by xereeto
|
||||
original by josh wardle'''+fg('white')+'''
|
||||
----------------------------------------
|
||||
Guess the WORDLE in 6 tries.
|
||||
Each guess must be a valid 5 letter word.
|
||||
Press the enter button to submit.
|
||||
Guess the WORDLE in 6 tries.
|
||||
Each guess must be a valid 5 letter word.
|
||||
Press the enter button to submit.
|
||||
|
||||
After each guess, the color of the tiles
|
||||
will change to show how close your guess
|
||||
was to the word.
|
||||
----------------------------------------
|
||||
Keys:
|
||||
q w e r t y u i o p
|
||||
a s d f g h j k l
|
||||
After each guess, the color of the tiles
|
||||
will change to show how close your guess
|
||||
was to the word.
|
||||
----------------------------------------
|
||||
Keys:
|
||||
q w e r t y u i o p
|
||||
a s d f g h j k l
|
||||
z x c v b n m
|
||||
----------------------------------------
|
||||
Game: XXX
|
||||
----------------------------------------
|
||||
Game: XXX
|
||||
'''
|
||||
import time
|
||||
goHome()
|
||||
print(screen,end="")
|
||||
print(screen,end="")
|
||||
goHome()
|
||||
w = Wordle()
|
||||
while w.turn<6 and not w.wonGame():
|
||||
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue