diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2019-01-05 17:37:11 +0000 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2019-01-05 17:37:11 +0000 |
commit | 8665eb3d9a4a406c9030f4a0325c6d76f5413193 (patch) | |
tree | b32d5e42aa3f73aaba30b1c7de0bf8ef7790f5ae | |
parent | d8e6e98dd29c501f4d28213b3e6fc907a65b8748 (diff) | |
download | org-d20-8665eb3d9a4a406c9030f4a0325c6d76f5413193.tar.gz |
accept a dice expression for the number of a kind of monster
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r-- | NEWS.md | 2 | ||||
-rw-r--r-- | TODO.md | 2 | ||||
-rw-r--r-- | org-d20.el | 17 |
3 files changed, 11 insertions, 10 deletions
@@ -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) @@ -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 -------------------- @@ -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 |