summaryrefslogtreecommitdiff
path: root/src/transactions.lisp
blob: 61f7f9b1a7b53d560e1dd346b38f076741aba860 (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
;;;; transactions.lisp -- data store transactions for dnd

(in-package :dnd)

(defun birth-from-the-goddess-loins (player name)
  (db:with-transaction ()
    (make-instance 'hero :name name :player player)))

(defun new-sesh (player)
  (db:with-transaction () (make-instance 'session :player player)))

(defun destroy-sesh (session)
  (db:with-transaction () 
    (db:delete-object session)))

(defun register-player (nick)
  (db:with-transaction ()
    (make-instance 'player :nickname nick)))

(defun create-adventure (player title &key (description "") seers)
  (db:with-transaction ()
    (make-instance 'adventure :title title :creator player
                   :seers seers
                   :description description)))

(defun report-a-rumor (reporter adventure reported)
  (db:with-transaction ()
    (let ((rumor
            (make-instance 'rumor
                           :reported reported
                           :reporter reporter)))
      (push rumor (rumors adventure)))))