diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2019-07-22 13:12:34 +0100 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2019-07-22 13:12:34 +0100 |
commit | bdb50ea7171fb0e7f5a2a6edf79c3a7da5a7f2c8 (patch) | |
tree | db618e901a3a31075517072b58ac51aa9f25fa48 /.emacs.d/site-lisp/org-fate.el | |
parent | e17d093fef4e0e7dec67614a527276a2fa34398b (diff) | |
download | dotfiles-bdb50ea7171fb0e7f5a2a6edf79c3a7da5a7f2c8.tar.gz |
add new org-fate.el
Diffstat (limited to '.emacs.d/site-lisp/org-fate.el')
-rw-r--r-- | .emacs.d/site-lisp/org-fate.el | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/.emacs.d/site-lisp/org-fate.el b/.emacs.d/site-lisp/org-fate.el new file mode 100644 index 00000000..b0a1ee87 --- /dev/null +++ b/.emacs.d/site-lisp/org-fate.el @@ -0,0 +1,91 @@ +;;; org-fate.el --- minor mode for Fate tabletop roleplaying games -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 Sean Whitton + +;; Author: Sean Whitton <spwhitton@spwhitton.name> +;; Version: 0.1pre +;; Keywords: outlines games + +;; This file is NOT part of GNU Emacs. + +;;; License: + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: + +;;; A minor mode intended for use in an Org-mode file in which you are +;;; keeping your GM notes for a Fate tabletop roleplaying game. + +;;; Example file footer: +;;; +;;; # Local Variables: +;;; # eval: (org-fate-mode 1) +;;; # End: +;;; +;;; Alternatively, example first line of file: +;;; +;;; # -*- mode: org; mode: org-fate -*- + +;;; Code: + +(require 'subr-x) + +(defgroup org-fate nil + "Customisation of `org-fate-mode'." + :group 'org) + +(defcustom org-fate-dice-sound nil + "Path to a sound file that `play-sound-file' can play." + :type 'string + :group 'org-fate) + +(defvar org-fate-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "<f12>") #'org-fate-roll) + map) + "Keymap for function `org-fate-mode'.") + +;;;###autoload +(define-minor-mode org-fate-mode + "Bind convenience functions for running a Fate game in an +Org-mode document." + :lighter " Fate") + + + +;;; Dice rolling + +;;;###autoload +(defun org-fate-roll () + "Roll Fate dice." + (interactive) + (let ((results '()) (total 0)) + (cl-loop + repeat 4 + do (case (1+ (random 6)) + ((1 2) + (push "⮋" results) + (setq total (1- total))) + ((3 4) + (push "⬤" results)) + ((5 6) + (push "⮉" results) + (setq total (1+ total))))) + (message "%s = %s" (string-join results " + ") total)) + (when org-fate-dice-sound + (play-sound-file org-fate-dice-sound))) + +(provide 'org-fate) +;;; org-fate.el ends here |