Created
October 15, 2013 01:22
-
-
Save vilmibm/6985139 to your computer and use it in GitHub Desktop.
I forgot my dice during d&d tonight so I wrote this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro roll [rolls _ sides & body] | |
`(+ (if (nil? ~body) 0 ~body) (reduce + (repeatedly ~rolls #(+ 1 (rand-int ~sides)))))) | |
(roll 1 d 4) ; dagger | |
(roll 1 d 20 + 6) ; initiative | |
(roll 4 d 4 + 4) ; 7th level magic missle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment