(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") ;; TODO: should I use print-object & the reader for serialisation? (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))