From ea8c770071d42609f698e69d3522340f81392eca Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Wed, 25 Mar 2026 09:09:11 +0100 Subject: [PATCH] Conditions: toggle system with known states + panic table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace free-text conditions with toggle checkboxes: - SPC G c -> choose: Přepnout stav / Panická reakce / Vlastní - Known conditions: Starving, Dehydrated, Exhausted, Freezing, Fatigued, Radiation — shown as [X]/[ ] toggles - Panic table: Jumpy, Freeze, Tunnel Vision, etc. with stress level - Status display shows all known conditions with checkbox state Co-Authored-By: Claude Opus 4.6 (1M context) --- alien-rpg.el | 111 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 91 insertions(+), 20 deletions(-) diff --git a/alien-rpg.el b/alien-rpg.el index 4b0e3ee..1eb9c42 100644 --- a/alien-rpg.el +++ b/alien-rpg.el @@ -1095,7 +1095,15 @@ Průlezy G<->H: G3<->H3, G4<->H4, G7<->H7, G8<->H8, G9<->H9 "--"))) ;; Zraneni a stavy (insert (format "Zranění: %s\n" (if injuries (string-join injuries ", ") "--"))) - (insert (format "Stavy: %s\n" (if conditions (string-join conditions ", ") "--"))) + (insert (format "Stavy: %s" + (mapconcat (lambda (c) + (format "[%s] %s" + (if (member c conditions) "X" " ") c)) + alien-rpg-known-conditions ", "))) + (let ((extra-conds (cl-remove-if (lambda (c) (member c alien-rpg-known-conditions)) conditions))) + (when extra-conds + (insert (format ", %s" (mapconcat (lambda (c) (format "[X] %s" c)) extra-conds ", "))))) + (insert "\n") ;; Signature (insert (format "Signature: %s\n" (or (plist-get ch :signature-item) "--")))) (goto-char (point-min)) @@ -1530,29 +1538,92 @@ FORMAT-FN dostane item, vrátí string. Bez FORMAT-FN se item použije přímo." (alien-rpg--autosave) (message "Vyléčeno: %s" (nth idx injuries))))))) +(defvar alien-rpg-known-conditions + '("Starving" "Dehydrated" "Exhausted" "Freezing" "Fatigued" "Radiation") + "Standardní stavy z herní karty.") + +(defvar alien-rpg-panic-effects + '(("7 lichá: Jumpy" . "Jumpy") + ("7 sudá: Freeze" . "Freeze") + ("8 lichá: Tunnel Vision" . "Tunnel Vision") + ("8 sudá: Seek Cover" . "Seek Cover") + ("9 lichá: Aggravated" . "Aggravated") + ("9 sudá: Scream" . "Scream") + ("10 lichá: Shakes" . "Shakes") + ("10 sudá: Flee" . "Flee") + ("11 lichá: Frantic" . "Frantic") + ("11 sudá: Frenzy" . "Frenzy") + ("12 lichá: Deflated" . "Deflated") + ("12 sudá: Catatonic" . "Catatonic") + ("13-14 lichá: Paranoid" . "Paranoid") + ("13-14 sudá: Hesitant" . "Hesitant")) + "Panické reakce podle stress levelu.") + (defun alien-rpg-condition () - "Stav/podmínka — přidat nebo odebrat." + "Přepni stav/podmínku — zaškrtni nebo odškrtni." (interactive) (let* ((conditions (plist-get alien-rpg-state :conditions)) - (actions (if conditions '("Přidat" "Odebrat") '("Přidat"))) - (action (if conditions - (completing-read "Podmínka: " actions nil t) - "Přidat"))) + (action (completing-read "Podmínky: " + '("Přepnout stav" "Panická reakce" "Vlastní") nil t))) (cond - ((string= action "Přidat") - (let ((cond-name (read-string "Stav: "))) - (setq alien-rpg-state (plist-put alien-rpg-state :conditions - (append conditions (list cond-name)))) - (alien-rpg--autosave) - (message "Stav: %s" cond-name))) - ((string= action "Odebrat") - (let* ((candidates (alien-rpg--numbered-candidates conditions)) - (choice (completing-read "Odebrat: " candidates nil t)) - (idx (cdr (assoc choice candidates)))) - (setq alien-rpg-state (plist-put alien-rpg-state :conditions - (alien-rpg--remove-nth idx conditions))) - (alien-rpg--autosave) - (message "Odebráno: %s" (nth idx conditions))))))) + ((string= action "Přepnout stav") + (let* ((candidates + (mapcar (lambda (c) + (format "[%s] %s" + (if (member c conditions) "X" " ") c)) + alien-rpg-known-conditions)) + (choice (completing-read "Stav: " candidates nil t)) + (cond-name (substring choice 4))) + (if (member cond-name conditions) + (progn + (setq alien-rpg-state + (plist-put alien-rpg-state :conditions + (remove cond-name conditions))) + (alien-rpg--autosave) + (message "[ ] %s" cond-name)) + (setq alien-rpg-state + (plist-put alien-rpg-state :conditions + (append conditions (list cond-name)))) + (alien-rpg--autosave) + (message "[X] %s" cond-name)))) + ((string= action "Panická reakce") + (let* ((candidates + (mapcar (lambda (p) + (let ((label (car p)) + (name (cdr p))) + (format "[%s] %s" + (if (member name conditions) "X" " ") + label))) + alien-rpg-panic-effects)) + (choice (completing-read "Panika: " candidates nil t)) + (idx (cl-position choice candidates :test #'string=)) + (cond-name (cdr (nth idx alien-rpg-panic-effects)))) + (if (member cond-name conditions) + (progn + (setq alien-rpg-state + (plist-put alien-rpg-state :conditions + (remove cond-name conditions))) + (alien-rpg--autosave) + (message "[ ] %s" cond-name)) + (setq alien-rpg-state + (plist-put alien-rpg-state :conditions + (append conditions (list cond-name)))) + (alien-rpg--autosave) + (message "[X] %s" cond-name)))) + ((string= action "Vlastní") + (let ((cond-name (read-string "Název: "))) + (if (member cond-name conditions) + (progn + (setq alien-rpg-state + (plist-put alien-rpg-state :conditions + (remove cond-name conditions))) + (alien-rpg--autosave) + (message "[ ] %s" cond-name)) + (setq alien-rpg-state + (plist-put alien-rpg-state :conditions + (append conditions (list cond-name)))) + (alien-rpg--autosave) + (message "[X] %s" cond-name))))))) ;; ==================================================================== ;; DISPATCH, HELP, VIEW MODE