blob: bac1039b98adcdeaf61e961fb676b96498ca709f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
;;; 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 <https://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 '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 "<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 (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
|