;;; 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 'cl-lib) (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 (cl-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