Dice calc: show results in buffer, include stress in menu

- Results now display in *Alien RPG* buffer (not message bar)
  so screen reader reads them reliably
- Menu already shows effective dice count with stress deducted:
  "Close Combat    3 kostek (Str 3 + 2 - stress 2)"
- Buffer shows full breakdown after selection

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 17:42:55 +01:00
parent 8d6098ff83
commit 362b8dae58

View File

@@ -1231,25 +1231,35 @@ Průlezy G<->H: G3<->H3, G4<->H4, G7<->H7, G8<->H8, G9<->H9
(defun alien-rpg-dice ()
"Kolik kostek hodit — vyber dovednost."
(interactive)
(let* ((choices (mapcar (lambda (sk)
(let* ((stress (plist-get alien-rpg-state :stress))
(choices (mapcar (lambda (sk)
(let* ((key (car sk))
(attr-key (cdr sk))
(name (cdr (assq key alien-rpg-skill-names)))
(attr-val (plist-get (plist-get alien-rpg-character :attributes) attr-key))
(skill-val (plist-get (plist-get alien-rpg-character :skills) key))
(total (+ attr-val skill-val))
(effective (max 0 (- total stress)))
(attr-abbr (cdr (assq attr-key alien-rpg-attr-abbrevs))))
(cons (format "%-18s %d (%s %d + %d)" name total attr-abbr attr-val skill-val)
(list name total attr-abbr attr-val skill-val))))
(cons (format "%-18s %d kostek (%s %d + %d - stress %d)"
name effective attr-abbr attr-val skill-val stress)
(list name total effective attr-abbr attr-val skill-val))))
alien-rpg-skill-attributes))
(choice (completing-read "Hod na: " choices nil t))
(data (cdr (assoc choice choices)))
(name (nth 0 data))
(total (nth 1 data))
(stress (plist-get alien-rpg-state :stress)))
(let ((effective (max 0 (- total stress))))
(message "%s: %d základ - %d stress = %d kostek"
name total stress effective))))
(effective (nth 2 data)))
(with-current-buffer (get-buffer-create "*Alien RPG*")
(let ((inhibit-read-only t))
(erase-buffer)
(insert (format "%s: %d kostek\n" name effective))
(insert (format "Základ: %d (atribut + dovednost)\n" total))
(insert (format "Stress: -%d\n" stress))
(insert (format "Výsledek: %d kostek k hodu\n" effective)))
(goto-char (point-min))
(special-mode))
(switch-to-buffer "*Alien RPG*")))
(defun alien-rpg-add-injury (injury)
"Přidej zranění."