diff --git a/.gitignore b/.gitignore index 3494b50..2117728 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ naledi.log usocket_minimal.lisp +heap.md diff --git a/.gitignore b/.gitignore index 3494b50..2117728 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ naledi.log usocket_minimal.lisp +heap.md diff --git a/client/user-interface.lisp b/client/user-interface.lisp index 77c82e7..c6077b4 100644 --- a/client/user-interface.lisp +++ b/client/user-interface.lisp @@ -179,8 +179,8 @@ (defun update-ui (mapwin playerwin placewin newswin) "Update all four UI elements" (draw-map mapwin) - (draw-player-panel playerwin) - (draw-place-panel placewin) + (draw-descriptive-panel playerwin "describe-player") + (draw-descriptive-panel placewin "describe-patch") (draw-news-panel newswin)) (defun draw-map (win) @@ -204,17 +204,9 @@ (croatoan:move win (1+ h) 1))) (croatoan:refresh win)) -(defun draw-player-panel (win) - "Draw a panel with information about the player character." - ;;TODO - (croatoan:box win) - (croatoan:move win 1 1) - (croatoan:add-string win "This is the player panel.") - (croatoan:refresh win)) - -(defun draw-place-panel (win) - "Draw a panel with information about the player's current location." - (let ((descr (break-lines (query-server "describe-patch") +(defun draw-descriptive-panel (win query) + "Draw a panel with information about the player or his location." + (let ((descr (break-lines (query-server query) (- (croatoan:.width win) 2)))) (croatoan:clear win) (croatoan:box win) @@ -225,21 +217,31 @@ (1+ (first (croatoan:.cursor-position win))) 1)) (croatoan:refresh win))) -(let ((news '("Press h for help."))) +(let ((news '("Press h for help.")) (display-time 6) (timer 0)) (defun draw-news-panel (win) "Draw a thin panel at the bottom of the screen to display news items." (collect-news) (croatoan:clear win) (croatoan:move win 0 0) - (croatoan:add-string win (car news)) + (when (< timer display-time) + (croatoan:add-string win (car news)) + (incf timer)) (croatoan:refresh win)) (defun collect-news () "Collect news for this player from the server" ;;XXX I don't quite understand why I need to do `read-from-string' here (let ((messages (read-from-string (query-server "messages")))) - (when messages (setf news (append messages news))))) + (when messages + (setf news (append messages news)) + (setf timer 0)))) + (defun notify (msg &rest format-args) + "Pass a message from the client to the user" + (let ((m (apply #'format (append (list NIL msg) format-args)))) + (setf news (append (list m) news)) + (setf timer 0))) + (defun message-window () "Return a dialog window with the last game messages." ;;TODO complete - stop the window disappearing diff --git a/.gitignore b/.gitignore index 3494b50..2117728 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ naledi.log usocket_minimal.lisp +heap.md diff --git a/client/user-interface.lisp b/client/user-interface.lisp index 77c82e7..c6077b4 100644 --- a/client/user-interface.lisp +++ b/client/user-interface.lisp @@ -179,8 +179,8 @@ (defun update-ui (mapwin playerwin placewin newswin) "Update all four UI elements" (draw-map mapwin) - (draw-player-panel playerwin) - (draw-place-panel placewin) + (draw-descriptive-panel playerwin "describe-player") + (draw-descriptive-panel placewin "describe-patch") (draw-news-panel newswin)) (defun draw-map (win) @@ -204,17 +204,9 @@ (croatoan:move win (1+ h) 1))) (croatoan:refresh win)) -(defun draw-player-panel (win) - "Draw a panel with information about the player character." - ;;TODO - (croatoan:box win) - (croatoan:move win 1 1) - (croatoan:add-string win "This is the player panel.") - (croatoan:refresh win)) - -(defun draw-place-panel (win) - "Draw a panel with information about the player's current location." - (let ((descr (break-lines (query-server "describe-patch") +(defun draw-descriptive-panel (win query) + "Draw a panel with information about the player or his location." + (let ((descr (break-lines (query-server query) (- (croatoan:.width win) 2)))) (croatoan:clear win) (croatoan:box win) @@ -225,21 +217,31 @@ (1+ (first (croatoan:.cursor-position win))) 1)) (croatoan:refresh win))) -(let ((news '("Press h for help."))) +(let ((news '("Press h for help.")) (display-time 6) (timer 0)) (defun draw-news-panel (win) "Draw a thin panel at the bottom of the screen to display news items." (collect-news) (croatoan:clear win) (croatoan:move win 0 0) - (croatoan:add-string win (car news)) + (when (< timer display-time) + (croatoan:add-string win (car news)) + (incf timer)) (croatoan:refresh win)) (defun collect-news () "Collect news for this player from the server" ;;XXX I don't quite understand why I need to do `read-from-string' here (let ((messages (read-from-string (query-server "messages")))) - (when messages (setf news (append messages news))))) + (when messages + (setf news (append messages news)) + (setf timer 0)))) + (defun notify (msg &rest format-args) + "Pass a message from the client to the user" + (let ((m (apply #'format (append (list NIL msg) format-args)))) + (setf news (append (list m) news)) + (setf timer 0))) + (defun message-window () "Return a dialog window with the last game messages." ;;TODO complete - stop the window disappearing diff --git a/params.lisp b/params.lisp index 0519bb9..d8d9db5 100644 --- a/params.lisp +++ b/params.lisp @@ -28,7 +28,7 @@ (defparameter *framerate* 1000) ;;Localhost defaults -(defparameter *defaulthost* '("127.0.0.1" 21892)) ;default port: 21895 +(defparameter *defaulthost* '("127.0.0.1" 21898)) ;default port: 21895 ;;Host server address to connect to - XXX global variable! (defparameter *host* (first *defaulthost*)) diff --git a/.gitignore b/.gitignore index 3494b50..2117728 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ naledi.log usocket_minimal.lisp +heap.md diff --git a/client/user-interface.lisp b/client/user-interface.lisp index 77c82e7..c6077b4 100644 --- a/client/user-interface.lisp +++ b/client/user-interface.lisp @@ -179,8 +179,8 @@ (defun update-ui (mapwin playerwin placewin newswin) "Update all four UI elements" (draw-map mapwin) - (draw-player-panel playerwin) - (draw-place-panel placewin) + (draw-descriptive-panel playerwin "describe-player") + (draw-descriptive-panel placewin "describe-patch") (draw-news-panel newswin)) (defun draw-map (win) @@ -204,17 +204,9 @@ (croatoan:move win (1+ h) 1))) (croatoan:refresh win)) -(defun draw-player-panel (win) - "Draw a panel with information about the player character." - ;;TODO - (croatoan:box win) - (croatoan:move win 1 1) - (croatoan:add-string win "This is the player panel.") - (croatoan:refresh win)) - -(defun draw-place-panel (win) - "Draw a panel with information about the player's current location." - (let ((descr (break-lines (query-server "describe-patch") +(defun draw-descriptive-panel (win query) + "Draw a panel with information about the player or his location." + (let ((descr (break-lines (query-server query) (- (croatoan:.width win) 2)))) (croatoan:clear win) (croatoan:box win) @@ -225,21 +217,31 @@ (1+ (first (croatoan:.cursor-position win))) 1)) (croatoan:refresh win))) -(let ((news '("Press h for help."))) +(let ((news '("Press h for help.")) (display-time 6) (timer 0)) (defun draw-news-panel (win) "Draw a thin panel at the bottom of the screen to display news items." (collect-news) (croatoan:clear win) (croatoan:move win 0 0) - (croatoan:add-string win (car news)) + (when (< timer display-time) + (croatoan:add-string win (car news)) + (incf timer)) (croatoan:refresh win)) (defun collect-news () "Collect news for this player from the server" ;;XXX I don't quite understand why I need to do `read-from-string' here (let ((messages (read-from-string (query-server "messages")))) - (when messages (setf news (append messages news))))) + (when messages + (setf news (append messages news)) + (setf timer 0)))) + (defun notify (msg &rest format-args) + "Pass a message from the client to the user" + (let ((m (apply #'format (append (list NIL msg) format-args)))) + (setf news (append (list m) news)) + (setf timer 0))) + (defun message-window () "Return a dialog window with the last game messages." ;;TODO complete - stop the window disappearing diff --git a/params.lisp b/params.lisp index 0519bb9..d8d9db5 100644 --- a/params.lisp +++ b/params.lisp @@ -28,7 +28,7 @@ (defparameter *framerate* 1000) ;;Localhost defaults -(defparameter *defaulthost* '("127.0.0.1" 21892)) ;default port: 21895 +(defparameter *defaulthost* '("127.0.0.1" 21898)) ;default port: 21895 ;;Host server address to connect to - XXX global variable! (defparameter *host* (first *defaulthost*)) diff --git a/server/item-methods.lisp b/server/item-methods.lisp index 6a97a58..d269cb5 100644 --- a/server/item-methods.lisp +++ b/server/item-methods.lisp @@ -37,7 +37,7 @@ (if (member (class-of tl) (.destructors d)) (if (>= 0 (decf (.health d) (random (* 10 (.level tl))))) (.drops d) d) - (progn (notify "You cannot attack ~A with ~A." + (progn (notify "You cannot attack ~A with ~A." ;;FIXME remove `notify' (leading-vowl (.name d)) (leading-vowel (.name tl))) NIL))) diff --git a/.gitignore b/.gitignore index 3494b50..2117728 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ naledi.log usocket_minimal.lisp +heap.md diff --git a/client/user-interface.lisp b/client/user-interface.lisp index 77c82e7..c6077b4 100644 --- a/client/user-interface.lisp +++ b/client/user-interface.lisp @@ -179,8 +179,8 @@ (defun update-ui (mapwin playerwin placewin newswin) "Update all four UI elements" (draw-map mapwin) - (draw-player-panel playerwin) - (draw-place-panel placewin) + (draw-descriptive-panel playerwin "describe-player") + (draw-descriptive-panel placewin "describe-patch") (draw-news-panel newswin)) (defun draw-map (win) @@ -204,17 +204,9 @@ (croatoan:move win (1+ h) 1))) (croatoan:refresh win)) -(defun draw-player-panel (win) - "Draw a panel with information about the player character." - ;;TODO - (croatoan:box win) - (croatoan:move win 1 1) - (croatoan:add-string win "This is the player panel.") - (croatoan:refresh win)) - -(defun draw-place-panel (win) - "Draw a panel with information about the player's current location." - (let ((descr (break-lines (query-server "describe-patch") +(defun draw-descriptive-panel (win query) + "Draw a panel with information about the player or his location." + (let ((descr (break-lines (query-server query) (- (croatoan:.width win) 2)))) (croatoan:clear win) (croatoan:box win) @@ -225,21 +217,31 @@ (1+ (first (croatoan:.cursor-position win))) 1)) (croatoan:refresh win))) -(let ((news '("Press h for help."))) +(let ((news '("Press h for help.")) (display-time 6) (timer 0)) (defun draw-news-panel (win) "Draw a thin panel at the bottom of the screen to display news items." (collect-news) (croatoan:clear win) (croatoan:move win 0 0) - (croatoan:add-string win (car news)) + (when (< timer display-time) + (croatoan:add-string win (car news)) + (incf timer)) (croatoan:refresh win)) (defun collect-news () "Collect news for this player from the server" ;;XXX I don't quite understand why I need to do `read-from-string' here (let ((messages (read-from-string (query-server "messages")))) - (when messages (setf news (append messages news))))) + (when messages + (setf news (append messages news)) + (setf timer 0)))) + (defun notify (msg &rest format-args) + "Pass a message from the client to the user" + (let ((m (apply #'format (append (list NIL msg) format-args)))) + (setf news (append (list m) news)) + (setf timer 0))) + (defun message-window () "Return a dialog window with the last game messages." ;;TODO complete - stop the window disappearing diff --git a/params.lisp b/params.lisp index 0519bb9..d8d9db5 100644 --- a/params.lisp +++ b/params.lisp @@ -28,7 +28,7 @@ (defparameter *framerate* 1000) ;;Localhost defaults -(defparameter *defaulthost* '("127.0.0.1" 21892)) ;default port: 21895 +(defparameter *defaulthost* '("127.0.0.1" 21898)) ;default port: 21895 ;;Host server address to connect to - XXX global variable! (defparameter *host* (first *defaulthost*)) diff --git a/server/item-methods.lisp b/server/item-methods.lisp index 6a97a58..d269cb5 100644 --- a/server/item-methods.lisp +++ b/server/item-methods.lisp @@ -37,7 +37,7 @@ (if (member (class-of tl) (.destructors d)) (if (>= 0 (decf (.health d) (random (* 10 (.level tl))))) (.drops d) d) - (progn (notify "You cannot attack ~A with ~A." + (progn (notify "You cannot attack ~A with ~A." ;;FIXME remove `notify' (leading-vowl (.name d)) (leading-vowel (.name tl))) NIL))) diff --git a/server/player.lisp b/server/player.lisp index 30cc756..1c9c267 100644 --- a/server/player.lisp +++ b/server/player.lisp @@ -66,6 +66,8 @@ ;;TODO convert to methods +;; FIXME remove `notify' calls + (defun stock-size (resource player) "How many items of this resource type is the player carrying?" (dolist (i (player-inventory player) 0) diff --git a/.gitignore b/.gitignore index 3494b50..2117728 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ naledi.log usocket_minimal.lisp +heap.md diff --git a/client/user-interface.lisp b/client/user-interface.lisp index 77c82e7..c6077b4 100644 --- a/client/user-interface.lisp +++ b/client/user-interface.lisp @@ -179,8 +179,8 @@ (defun update-ui (mapwin playerwin placewin newswin) "Update all four UI elements" (draw-map mapwin) - (draw-player-panel playerwin) - (draw-place-panel placewin) + (draw-descriptive-panel playerwin "describe-player") + (draw-descriptive-panel placewin "describe-patch") (draw-news-panel newswin)) (defun draw-map (win) @@ -204,17 +204,9 @@ (croatoan:move win (1+ h) 1))) (croatoan:refresh win)) -(defun draw-player-panel (win) - "Draw a panel with information about the player character." - ;;TODO - (croatoan:box win) - (croatoan:move win 1 1) - (croatoan:add-string win "This is the player panel.") - (croatoan:refresh win)) - -(defun draw-place-panel (win) - "Draw a panel with information about the player's current location." - (let ((descr (break-lines (query-server "describe-patch") +(defun draw-descriptive-panel (win query) + "Draw a panel with information about the player or his location." + (let ((descr (break-lines (query-server query) (- (croatoan:.width win) 2)))) (croatoan:clear win) (croatoan:box win) @@ -225,21 +217,31 @@ (1+ (first (croatoan:.cursor-position win))) 1)) (croatoan:refresh win))) -(let ((news '("Press h for help."))) +(let ((news '("Press h for help.")) (display-time 6) (timer 0)) (defun draw-news-panel (win) "Draw a thin panel at the bottom of the screen to display news items." (collect-news) (croatoan:clear win) (croatoan:move win 0 0) - (croatoan:add-string win (car news)) + (when (< timer display-time) + (croatoan:add-string win (car news)) + (incf timer)) (croatoan:refresh win)) (defun collect-news () "Collect news for this player from the server" ;;XXX I don't quite understand why I need to do `read-from-string' here (let ((messages (read-from-string (query-server "messages")))) - (when messages (setf news (append messages news))))) + (when messages + (setf news (append messages news)) + (setf timer 0)))) + (defun notify (msg &rest format-args) + "Pass a message from the client to the user" + (let ((m (apply #'format (append (list NIL msg) format-args)))) + (setf news (append (list m) news)) + (setf timer 0))) + (defun message-window () "Return a dialog window with the last game messages." ;;TODO complete - stop the window disappearing diff --git a/params.lisp b/params.lisp index 0519bb9..d8d9db5 100644 --- a/params.lisp +++ b/params.lisp @@ -28,7 +28,7 @@ (defparameter *framerate* 1000) ;;Localhost defaults -(defparameter *defaulthost* '("127.0.0.1" 21892)) ;default port: 21895 +(defparameter *defaulthost* '("127.0.0.1" 21898)) ;default port: 21895 ;;Host server address to connect to - XXX global variable! (defparameter *host* (first *defaulthost*)) diff --git a/server/item-methods.lisp b/server/item-methods.lisp index 6a97a58..d269cb5 100644 --- a/server/item-methods.lisp +++ b/server/item-methods.lisp @@ -37,7 +37,7 @@ (if (member (class-of tl) (.destructors d)) (if (>= 0 (decf (.health d) (random (* 10 (.level tl))))) (.drops d) d) - (progn (notify "You cannot attack ~A with ~A." + (progn (notify "You cannot attack ~A with ~A." ;;FIXME remove `notify' (leading-vowl (.name d)) (leading-vowel (.name tl))) NIL))) diff --git a/server/player.lisp b/server/player.lisp index 30cc756..1c9c267 100644 --- a/server/player.lisp +++ b/server/player.lisp @@ -66,6 +66,8 @@ ;;TODO convert to methods +;; FIXME remove `notify' calls + (defun stock-size (resource player) "How many items of this resource type is the player carrying?" (dolist (i (player-inventory player) 0) diff --git a/server/server.lisp b/server/server.lisp index 5eba089..ba0cfd0 100644 --- a/server/server.lisp +++ b/server/server.lisp @@ -264,7 +264,7 @@ (aref submap w h 1) next-col)))))) (defun describe-patch (&optional (x 0) (y 0)) - "Return a set of lines describing the patch at these coordinates." + "Return a multi-line string describing the patch at these coordinates." (let* ((plr (player-human (get-player (thread-player)))) (p (coord (+ x (.x plr)) (+ y (.y plr))))) (format NIL "~A~%~%~A / ~A~%~%The ground here is ~A.~A~A" @@ -283,6 +283,22 @@ (string-from-list (mapcar #'.name (patch-items p)) (format NIL "~% *"))))))) +(defun describe-player () + "Return a multi-line string describing the current player." + (let ((p (player-human (get-player (thread-player))))) + (sconc + (format NIL "~A~%~%Health: ~S / ~S~%Experience: ~S (Level ~S)" + (string-upcase (.name p)) (.health p) (.max-health p) + (.xp p) (.level p)) + (format NIL "~%~%Strength: ~S Dexterity: ~S~%Intelligence: ~S" + (.strength p) (.dex p) (.int p)) + (format NIL "~%~%Hunger: ~S~%Carried items: ~S~%Holding: ~A" + (.hunger p) + (length (remove-if #'(lambda (x) (or (null (first x)) + (zerop (second x)))) + (.inventory p))) + (if (.tool p) (.name (.tool p)) ""))))) + (defun move-player (dir) "Move a player in the given direction" (let ((plr (player-human (get-player (thread-player))))) @@ -305,6 +321,7 @@ (list "signup" #'create-player) (list "map" #'get-map) (list "describe-patch" #'describe-patch) + (list "describe-player" #'describe-player) (list "move" #'move-player) (list "messages" #'(lambda () (collect-messages (get-player (thread-player)))))))