#+title: Fate Accelerated + One Page Solo Engine [[elisp:(fae/roll-ndF 4)][Roll 4dF]] * Characters ** PC *** CHARACTER NAME :PROPERTIES: :FatePoints: 0 :Refresh: 0 :END: CHARACTER DESCRIPTION **** Stress - [ ] 1 - [ ] 2 - [ ] 3 **** Aspects - *High Concept*: - *Trouble*: - *Aspect 1*: ***** Consequences - *Consequence 1*: - *Consequence 2*: - *Consequence 3*: **** Approaches #+name: pc1 | +x | Approach | |----+----------| | +2 | [[elisp:(fae/roll-approach "pc1" "Careful")][Careful]] | | +0 | [[elisp:(fae/roll-approach "pc1" "Clever")][Clever]] | | +8 | [[elisp:(fae/roll-approach "pc1" "Flashy")][Flashy]] | | +3 | [[elisp:(fae/roll-approach "pc1" "Forecful")][Forceful]] | | +0 | [[elisp:(fae/roll-approach "pc1" "Quick")][Quick]] | | +0 | [[elisp:(fae/roll-approach "pc1" "Sneaky")][Sneaky]] | **** Stunts * Log * Code #+name: startup #+begin_src elisp :results silent (org-sbe "fae") (define-minor-mode srpg-mode "Minor mode for solo RPG gameplay." :init-value nil :keymap (make-keymap)) (define-key srpg-mode-map (kbd "M-r") 'fae/take-action) #+end_src #+name: prop-tbl-lookup #+begin_src elisp :var lookup="" target="" :results silent (alist-get target (mapcar #'(lambda (x) (cons (replace-regexp-in-string "\\(\\[\\[.*\\]\\[\\)\\(.*\\)\\]\\]" "\\2" (cadr x)) (car x))) (cl-remove-if (lambda (x) (not (listp x))) lookup)) nil nil (lambda (x y) (let ((z (string-search x y))) (and z (= 0 z))))) #+end_src ** Fate Accelerated #+name: fae #+begin_src elisp :results silent (defun fae/roll-fate-die () "Rolls a single fate die, returning either 1, 0, or -1." (interactive) (- (random 3) 1)) (defun fae/roll-ndF (n) "Rolls `n' fate dice, and returns the result." (interactive) (defun roll (i acc) (if (= i n) acc (roll (+ 1 i) (+ acc (fae/roll-fate-die))))) (roll 0 0)) (defun fae/get-approach-modifier (approach) "Get approach value." (let ( (table (read-string "For which approach table? "))) (or (org-babel-execute-src-block nil (org-babel-lob-get-info `(babel-call (:call "prop-tbl-lookup" :arguments ,(format "%s, \"%s\"" table approach))))) 0))) (defun fae/roll-approach (table approach) "Get careful approach value." (+ (fae/roll-ndF 4) (or (org-babel-execute-src-block nil (org-babel-lob-get-info `(babel-call (:call "prop-tbl-lookup" :arguments ,(format "%s, \"%s\"" table approach))))) 0) (if (y-or-n-p "Any other modifiers?") (read-minibuffer "+? ") 0))) (defun fae/take-action () "Say what you're trying to do and insert a roll outcome." (interactive) (let* ((action (read-string "What are you trying to do? ")) (dice-roll (fae/roll-ndF 4)) (approach (completing-read "Select approach: " '("Careful" "Clever" "Flashy" "Forceful" "Quick" "Sneaky"))) (app-mod (fae/get-approach-modifier approach)) (add-mod (if (y-or-n-p "Any other modifiers?") (read-minibuffer "+? ") 0))) (insert (format "%s (Approach %s, Rolled %s+%s+%s=%s)\n" action approach dice-roll app-mod add-mod (+ dice-roll app-mod add-mod))))) #+end_src # Local Variables: # org-confirm-babel-evaluate: nil # eval: (progn (org-sbe "startup")) # End: