about summary refs log tree commit diff stats
path: root/ccap-muck.lisp
diff options
context:
space:
mode:
authorDarren Bane <darren.bane@gmail.com>2021-01-17 00:54:23 +0000
committerDarren Bane <darren.bane@gmail.com>2021-01-17 00:54:23 +0000
commitec33fa3c80f852d60d7e2fcd046cc49c08fad803 (patch)
tree46d4952b98745fc2da89765ce1f228040cb6c526 /ccap-muck.lisp
parent6222836c3b031ce6cf4bc98c3bbf7ff896d23786 (diff)
downloadlsp-ec33fa3c80f852d60d7e2fcd046cc49c08fad803.tar.gz
Making changes
Diffstat (limited to 'ccap-muck.lisp')
-rw-r--r--ccap-muck.lisp50
1 files changed, 25 insertions, 25 deletions
diff --git a/ccap-muck.lisp b/ccap-muck.lisp
index 9931b63..9037d98 100644
--- a/ccap-muck.lisp
+++ b/ccap-muck.lisp
@@ -1,4 +1,4 @@
-(require "split-sequence")
+(require "split-sequence")              ; TODO: really used?
 (defpackage #:ccap-muck
   (:use #:common-lisp #:split-sequence)
   (:export
@@ -8,8 +8,8 @@
 
 (defvar *terminate-program* nil)
 
-(defconstant +bold+ "#\esc[1m")
-(defconstant +unbold+ "#\esc[0m")
+(defvar +bold+ "#\esc[1m")    ; TODO: (alexandria:define-constant ...)
+(defvar +unbold+ "#\esc[0m")
 (defconstant +q+ #\")
 
 (defclass <avatar> () ((name :accessor name)
@@ -23,24 +23,24 @@
                            (socket :reader socket)
                            (parser :reader parser)
                            (avatar :reader avatar)
-                           (room :reader room)))
+                           (curr-room :reader curr-room)))
 (defvar *connections* '())
 
 (defconstant +port-number+ 6565)
 
-(defconstant +vd-type+ #(n s e w u d))
+(defvar +vd-type+ #(n s e w u d))  ; TODO: alexandria again
 
 (defclass <room> () ((name :reader name)
-		     (desc :reader desc)
-		     (exits :reader exits)))
+                     (desc :reader desc)
+                     (exits :reader exits)))
 (defvar *rooms* '())
 
 (defvar *write-rooms* nil)
 
 (defconstant +command-type+ #(say help quit look
-			      rooms make-room make-door teleport
-			      n s e w
-			      u d password shutdown))
+                              rooms make-room make-door teleport
+                              n s e w
+                              u d password shutdown))
 
 (defconstant +name-prompt+ "Please enter your character name:")
 
@@ -74,8 +74,8 @@
         (if (string= s (symbol-name c))
             (return-from result-command c))))))
 
-(defun name (c)
-  (concatenate 'string +bold+ (name (avatar c)) +unbold))
+(defun format-name (c)
+  (concatenate 'string +bold+ (name (avatar c)) +unbold+))
 
 (defun say (c s)
   (if (g c)
@@ -91,12 +91,12 @@
   (do ((cs *connections* (cdr cs)))
       ((null cs))
     (let ((c (car cs)))
-      (if (eq (room c) r)
+      (if (eq (curr-room c) r)
           (say c s)))))
 
 (defun look (c)
-  (say c (concatenate 'string "Room: " (name (room c))))
-  (do ((ds (desc (room c)) (cdr ds)))
+  (say c (concatenate 'string "Room: " (name (curr-room c))))
+  (do ((ds (desc (curr-room c)) (cdr ds)))
       ((null ds))
     (let ((d (car ds)))
       (say c (line d))))
@@ -104,11 +104,11 @@
   (say c "Exits:")
   (do ((i 0 (+ i 1)))
       ((>= i (length +vd-type+)))
-    (let ((e (elt (exits (room c)) i)))
+    (let ((e (elt (exits (curr-room c)) i)))
       (if (not (null e))
           (say c (concatenate 'string " " (symbol-name (elt +vd-type+ i)) " " (name e))))))
   (say c "Avatars:")
-  ()
+  ())
 
 ;; TODO: Use the reader, for prototype at least?
 ;;       Can switch to postmodern for production.
@@ -133,7 +133,7 @@
           (setf (desc r) desc)
           (setq *rooms* (cons r *rooms*))))
       (file-position file 0)
-      (
+      ())))
 
 (defmethod print-object ((obj <room>) stream)
   (flet ((write-desc (ds)
@@ -153,19 +153,19 @@
 
 (defun write-room-database ()
   (with-open-file (file +rdb+ :direction output)
-    (mapcar (lambda (r) (print-object r file)) *rooms*)) 
+    (mapcar (lambda (r) (print-object r file)) *rooms*))
   (setq *write-rooms* nil))
 
 (defun read-avatar-database ()
   (setq *avatars* '())
   (with-open-file (file +adb+ :direction :input)
     (do ((name (read-line file nil nil))
-	 (password (read-line file nil nil)))
-	((or (null name) (null password)))
+         (password (read-line file nil nil)))
+        ((or (null name) (null password)))
       (let ((a (make-instance (find-class '<avatar>))))
-	(setf (name a) name)
-	(setf (password a) password)
-	(setq *avatars* (cons a *avatars*)))))
+        (setf (name a) name)
+        (setf (password a) password)
+        (setq *avatars* (cons a *avatars*)))))
   (setq *write-avatars* nil))
 
 (defmethod print-object ((obj <avatar>) stream)
@@ -179,5 +179,5 @@
   (read-avatar-database)
   (read-room-database)
   (while (not *terminate-program*)
-	 (check-for-inputs)))
+         (check-for-inputs)))
 (provide "ccap-muck")