diff --git a/jobs/division_cipher.py b/jobs/division_cipher.py index eb20a80..66466fd 100644 --- a/jobs/division_cipher.py +++ b/jobs/division_cipher.py @@ -5,7 +5,7 @@ from jobs.czech_words import CZECH_WORDS class DivisionCipherJob(Job): def __init__(self): - self.secret = "TAJENKA" + self.user_phrase = None def get_name(self): return "TAJENKA DELENIM" @@ -13,21 +13,20 @@ class DivisionCipherJob(Job): 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) - + self.user_phrase = phrase if phrase else None + + def print_body(self, p): + raw_secret = self.user_phrase if self.user_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): - secret = self.secret + # Keep only A-Z + secret = "".join([c for c in only_ascii.upper() if 'A' <= c <= 'Z']) + + if not secret: + secret = "TAJENKA" p.text("Vylusti tajenku!\n") p.text("Vysledek deleni je poradi pismena\n")