From bdb50ea7171fb0e7f5a2a6edf79c3a7da5a7f2c8 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 22 Jul 2019 13:12:34 +0100 Subject: add new org-fate.el --- .emacs.d/site-lisp/org-fate.el | 91 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .emacs.d/site-lisp/org-fate.el (limited to '.emacs.d/site-lisp') 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 +;; 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 . + +;;; 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 "") #'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 -- cgit v1.2.3