aboutsummaryrefslogtreecommitdiff
path: root/org-d20.el
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-01-05 17:37:11 +0000
committerSean Whitton <spwhitton@spwhitton.name>2019-01-05 17:37:11 +0000
commit8665eb3d9a4a406c9030f4a0325c6d76f5413193 (patch)
treeb32d5e42aa3f73aaba30b1c7de0bf8ef7790f5ae /org-d20.el
parentd8e6e98dd29c501f4d28213b3e6fc907a65b8748 (diff)
downloadorg-d20-8665eb3d9a4a406c9030f4a0325c6d76f5413193.tar.gz
accept a dice expression for the number of a kind of monster
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'org-d20.el')
-rw-r--r--org-d20.el17
1 files changed, 9 insertions, 8 deletions
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