diff options
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 |
