summaryrefslogtreecommitdiff
path: root/.emacs.d/site-lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2017-10-02 10:29:27 -0700
committerSean Whitton <spwhitton@spwhitton.name>2017-10-02 10:29:27 -0700
commit88f1b77e4b25f5f4bb1c2c589098e5e464b5774d (patch)
tree057b2edc9db214d7069a93694d54fe864ec22101 /.emacs.d/site-lisp
parentf381c15705bbdf03d5d3f05962f5a16121ebe42a (diff)
downloaddotfiles-88f1b77e4b25f5f4bb1c2c589098e5e464b5774d.tar.gz
spwd20-damage marks monsters as dead
Diffstat (limited to '.emacs.d/site-lisp')
-rw-r--r--.emacs.d/site-lisp/spwd20.el15
1 files changed, 12 insertions, 3 deletions
diff --git a/.emacs.d/site-lisp/spwd20.el b/.emacs.d/site-lisp/spwd20.el
index 01679a69..528ae050 100644
--- a/.emacs.d/site-lisp/spwd20.el
+++ b/.emacs.d/site-lisp/spwd20.el
@@ -162,7 +162,6 @@ the best N of them, e.g., 4d6k3."
(insert ">>>>"))))
(org-table-align))
-;;; TODO should surround monster name in tildes when damage >= HP
(defun spwd20-damage (dmg)
"Apply damage to the monster/NPC in the initiative table row at point."
(interactive "*nDamage dealt: ")
@@ -170,8 +169,18 @@ the best N of them, e.g., 4d6k3."
(org-table-goto-column 6)
(skip-chars-forward " ")
(when (looking-at "[0-9]+")
- (replace-match
- (int-to-string (+ dmg (string-to-int (match-string 0))))))))
+ (let ((total-damage (+ dmg (string-to-int (match-string 0)))))
+ (replace-match (int-to-string total-damage))
+ (save-excursion
+ (org-table-goto-column 5)
+ (skip-chars-forward " ")
+ (when (and (looking-at "[0-9]+")
+ (>= total-damage (string-to-int (match-string 0))))
+ (org-table-goto-column 2)
+ (insert "~")
+ (forward-word 1)
+ (insert "~")))))
+ (org-table-align)))
(defun spwd20-roll (exp)
"Prompt, evaluate and display dice roll expression EXP.