diff --git a/jobs/division_cipher.py b/jobs/division_cipher.py index 8a98b30..eb20a80 100644 --- a/jobs/division_cipher.py +++ b/jobs/division_cipher.py @@ -1,13 +1,33 @@ import random +import unicodedata from .base import Job +from jobs.czech_words import CZECH_WORDS class DivisionCipherJob(Job): + def __init__(self): + self.secret = "TAJENKA" + def get_name(self): - return "TAJENKA (DELENI)" + return "TAJENKA DELENIM" + + def configure(self): + print("\n--- Configure Division Cipher ---") + phrase = input("Enter secret phrase (default: Random): ").strip().upper() + + raw_secret = phrase if phrase else random.choice(CZECH_WORDS) + + # Remove accents to ensure mapping to A-Z works + nfkd_form = unicodedata.normalize('NFKD', raw_secret) + only_ascii = "".join([c for c in nfkd_form if not unicodedata.combining(c)]) + + # Keep only A-Z + self.secret = "".join([c for c in only_ascii.upper() if 'A' <= c <= 'Z']) + + if not self.secret: + self.secret = "TAJENKA" def print_body(self, p): - words = ["TONIK", "ROBOT", "MOBIL", "MAMISEK", "SLADKE", "BOBEK", "BOREC", "HUSTY", "VOLNO", "HOTOVE"] - secret = random.choice(words) + secret = self.secret p.text("Vylusti tajenku!\n") p.text("Vysledek deleni je poradi pismena\n") diff --git a/jobs/word_search.py b/jobs/word_search.py index 119d6cd..69a371e 100644 --- a/jobs/word_search.py +++ b/jobs/word_search.py @@ -16,17 +16,21 @@ class WordSearchJob: def configure(self): print("\n--- Configure Word Search ---") - phrase = input("Enter hidden phrase (default: TAJENKA): ").strip().upper() + phrase = input("Enter hidden phrase (default: Random): ").strip().upper() if phrase: self.hidden_phrase = "".join(c for c in phrase if c.isalnum()) else: - self.hidden_phrase = "TAJENKA" + self.hidden_phrase = random.choice(CZECH_WORDS) self.width = len(self.hidden_phrase) + 2 self.height = len(self.hidden_phrase) + 2 - size = int(input(f"Enter size (default: {self.width}): ").strip()) - if size: - self.width = size - self.height = size + size_str = input(f"Enter size (default: {self.width}): ").strip() + if size_str: + try: + size = int(size_str) + self.width = size + self.height = size + except ValueError: + pass if self.width < 5: self.width = 5 self.height = 5