From ca5768f305d4f7d152fe3f8098be28914086ca7e Mon Sep 17 00:00:00 2001 From: Darren Bane Date: Sun, 6 Dec 2020 12:52:55 +0000 Subject: Try port the Ada 16k MUD competition entry to CL --- ccap-muck.lisp | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 ccap-muck.lisp 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 () ((name :accessor name) + (playing :reader playing :initform nil) + (password :accessor password))) +(defvar *avatars* '()) + +(defvar *write-avatars* nil) + +(defclass () ((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 () ((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 ')))) + (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)) -- cgit 1.4.1-2-gfad0