- (c) notice
- colorful text
- use wordbox to print letters in boxes
- better(?) formatting on printed strings
- use more descriptive variable names
This commit is contained in:
John 2022-02-14 20:56:02 -06:00
parent 1b214b33f0
commit 5cfd666654

View File

@ -1,6 +1,17 @@
"""
Copyright(c) 2022 SoftFish
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
import w import w
import c
import argparse import argparse
import sys
from datetime import date from datetime import date
# Set up argument parser # Set up argument parser
@ -71,11 +82,14 @@ else:
# Box characters! # Box characters!
boxes = ["", "🟨", "🟩"] boxes = ["", "🟨", "🟩"]
# gray bg yellow bg green bg white fg black bg
colors= [0x13a3a3c, 0x1b59f3b, 0x1538d4e, 0xd7dadc, 0x1121213]
# Guesses go here # Guesses go here
guesses = [] guesses = []
def wordbox(word): # Letter is in boxes
def wordbox(word, showword = 0):
output = "" output = ""
line = [0] * len(word) line = [0] * len(word)
guess = list(word) guess = list(word)
@ -95,28 +109,40 @@ def wordbox(word):
# Remove letter from solution and guess # Remove letter from solution and guess
sol[sol.index(word[i])] = guess[i] = 0 sol[sol.index(word[i])] = guess[i] = 0
# Turn blocks into a string, and print it # Turn blocks into a string, and print it
if showword:
for i in range(len(word)):
#output += c.c(7,0,1) + (c.c(2,1) if line[i] == 2 else c.c(3,1) if line[i] == 1 else c.c(0,1,1)) + word[i].upper() + " " + c.reset
output += c.c24(colors[3]) + c.c24(colors[line[i]]) + " " + word[i].upper() + " " + c.reset
else:
for i in line: for i in line:
output += boxes[i] #output += c.c(7, 0, 1) + (c.c(2, 1) if i == 2 else c.c(3, 1) if i == 1 else c.c(0, 1, 1)) + boxes[i] + c.reset
output += c.c24(colors[3]) + c.c24(colors[i]) + boxes[i] + c.reset
print(output) print(output)
def game(): def game():
print("[ Wordle {}{} ]".format(d, "*" if args.hard else " ")) spaces = " " * (2-(len(str(d))//2))
print(c.reset + "[ " + spaces + "Wordle {}{}".format(d, "*" if args.hard else " ") + spaces + "]")
words = w.Words + w.Answers words = w.Words + w.Answers
guess = 0 guess = 0
while guess < max_guesses: while guess < max_guesses:
ui = input().lower() # lol i should probably use curses
if len(ui) == 5 and (ui in words or args.nonsense): user_input = input(" [ ]\b\b\b\b\b\b").lower()
guesses.append(ui) if len(user_input) == 5 and (user_input in words or args.nonsense):
wordbox(ui) # Add guesses to the guessed list, and put the word in boxes
if (ui == solution): guesses.append(user_input)
wordbox(user_input, 1)
# win condition
if (user_input == solution):
win(True) win(True)
return return
else: else:
guess += 1 guess += 1
else: else:
if ui == "exit": # Allow the user to make it stop
if user_input == "exit":
exit() exit()
print ("Not in word list") print ("Not in word list")
# lose
win(False) win(False)
def win(won): def win(won):