aboutsummaryrefslogtreecommitdiff
path: root/server/game
diff options
context:
space:
mode:
authorLoic Guegan <manzerberdes@gmx.com>2019-05-09 18:38:31 +0200
committerLoic Guegan <manzerberdes@gmx.com>2019-05-09 18:38:31 +0200
commitd261883d4148a87ea8f6bb6cef16be406a2c0a10 (patch)
treec10fa38dbe394e3f4fc6269c0ba6cdfa7eed758e /server/game
parentf0ccb136eb945b19d3d9eec61ad8a15a0a9ba993 (diff)
Update api
Diffstat (limited to 'server/game')
-rw-r--r--server/game/game.lisp7
1 files changed, 7 insertions, 0 deletions
diff --git a/server/game/game.lisp b/server/game/game.lisp
index f909f36..9ea2029 100644
--- a/server/game/game.lisp
+++ b/server/game/game.lisp
@@ -39,6 +39,13 @@
(format t "~%Direction: ~a" dir)
(format t "~%Food: ~a" food)))
+(defgeneric dump (g)
+ (:documentation "Dump a game. Return a plist."))
+
+(defmethod dump ((g game))
+ (with-slots (snake food game-over) g
+ (list :snake snake :food food :game-over game-over)))
+
;;; Note that there is no waranty that nb food are added (ex: if food position collide with snake position)
(defgeneric add-food (g nb)
(:documentation "Add food on the game grid."))