diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2019-01-06 10:34:49 +0000 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2019-01-06 10:34:49 +0000 |
commit | feac5e881faad4bb9f737d9cc829ef9785ae8c4a (patch) | |
tree | fdd299c691225de12007b26efaeeee087af8256a | |
parent | b2dc59d0f89a69069ca8fd52caa68a4c68034ada (diff) | |
download | org-d20-feac5e881faad4bb9f737d9cc829ef9785ae8c4a.tar.gz |
factor out `org-d20--d20-plus'
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r-- | org-d20.el | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -229,10 +229,7 @@ the best N of them, e.g., 4d6k3." ;; In 5e, all monsters of the same kind have the same ;; initiative (let ((init (int-to-string - (cdr (org-d20--roll - (concat - "1d20" - (org-d20--num-to-term init-input)))))) + (org-d20--d20-plus (string-to-number init-input)))) (monsters-left num-input)) (while (>= monsters-left 1) (let ((hp (int-to-string (cdr (org-d20--roll hd-input))))) @@ -363,10 +360,7 @@ the best N of them, e.g., 4d6k3." (org-table-goto-line (1+ (org-table-current-line))) (org-table-goto-line (1+ (org-table-current-line))) (let ((init (int-to-string - (cdr (org-d20--roll - (concat - "1d20" - (org-d20--num-to-term init-input)))))) + (org-d20--d20-plus (string-to-number init-input)))) (monsters-left num-input)) (while (>= monsters-left 1) ;; Open a new row and then immediately move it downwards @@ -449,5 +443,9 @@ the best N of them, e.g., 4d6k3." (forward-char -2) (skip-chars-backward " ")) +;; Roll a d20, adding or subtracting a modifier +(defun org-d20--d20-plus (&optional mod) + (+ 1 mod (random 20))) + (provide 'org-d20) ;;; org-d20.el ends here |