Working with both Dice and Frequency tables

Some of these tables are getting complicated, so I have created three
different tables, and this should be sufficient.

Describing it, however, seems to be a lot for source code, and I thought
I would describe it using a literate programming style. We'll see.
This commit is contained in:
Howard Abrams 2021-02-08 15:26:16 -08:00
parent 558d7eb984
commit 7dab533415
7 changed files with 975 additions and 270 deletions

View file

@ -155,6 +155,24 @@ average value of AVG, if given."
(rpgdm--test-roll-series 'rpgdm--roll dice-args lowest highest)))))
;; For programmatic reasons, we need a quick way to roll dice and get a
;; numeric value.
(defun rpgdm-roll-sum (first &optional dice-type modifier)
"Return a number value from rolling some dice.
The FIRST can be one of the following values:
- A dice expression as a string, e.g. 2d4+2
- A roll-combo tuple list
- A single number of dice to roll (but this requires more values)
If FIRST is an integer, then DICE-TYPE is the number of dice sides.
MODIFIER, if given, is added to roll."
(cond
((stringp first) (rpgdm--sum (rpgdm--roll-expression first)))
((listp first) (rpgdm--sum first))
(t (rpgdm--sum (rpgdm--roll first dice-type modifier)))))
;; Now that we can roll a die with distinct numbers, let's now deal with dice
;; strings, e.g. 2d10+4. Can we have a regular expression that could identify
;; as well as pull apart the individual numbers?