Add dice tables

A dice table is a direct translation of a gaming table from a book,
where the table has a stated dice expression, and each entry has a
numeric range. Most tables can now be taken as is from published
sources.

Also, if a message from a randomly rolled table contains a dice
expression, like Found 2d8 scrolls, the expression is automatically
substituted.

Finally if a message contains something like:
  You found a [wolf/fox/badger].
The displayed message will only include on of those entries.
This commit is contained in:
Howard Abrams 2021-02-11 22:08:06 -08:00
parent 106ed2e6dd
commit 656c168a52
8 changed files with 155 additions and 59 deletions

View file

@ -210,6 +210,11 @@ the following:
(re-search-forward rpgdm-roll-regexp))
(goto-char (match-beginning 0)))
(defun rpgdm-dice-format-string (str)
"Replace all dice expressions in STR with a dice roll results."
(while (string-match rpgdm-roll-regexp str)
(replace-regexp-in-string (concat rpgdm-roll-regexp "'") 'rpgdm-roll-sum str)))
;; Practice: somed8 d4 2d8 3d6+2
(defun rpgdm--roll-expression (expression)