From 8665eb3d9a4a406c9030f4a0325c6d76f5413193 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 5 Jan 2019 17:37:11 +0000 Subject: accept a dice expression for the number of a kind of monster Signed-off-by: Sean Whitton --- NEWS.md | 2 ++ TODO.md | 2 -- org-d20.el | 17 +++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6a355dd..a13c601 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,8 @@ - `org-d20-roll` shows the results on each dice rolled - New defcustom, `org-d20-letter-monsters` - New defcustom, `org-d20-continue-monster-numbering` +- You can now specify a dice expression for the number of a type of + monster/NPC - Improve README for new users 0.2 (2018-12-31) diff --git a/TODO.md b/TODO.md index c603ae5..1294e29 100644 --- a/TODO.md +++ b/TODO.md @@ -8,8 +8,6 @@ Features - defcustom to roll each monster's initiative separately (as in 3e), rather than having type of monster act at the same time (as in 5e) -- For number of monsters, accept a dice expession (e.g. 1d4 Gas - Spores) Possible refactoring -------------------- diff --git a/org-d20.el b/org-d20.el index b730cb0..2abcee9 100644 --- a/org-d20.el +++ b/org-d20.el @@ -156,17 +156,17 @@ the best N of them, e.g., 4d6k3." (when (> (length name-input) 0) (setq init-input (read-string (concat name-input "'s init modifier: ")) hd-input (read-string (concat name-input "'s hit points: ")) - num-input (string-to-int - (read-string (concat "How many " name-input "? ")))) + num-input (cdr (org-d20--roll + (read-string (concat "How many " name-input "? "))))) ;; in 5e, all monsters of the same kind have the same ;; initiative (let ((init (int-to-string - (org-d20--roll (concat - "1d20" - (org-d20--num-to-term init-input))))) + (cdr (org-d20--roll (concat + "1d20" + (org-d20--num-to-term init-input)))))) (monsters-left num-input)) (while (>= monsters-left 1) - (let ((hp (int-to-string (org-d20--roll hd-input)))) + (let ((hp (int-to-string (cdr (org-d20--roll hd-input))))) (push (list "" (concat name-input " " @@ -331,8 +331,9 @@ the best N of them, e.g., 4d6k3." (let* ((name-input (read-string "Monster/NPC name: ")) (init-input (read-string (concat name-input "'s init modifier: "))) (hd-input (read-string (concat name-input "'s hit points: "))) - (num-input (string-to-int - (read-string (concat "How many " name-input "? ")))) + (num-input + (cdr (org-d20--roll + (read-string (concat "How many " name-input "? "))))) (monster 1)) ;; first, if we need to, try to count the number of monsters. ;; We can only use a crude heuristic here because we don't -- cgit v1.2.3