diff --git a/jobs/base.py b/jobs/base.py index 6599480..db35446 100644 --- a/jobs/base.py +++ b/jobs/base.py @@ -4,6 +4,9 @@ class Job: def get_name(self): raise NotImplementedError + def configure(self): + pass + def print_body(self, p): raise NotImplementedError diff --git a/jobs/maze.py b/jobs/maze.py index 3fb752b..0cf440d 100644 --- a/jobs/maze.py +++ b/jobs/maze.py @@ -3,15 +3,33 @@ from PIL import Image, ImageDraw from .base import Job class MazeJob(Job): + def __init__(self): + self.width = 14 + self.height = 32 + def get_name(self): return "BLUDISTE" + def configure(self): + print("\nSelect Difficulty:") + print(" [1] Easy") + print(" [2] Medium") + print(" [3] Hard") + choice = input("Choice [2]: ").strip() + + if choice == '1': + self.height = 8 + elif choice == '3': + self.height = 32 + else: + self.height = 18 + def print_body(self, p): # Width and Height in cells. # Total width in chars = 2 * w + 1. # w=15 -> 31 chars (Fits comfortably on 80mm printers, tight on 58mm) - w = 14 - h = 32 + w = self.width + h = self.height maze = self.generate_maze(w, h) @@ -38,12 +56,17 @@ class MazeJob(Job): for r in range(rows): for c in range(cols): + x = c * cell_size + y = r * cell_size + # Draw walls as black rectangles if maze[r][c] == '#': - x = c * cell_size - y = r * cell_size # fill=0 means Black in '1' mode draw.rectangle([x, y, x + cell_size, y + cell_size], fill=0) + elif maze[r][c] == 'S': + draw.text((x + 5, y + 2), "S", fill=0) + elif maze[r][c] == 'E': + draw.text((x + 5, y + 2), "E", fill=0) return img diff --git a/print_server.py b/print_server.py index 149bdc6..7533fd8 100644 --- a/print_server.py +++ b/print_server.py @@ -79,16 +79,27 @@ def run_tui(): continue if job: + job.configure() + + copies_str = input("\nNumber of copies [1]: ").strip() + try: + copies = max(1, int(copies_str)) if copies_str else 1 + except ValueError: + copies = 1 + p = get_printer() if p: - print(f"Printing {job.get_name()}...") + print(f"Printing {job.get_name()} ({copies} copies)...") try: - job.run(p) - - # If using Dummy, print the output to console to verify - if isinstance(p, Dummy): - print(p.output.decode('utf-8', errors='ignore')) + for i in range(copies): + if copies > 1: + print(f" Printing copy {i + 1}...") + job.run(p) + # If using Dummy, print the output to console to verify + if isinstance(p, Dummy): + print(p.output.decode('utf-8', errors='ignore')) + print("Success! Job sent to printer.") except Exception as e: print(f"Print Error: {e}")