diff --git a/TODO b/TODO index 31330e0..5324f0f 100644 --- a/TODO +++ b/TODO @@ -10,6 +10,8 @@ * split `naledi-ya-africa` package into `naledi-server` and `naledi-client`? +* implement client/server communication + * implement players and player list * (I am legion...) diff --git a/TODO b/TODO index 31330e0..5324f0f 100644 --- a/TODO +++ b/TODO @@ -10,6 +10,8 @@ * split `naledi-ya-africa` package into `naledi-server` and `naledi-client`? +* implement client/server communication + * implement players and player list * (I am legion...) diff --git a/naledi.lisp b/naledi.lisp index 8deabe5..00d0114 100644 --- a/naledi.lisp +++ b/naledi.lisp @@ -152,6 +152,7 @@ ;; a space after each character (dotimes (h (1- (croatoan:.height win))) (dotimes (w (- (halve (croatoan:.width win) 'floor) 2)) + ;;TODO replace `coord' with `query-server' (let ((p (coord (+ w x0 3) (+ h y0 1)))) (if (null p) (croatoan:add-char win #\space) (if (and (= (first (patch-pos p)) (first me)) @@ -186,7 +187,8 @@ (defun draw-place-panel (win me) "Draw a panel with information about the player's current location." - (let ((descr (break-lines (describe-patch me) + ;;TODO replace `describe-patch' with `query-server' + (let ((descr (break-lines (describe-patch me) (- (croatoan:.width win) 2)))) (croatoan:clear win) (croatoan:box win) @@ -202,11 +204,13 @@ "Draw a thin panel at the bottom of the screen to display news items." (croatoan:clear win) (croatoan:move win 0 0) + ;;TODO get news from server (croatoan:add-string win (car news)) (croatoan:refresh win)) (defun notify (news-string &rest formats) "Append a string to the news to notify the user." + ;;TODO needs to be moved to the server ;;A bit of a kluge, but means that `notify' supports formatting (setf news (cons (apply #'format (cons NIL (cons news-string formats))) @@ -215,6 +219,7 @@ (defun message-window () "Return a dialog window with the last game messages." ;;TODO complete + ;;TODO get news from server ;;XXX use `user-inform' instead of dialog-window? (make-instance 'croatoan:dialog-window :input-blocking t @@ -232,6 +237,7 @@ :message-text "Press b to go back."))) ;;:event-handlers '((#\b #'exit-event-loop))))) +;;TODO command/chat window (defun process-command (event) ;;TODO diff --git a/TODO b/TODO index 31330e0..5324f0f 100644 --- a/TODO +++ b/TODO @@ -10,6 +10,8 @@ * split `naledi-ya-africa` package into `naledi-server` and `naledi-client`? +* implement client/server communication + * implement players and player list * (I am legion...) diff --git a/naledi.lisp b/naledi.lisp index 8deabe5..00d0114 100644 --- a/naledi.lisp +++ b/naledi.lisp @@ -152,6 +152,7 @@ ;; a space after each character (dotimes (h (1- (croatoan:.height win))) (dotimes (w (- (halve (croatoan:.width win) 'floor) 2)) + ;;TODO replace `coord' with `query-server' (let ((p (coord (+ w x0 3) (+ h y0 1)))) (if (null p) (croatoan:add-char win #\space) (if (and (= (first (patch-pos p)) (first me)) @@ -186,7 +187,8 @@ (defun draw-place-panel (win me) "Draw a panel with information about the player's current location." - (let ((descr (break-lines (describe-patch me) + ;;TODO replace `describe-patch' with `query-server' + (let ((descr (break-lines (describe-patch me) (- (croatoan:.width win) 2)))) (croatoan:clear win) (croatoan:box win) @@ -202,11 +204,13 @@ "Draw a thin panel at the bottom of the screen to display news items." (croatoan:clear win) (croatoan:move win 0 0) + ;;TODO get news from server (croatoan:add-string win (car news)) (croatoan:refresh win)) (defun notify (news-string &rest formats) "Append a string to the news to notify the user." + ;;TODO needs to be moved to the server ;;A bit of a kluge, but means that `notify' supports formatting (setf news (cons (apply #'format (cons NIL (cons news-string formats))) @@ -215,6 +219,7 @@ (defun message-window () "Return a dialog window with the last game messages." ;;TODO complete + ;;TODO get news from server ;;XXX use `user-inform' instead of dialog-window? (make-instance 'croatoan:dialog-window :input-blocking t @@ -232,6 +237,7 @@ :message-text "Press b to go back."))) ;;:event-handlers '((#\b #'exit-event-loop))))) +;;TODO command/chat window (defun process-command (event) ;;TODO diff --git a/server-protocol.txt b/server-protocol.txt new file mode 100644 index 0000000..d3f7d0b --- /dev/null +++ b/server-protocol.txt @@ -0,0 +1,30 @@ +NALEDI ya AFRICA - SERVER PROTOCOL + +This document describes the text-based protocol used by the Naledi client to +communicate with the game server. + +General syntax: " []*" + +The server will always return a string answer to a command. + + +COMMANDS + +* login + -> "T" on acceptance, "NIL" on denial + -> Warning: passwords are transmitted and stored in plain text! + -> required before all other commands + +* news + -> latest news item relevant to the player + +* patch-char + -> " " of the specified patch + +* describe-patch + -> a string representation of a list of lines describing the specified patch + +* move + -> "T" on success, "NIL" on failure + + diff --git a/TODO b/TODO index 31330e0..5324f0f 100644 --- a/TODO +++ b/TODO @@ -10,6 +10,8 @@ * split `naledi-ya-africa` package into `naledi-server` and `naledi-client`? +* implement client/server communication + * implement players and player list * (I am legion...) diff --git a/naledi.lisp b/naledi.lisp index 8deabe5..00d0114 100644 --- a/naledi.lisp +++ b/naledi.lisp @@ -152,6 +152,7 @@ ;; a space after each character (dotimes (h (1- (croatoan:.height win))) (dotimes (w (- (halve (croatoan:.width win) 'floor) 2)) + ;;TODO replace `coord' with `query-server' (let ((p (coord (+ w x0 3) (+ h y0 1)))) (if (null p) (croatoan:add-char win #\space) (if (and (= (first (patch-pos p)) (first me)) @@ -186,7 +187,8 @@ (defun draw-place-panel (win me) "Draw a panel with information about the player's current location." - (let ((descr (break-lines (describe-patch me) + ;;TODO replace `describe-patch' with `query-server' + (let ((descr (break-lines (describe-patch me) (- (croatoan:.width win) 2)))) (croatoan:clear win) (croatoan:box win) @@ -202,11 +204,13 @@ "Draw a thin panel at the bottom of the screen to display news items." (croatoan:clear win) (croatoan:move win 0 0) + ;;TODO get news from server (croatoan:add-string win (car news)) (croatoan:refresh win)) (defun notify (news-string &rest formats) "Append a string to the news to notify the user." + ;;TODO needs to be moved to the server ;;A bit of a kluge, but means that `notify' supports formatting (setf news (cons (apply #'format (cons NIL (cons news-string formats))) @@ -215,6 +219,7 @@ (defun message-window () "Return a dialog window with the last game messages." ;;TODO complete + ;;TODO get news from server ;;XXX use `user-inform' instead of dialog-window? (make-instance 'croatoan:dialog-window :input-blocking t @@ -232,6 +237,7 @@ :message-text "Press b to go back."))) ;;:event-handlers '((#\b #'exit-event-loop))))) +;;TODO command/chat window (defun process-command (event) ;;TODO diff --git a/server-protocol.txt b/server-protocol.txt new file mode 100644 index 0000000..d3f7d0b --- /dev/null +++ b/server-protocol.txt @@ -0,0 +1,30 @@ +NALEDI ya AFRICA - SERVER PROTOCOL + +This document describes the text-based protocol used by the Naledi client to +communicate with the game server. + +General syntax: " []*" + +The server will always return a string answer to a command. + + +COMMANDS + +* login + -> "T" on acceptance, "NIL" on denial + -> Warning: passwords are transmitted and stored in plain text! + -> required before all other commands + +* news + -> latest news item relevant to the player + +* patch-char + -> " " of the specified patch + +* describe-patch + -> a string representation of a list of lines describing the specified patch + +* move + -> "T" on success, "NIL" on failure + + diff --git a/src/server.lisp b/src/server.lisp index c113434..255c47e 100644 --- a/src/server.lisp +++ b/src/server.lisp @@ -129,6 +129,7 @@ (logging "~&SERVER: received a connection.") ; cf. `get-peer-name' (do* ((sockstr (usocket:socket-stream conn)) (request (read-line sockstr NIL) (read-line sockstr NIL))) + ;;TODO remember player name ;;TODO remove player-thread from list when terminated ((or (not running) (null request))) (format sockstr "~S~%" (to-string (answer request)))