about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDarren Bane <darren.bane@gmail.com>2020-12-06 12:52:55 +0000
committerDarren Bane <darren.bane@gmail.com>2020-12-06 12:52:55 +0000
commitca5768f305d4f7d152fe3f8098be28914086ca7e (patch)
tree7d6b1ac75d048ac7183684bc9387e541be3a9a9b
parent10b5ba35c96f72e5b66698b36c7e0a38b555f394 (diff)
downloadlsp-ca5768f305d4f7d152fe3f8098be28914086ca7e.tar.gz
Try port the Ada 16k MUD competition entry to CL
-rw-r--r--ccap-muck.lisp71
1 files changed, 71 insertions, 0 deletions
diff --git a/ccap-muck.lisp b/ccap-muck.lisp
new file mode 100644
index 0000000..3374606
--- /dev/null
+++ b/ccap-muck.lisp
@@ -0,0 +1,71 @@
+(defvar *terminate-program* nil)
+
+(defconstant +bold+ "[1m")
+(defconstant +unbold+ "[0m")
+(defconstant +q+ #\")
+
+(defclass <avatar> () ((name :accessor name)
+                       (playing :reader playing :initform nil)
+                       (password :accessor password)))
+(defvar *avatars* '())
+
+(defvar *write-avatars* nil)
+
+(defclass <connection> () ((g :reader g)
+                           (socket :reader socket)
+                           (parser :reader parser)
+                           (avatar :reader avatar)
+                           (r :reader r)))
+(defvar *connections* '())
+
+(defconstant +port-number+ 6565)
+
+(defconstant +vd-type+ (vector 'n 's 'e 'w
+			       'u 'd))
+
+(defclass <room> () ((name :reader name)
+		     (desc :reader desc)
+		     (exits :reader exits)))
+(defvar *rooms* '())
+
+(defvar *write-rooms* nil)
+
+(defconstant +command-type+ (vector 'say 'help 'quit 'look
+				    'rooms 'make-room 'make-door 'teleport
+				    'n 's 'e 'w
+				    'u 'd 'password 'shutdown))
+
+(defconstant +name-prompt+ "Please enter your character name:")
+
+(defconstant +rdb+ "room.tam")
+(defconstant +adb+ "avatar.tam")
+
+(defun read-room-database ()
+  (with-open-file (file +rdb+ :direction :input)
+    ))
+
+(defun write-room-database ()
+  (with-open-file (file +rdb+ :direction output)
+    (mapcar (lambda (r)
+	      (format file "~A~%"
+
+(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)))
+      (let ((a (make-instance (find-class '<avatar>))))
+	(setf (name a) name)
+	(setf (password a) password)
+	(setq *avatars* (cons a *avatars*)))))
+  (setq *write-avatars* nil))
+
+(defun write-avatar-database ()
+  (with-open-file (file +adb+ :direction output)
+    (mapcar (lambda (a) (format file "~A~%~A~%" (name a) (password a))) *avatars*)))
+
+(read-avatar-database)
+(read-room-database)
+(while (not *terminate-program*)
+       (check-for-inputs))