Files
fedora_openclaw 46116f7f4b Initial commit: DOOM x MATRIX System Failure text adventure
Modulares Python-Textadventure mit Kampfsystem (Stagger, Bullet Time,
Glory Kills, Hacking-Skill-Checks), Hub-Raum-Navigation, prozeduralen
Encountern, 3 Charakterklassen, mehreren Enden und Story-Elementen
(weißer Hase, Orakel, schwarze-Katze-Deja-vu-Glitch).
2026-07-05 18:56:44 +02:00

114 lines
2.8 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""UI-Hilfsfunktionen: Farben, Textausgabe, Balken, Glitch-Effekte."""
import os
import sys
import time
import random
try:
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
except (AttributeError, ValueError):
pass
try:
import colorama
colorama.init()
except ImportError:
pass
if os.name == 'nt':
os.system('') # aktiviert ANSI-Codes im klassischen Windows-Terminal
class Colors:
GREEN = '\033[92m'
RED = '\033[91m'
CYAN = '\033[96m'
YELLOW = '\033[93m'
MAGENTA = '\033[95m'
WHITE = '\033[97m'
BLACK = '\033[30m'
BOLD = '\033[1m'
DIM = '\033[2m'
BLINK = '\033[5m'
END = '\033[0m'
# Globaler Schalter für --fast Flag; wenn True, werden alle Delays uebersprungen
FAST_MODE = False
def set_fast_mode(enabled):
global FAST_MODE
FAST_MODE = enabled
def slow_print(text, delay=0.02):
"""Langsames Tippen fuer Dramatik (uebersprungen im --fast Modus)."""
if FAST_MODE:
print(text)
return
for char in text:
print(char, end='', flush=True)
time.sleep(delay)
print()
def dramatic_pause(seconds=1):
if FAST_MODE:
return
time.sleep(seconds)
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
def bar(val, max_val, color, width=20):
val = max(0, min(val, max_val))
filled = int(val / max_val * width) if max_val else 0
filled = max(0, min(width, filled))
b = '█' * filled + '░' * (width - filled)
return f"{color}{b}{Colors.END} {val}/{max_val}"
def glitch_text(text, intensity=0.15, rng=None):
"""Verwuerfelt zufaellig Zeichen in einem String -- fuer Deja-vu-/Bug-Momente."""
rng = rng or random
glitch_chars = "#%&@$!?/\\|01"
out = []
for ch in text:
if ch != ' ' and rng.random() < intensity:
out.append(rng.choice(glitch_chars))
else:
out.append(ch)
return ''.join(out)
def print_glitch_sequence(text, cycles=3, delay=0.04, color=Colors.GREEN):
"""Zeigt kurz Glitch-Varianten eines Textes an, bevor der echte Text steht."""
if FAST_MODE:
print(f"{color}{text}{Colors.END}")
return
for _ in range(cycles):
print(f"\r{color}{glitch_text(text, 0.4)}{Colors.END}", end='', flush=True)
time.sleep(delay)
print(f"\r{color}{text}{Colors.END}")
def divider(char='═', width=45, color=Colors.CYAN):
print(f"{color}{char * width}{Colors.END}")
def section_title(title, color=Colors.CYAN):
print(f"\n{Colors.BOLD}{color}═══ {title} ═══{Colors.END}")
def menu(options, prompt="Aktion"):
"""options: Liste von (key, label) Tupeln. Gibt die gewaehlte Eingabe zurueck."""
for key, label in options:
print(f" {Colors.GREEN}[{key}]{Colors.END} {label}")
return input(f"\n{Colors.CYAN}{prompt}: {Colors.END}").strip()