Re-roll the same dice expression.
Yes, I got that idea from d20, and at some point, we need to figure out how to play better together.
This commit is contained in:
parent
a61dfcc201
commit
520f74cc66
2 changed files with 14 additions and 1 deletions
|
|
@ -32,6 +32,10 @@
|
|||
;;
|
||||
;;; Code:
|
||||
|
||||
(defvar rpgdm-previous-roll-expression nil
|
||||
"Whenever we roll a dice from an expression, we remember it
|
||||
here, so that we can re-roll it again.")
|
||||
|
||||
;; The basics of a dice roll is a random number from a given range. Note that if
|
||||
;; we give a 6-sided die to the random number, we will end up with a range of 0
|
||||
;; to 5, so we need to increase this value by 1.
|
||||
|
|
@ -282,9 +286,18 @@ Unless the point is on a dice roll description, e.g 2d12+3."
|
|||
(interactive (list (if (looking-at rpgdm-roll-regexp)
|
||||
(match-string-no-properties 0)
|
||||
(read-string "Dice Expression: "))))
|
||||
(setq rpgdm-previous-roll-expression expression)
|
||||
(let ((roll-results (rpgdm--roll-expression expression)))
|
||||
(rpgdm-message "Rolled: %s" (rpgdm--display-roll roll-results expression))))
|
||||
|
||||
(defun rpgdm-roll-again ()
|
||||
"Roll the previous expression ... again.
|
||||
Never rolled before? No problem, we'll query for the expression
|
||||
if we need too."
|
||||
(interactive)
|
||||
(if rpgdm-previous-roll-expression
|
||||
(rpgdm-roll rpgdm-previous-roll-expression)
|
||||
(call-interactively 'rpgdm-roll)))
|
||||
|
||||
;; ----------------------------------------------------------------------
|
||||
;; ADVANTAGE and DISADVANTAGE ROLLS
|
||||
|
|
|
|||
2
rpgdm.el
2
rpgdm.el
|
|
@ -43,7 +43,7 @@
|
|||
_d_: Roll Dice _z_: Flip a coin _r_: Dashboard _s_: d20 Skill _m_: Moderate _o_: Links ⌘-l: Last Results
|
||||
_b_: Previous _f_: Next Dice Expr _t_: Load Tables _e_: Easy check _h_: Hard check _J_/_K_: Page up/dn ⌘-k: ↑ Previous
|
||||
_a_/_A_: Advantage/Disadvantage _c_: Choose Item _v_: Difficult _i_: Impossible _N_/_W_: Narrow/Widen ⌘-j: ↓ Next "
|
||||
("d" rpgdm-roll)
|
||||
("d" rpgdm-roll) ("D" rpgdm-roll-again)
|
||||
("f" rpgdm-forward-roll) ("b" rpgdm-forward-roll)
|
||||
("a" rpgdm-roll-advantage) ("A" rpgdm-roll-disadvantage)
|
||||
("z" rpgdm-yes-and-50/50)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue