diff options
| author | Loic Guegan <manzerberdes@gmx.com> | 2019-05-12 14:01:05 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerberdes@gmx.com> | 2019-05-12 14:01:05 +0200 |
| commit | 8e31de079306b288ff159c4e364a1716d8e47d25 (patch) | |
| tree | b2beed91fd1411f22a24a0143fb926127156c1fe /server/api/api.lisp | |
| parent | 8cba94e0812539191b40ad0f823bdaa3b14bb278 (diff) | |
Diffstat (limited to 'server/api/api.lisp')
| -rw-r--r-- | server/api/api.lisp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/server/api/api.lisp b/server/api/api.lisp index a87cf6c..cea5d66 100644 --- a/server/api/api.lisp +++ b/server/api/api.lisp @@ -33,6 +33,7 @@ ((equal dir "down") (setf (getf p-request :direction) :down)) ((equal dir "left") (setf (getf p-request :direction) :left)) ((equal dir "right") (setf (getf p-request :direction) :right)))))) + ((equal type "admin")) ((not (equal type "new-game")) (error 'bad-request :msg "Unknown request type"))) p-request))) @@ -59,6 +60,16 @@ (to-json (append (list :type "state") (dump gm game-id))))))) +;;; TODO: debug this function +(defmethod handle-admin ((api api) data) + (with-slots (gm) api + (let* ((game-id (getf data :game-id)) + (cmd (getf data :cmd)) + (arg (getf data :arg)) + (game (get-game gm game-id))) + (cond + ((equal cmd "move") (admin game :move arg))))) + "Command executed!") (defmethod handle-request ((api api) request) ;; Catch request error and send it to the client @@ -68,6 +79,7 @@ (cond ((equal type "new-game") (handle-new-game api data)) ((equal type "update") (handle-update api data)) + ((equal type "admin") (handle-admin api data)) (t (format t "Unknow type")))) (error (condition) ; Send reason to the client (let ((reason (make-array 0 |
