diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl index 8669177..4861d59 100644 --- a/ATL/lisp-test2.atl +++ b/ATL/lisp-test2.atl @@ -15,4 +15,5 @@ special-item "lockpick" special-item "torch" -load-file lisp-test.atl \ No newline at end of file +load-file lisp-test.atl +load-file test-extension.lisp \ No newline at end of file diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl index 8669177..4861d59 100644 --- a/ATL/lisp-test2.atl +++ b/ATL/lisp-test2.atl @@ -15,4 +15,5 @@ special-item "lockpick" special-item "torch" -load-file lisp-test.atl \ No newline at end of file +load-file lisp-test.atl +load-file test-extension.lisp \ No newline at end of file diff --git a/ATL/test-extension.lisp b/ATL/test-extension.lisp new file mode 100644 index 0000000..3f261b4 --- /dev/null +++ b/ATL/test-extension.lisp @@ -0,0 +1,5 @@ +;; This file tests whether the interpreter loads Lisp files correctly. +;; author: Daniel Vedder +;; date: 21/05/2015 + +(format t "~&Loaded Lisp extension file.") diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl index 8669177..4861d59 100644 --- a/ATL/lisp-test2.atl +++ b/ATL/lisp-test2.atl @@ -15,4 +15,5 @@ special-item "lockpick" special-item "torch" -load-file lisp-test.atl \ No newline at end of file +load-file lisp-test.atl +load-file test-extension.lisp \ No newline at end of file diff --git a/ATL/test-extension.lisp b/ATL/test-extension.lisp new file mode 100644 index 0000000..3f261b4 --- /dev/null +++ b/ATL/test-extension.lisp @@ -0,0 +1,5 @@ +;; This file tests whether the interpreter loads Lisp files correctly. +;; author: Daniel Vedder +;; date: 21/05/2015 + +(format t "~&Loaded Lisp extension file.") diff --git a/LICENSE b/LICENSE index 49cb2b0..66fc13a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -ATLANTIS +ATLANTIS LICENSE Copyright (c) 2015 Daniel Vedder @@ -19,3 +19,4 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl index 8669177..4861d59 100644 --- a/ATL/lisp-test2.atl +++ b/ATL/lisp-test2.atl @@ -15,4 +15,5 @@ special-item "lockpick" special-item "torch" -load-file lisp-test.atl \ No newline at end of file +load-file lisp-test.atl +load-file test-extension.lisp \ No newline at end of file diff --git a/ATL/test-extension.lisp b/ATL/test-extension.lisp new file mode 100644 index 0000000..3f261b4 --- /dev/null +++ b/ATL/test-extension.lisp @@ -0,0 +1,5 @@ +;; This file tests whether the interpreter loads Lisp files correctly. +;; author: Daniel Vedder +;; date: 21/05/2015 + +(format t "~&Loaded Lisp extension file.") diff --git a/LICENSE b/LICENSE index 49cb2b0..66fc13a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -ATLANTIS +ATLANTIS LICENSE Copyright (c) 2015 Daniel Vedder @@ -19,3 +19,4 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 2bcbb5b..288cd46 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -29,11 +29,11 @@ (input-string ip) (while (not (= (count-instances #\. (to-list ip)) 3)) (format t "~&Not an IP address: ~A. Please reenter:" ip) - (input ip)) + (input-string ip)) (format t "~&What port does the game run on?") (while (not (numberp (input port))) (format t "~&Not a number: ~A. Please reenter:" port)) - (format t "~&Joining game on ~A:~A" (symbol-name ip) port)) + (format t "~&Joining game on ~A:~A" ip port)) (defun print-version () @@ -50,9 +50,9 @@ (defun start-menu () "Show the start menu and take a choice from the user" - (let ((logo (load-text-file "banner.txt"))) - (dolist (line logo) - (unless (null line) (format t "~%~A" line)))) +; (let ((logo (load-text-file "banner.txt"))) + (dolist (line (load-text-file "banner.txt")) + (unless (null line) (format t "~%~A" line))) (format t "~&~%Welcome! What do you want to do?") (format t "~&-> (S)tart a server") (format t "~&-> (J)oin a game") @@ -62,7 +62,11 @@ (cond ((equalp choice 's) (start-server)) ((equalp choice 'j) (join-game)) ((equalp choice 'a) - (print-version) (start-menu)) + (print-version) + (when (y-or-n-p "~%Show the license text?") + (dolist (line (load-text-file "../LICENSE")) + (unless (null line) (format t "~%~A" line)))) + (start-menu)) ((equalp choice 'e) (format t "~&Goodbye!") (quit)))) diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl index 8669177..4861d59 100644 --- a/ATL/lisp-test2.atl +++ b/ATL/lisp-test2.atl @@ -15,4 +15,5 @@ special-item "lockpick" special-item "torch" -load-file lisp-test.atl \ No newline at end of file +load-file lisp-test.atl +load-file test-extension.lisp \ No newline at end of file diff --git a/ATL/test-extension.lisp b/ATL/test-extension.lisp new file mode 100644 index 0000000..3f261b4 --- /dev/null +++ b/ATL/test-extension.lisp @@ -0,0 +1,5 @@ +;; This file tests whether the interpreter loads Lisp files correctly. +;; author: Daniel Vedder +;; date: 21/05/2015 + +(format t "~&Loaded Lisp extension file.") diff --git a/LICENSE b/LICENSE index 49cb2b0..66fc13a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -ATLANTIS +ATLANTIS LICENSE Copyright (c) 2015 Daniel Vedder @@ -19,3 +19,4 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 2bcbb5b..288cd46 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -29,11 +29,11 @@ (input-string ip) (while (not (= (count-instances #\. (to-list ip)) 3)) (format t "~&Not an IP address: ~A. Please reenter:" ip) - (input ip)) + (input-string ip)) (format t "~&What port does the game run on?") (while (not (numberp (input port))) (format t "~&Not a number: ~A. Please reenter:" port)) - (format t "~&Joining game on ~A:~A" (symbol-name ip) port)) + (format t "~&Joining game on ~A:~A" ip port)) (defun print-version () @@ -50,9 +50,9 @@ (defun start-menu () "Show the start menu and take a choice from the user" - (let ((logo (load-text-file "banner.txt"))) - (dolist (line logo) - (unless (null line) (format t "~%~A" line)))) +; (let ((logo (load-text-file "banner.txt"))) + (dolist (line (load-text-file "banner.txt")) + (unless (null line) (format t "~%~A" line))) (format t "~&~%Welcome! What do you want to do?") (format t "~&-> (S)tart a server") (format t "~&-> (J)oin a game") @@ -62,7 +62,11 @@ (cond ((equalp choice 's) (start-server)) ((equalp choice 'j) (join-game)) ((equalp choice 'a) - (print-version) (start-menu)) + (print-version) + (when (y-or-n-p "~%Show the license text?") + (dolist (line (load-text-file "../LICENSE")) + (unless (null line) (format t "~%~A" line)))) + (start-menu)) ((equalp choice 'e) (format t "~&Goodbye!") (quit)))) diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index 79b5a58..2c5b87d 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -28,14 +28,15 @@ (make-character-class :name name)) (defun start-place (place) - ;; TODO - (format t "~&Starting place is ~A" place)) + (format t "~&Starting place is ~A" place) + (setf (world-starting-place *world*) place) + NIL) (let ((world-directory NIL) (loaded-files NIL)) (defun load-file (file-name) - "Load and interpret an ATL source file" + "Load and interpret an ATL source file or a Lisp extension file" ;; save/load the current working directory (if (null (pathname-directory file-name)) (setf file-name (make-pathname @@ -49,7 +50,11 @@ (if (member file-name loaded-files :test #'equalp) (return-from load-file) (setf loaded-files (cons file-name loaded-files))) - ;; parse the ATL file + ;; check if this is a Lisp extension file + (when (equalp (pathname-type file-name) "lisp") + (load file-name) + (return-from load-file)) + ;; otherwise, parse the ATL file (do* ((line-nr 0 (1+ line-nr)) (source (load-text-file file-name)) (line (nth line-nr source) (nth line-nr source)) (current-object NIL)) diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl index 8669177..4861d59 100644 --- a/ATL/lisp-test2.atl +++ b/ATL/lisp-test2.atl @@ -15,4 +15,5 @@ special-item "lockpick" special-item "torch" -load-file lisp-test.atl \ No newline at end of file +load-file lisp-test.atl +load-file test-extension.lisp \ No newline at end of file diff --git a/ATL/test-extension.lisp b/ATL/test-extension.lisp new file mode 100644 index 0000000..3f261b4 --- /dev/null +++ b/ATL/test-extension.lisp @@ -0,0 +1,5 @@ +;; This file tests whether the interpreter loads Lisp files correctly. +;; author: Daniel Vedder +;; date: 21/05/2015 + +(format t "~&Loaded Lisp extension file.") diff --git a/LICENSE b/LICENSE index 49cb2b0..66fc13a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -ATLANTIS +ATLANTIS LICENSE Copyright (c) 2015 Daniel Vedder @@ -19,3 +19,4 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 2bcbb5b..288cd46 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -29,11 +29,11 @@ (input-string ip) (while (not (= (count-instances #\. (to-list ip)) 3)) (format t "~&Not an IP address: ~A. Please reenter:" ip) - (input ip)) + (input-string ip)) (format t "~&What port does the game run on?") (while (not (numberp (input port))) (format t "~&Not a number: ~A. Please reenter:" port)) - (format t "~&Joining game on ~A:~A" (symbol-name ip) port)) + (format t "~&Joining game on ~A:~A" ip port)) (defun print-version () @@ -50,9 +50,9 @@ (defun start-menu () "Show the start menu and take a choice from the user" - (let ((logo (load-text-file "banner.txt"))) - (dolist (line logo) - (unless (null line) (format t "~%~A" line)))) +; (let ((logo (load-text-file "banner.txt"))) + (dolist (line (load-text-file "banner.txt")) + (unless (null line) (format t "~%~A" line))) (format t "~&~%Welcome! What do you want to do?") (format t "~&-> (S)tart a server") (format t "~&-> (J)oin a game") @@ -62,7 +62,11 @@ (cond ((equalp choice 's) (start-server)) ((equalp choice 'j) (join-game)) ((equalp choice 'a) - (print-version) (start-menu)) + (print-version) + (when (y-or-n-p "~%Show the license text?") + (dolist (line (load-text-file "../LICENSE")) + (unless (null line) (format t "~%~A" line)))) + (start-menu)) ((equalp choice 'e) (format t "~&Goodbye!") (quit)))) diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index 79b5a58..2c5b87d 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -28,14 +28,15 @@ (make-character-class :name name)) (defun start-place (place) - ;; TODO - (format t "~&Starting place is ~A" place)) + (format t "~&Starting place is ~A" place) + (setf (world-starting-place *world*) place) + NIL) (let ((world-directory NIL) (loaded-files NIL)) (defun load-file (file-name) - "Load and interpret an ATL source file" + "Load and interpret an ATL source file or a Lisp extension file" ;; save/load the current working directory (if (null (pathname-directory file-name)) (setf file-name (make-pathname @@ -49,7 +50,11 @@ (if (member file-name loaded-files :test #'equalp) (return-from load-file) (setf loaded-files (cons file-name loaded-files))) - ;; parse the ATL file + ;; check if this is a Lisp extension file + (when (equalp (pathname-type file-name) "lisp") + (load file-name) + (return-from load-file)) + ;; otherwise, parse the ATL file (do* ((line-nr 0 (1+ line-nr)) (source (load-text-file file-name)) (line (nth line-nr source) (nth line-nr source)) (current-object NIL)) diff --git a/lisp/player.lisp b/lisp/player.lisp index bc050e8..03f2333 100644 --- a/lisp/player.lisp +++ b/lisp/player.lisp @@ -18,7 +18,8 @@ (constitution 0) (intelligence 0) (items NIL) - (weapons NIL)) + (weapons NIL) + (place)) (defstruct race diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl index 8669177..4861d59 100644 --- a/ATL/lisp-test2.atl +++ b/ATL/lisp-test2.atl @@ -15,4 +15,5 @@ special-item "lockpick" special-item "torch" -load-file lisp-test.atl \ No newline at end of file +load-file lisp-test.atl +load-file test-extension.lisp \ No newline at end of file diff --git a/ATL/test-extension.lisp b/ATL/test-extension.lisp new file mode 100644 index 0000000..3f261b4 --- /dev/null +++ b/ATL/test-extension.lisp @@ -0,0 +1,5 @@ +;; This file tests whether the interpreter loads Lisp files correctly. +;; author: Daniel Vedder +;; date: 21/05/2015 + +(format t "~&Loaded Lisp extension file.") diff --git a/LICENSE b/LICENSE index 49cb2b0..66fc13a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -ATLANTIS +ATLANTIS LICENSE Copyright (c) 2015 Daniel Vedder @@ -19,3 +19,4 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 2bcbb5b..288cd46 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -29,11 +29,11 @@ (input-string ip) (while (not (= (count-instances #\. (to-list ip)) 3)) (format t "~&Not an IP address: ~A. Please reenter:" ip) - (input ip)) + (input-string ip)) (format t "~&What port does the game run on?") (while (not (numberp (input port))) (format t "~&Not a number: ~A. Please reenter:" port)) - (format t "~&Joining game on ~A:~A" (symbol-name ip) port)) + (format t "~&Joining game on ~A:~A" ip port)) (defun print-version () @@ -50,9 +50,9 @@ (defun start-menu () "Show the start menu and take a choice from the user" - (let ((logo (load-text-file "banner.txt"))) - (dolist (line logo) - (unless (null line) (format t "~%~A" line)))) +; (let ((logo (load-text-file "banner.txt"))) + (dolist (line (load-text-file "banner.txt")) + (unless (null line) (format t "~%~A" line))) (format t "~&~%Welcome! What do you want to do?") (format t "~&-> (S)tart a server") (format t "~&-> (J)oin a game") @@ -62,7 +62,11 @@ (cond ((equalp choice 's) (start-server)) ((equalp choice 'j) (join-game)) ((equalp choice 'a) - (print-version) (start-menu)) + (print-version) + (when (y-or-n-p "~%Show the license text?") + (dolist (line (load-text-file "../LICENSE")) + (unless (null line) (format t "~%~A" line)))) + (start-menu)) ((equalp choice 'e) (format t "~&Goodbye!") (quit)))) diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index 79b5a58..2c5b87d 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -28,14 +28,15 @@ (make-character-class :name name)) (defun start-place (place) - ;; TODO - (format t "~&Starting place is ~A" place)) + (format t "~&Starting place is ~A" place) + (setf (world-starting-place *world*) place) + NIL) (let ((world-directory NIL) (loaded-files NIL)) (defun load-file (file-name) - "Load and interpret an ATL source file" + "Load and interpret an ATL source file or a Lisp extension file" ;; save/load the current working directory (if (null (pathname-directory file-name)) (setf file-name (make-pathname @@ -49,7 +50,11 @@ (if (member file-name loaded-files :test #'equalp) (return-from load-file) (setf loaded-files (cons file-name loaded-files))) - ;; parse the ATL file + ;; check if this is a Lisp extension file + (when (equalp (pathname-type file-name) "lisp") + (load file-name) + (return-from load-file)) + ;; otherwise, parse the ATL file (do* ((line-nr 0 (1+ line-nr)) (source (load-text-file file-name)) (line (nth line-nr source) (nth line-nr source)) (current-object NIL)) diff --git a/lisp/player.lisp b/lisp/player.lisp index bc050e8..03f2333 100644 --- a/lisp/player.lisp +++ b/lisp/player.lisp @@ -18,7 +18,8 @@ (constitution 0) (intelligence 0) (items NIL) - (weapons NIL)) + (weapons NIL) + (place)) (defstruct race diff --git a/lisp/world.lisp b/lisp/world.lisp index b93c634..3a01bdc 100644 --- a/lisp/world.lisp +++ b/lisp/world.lisp @@ -23,7 +23,8 @@ (places NIL) (monsters NIL) (npcs NIL) - (items NIL)) + (items NIL) + (starting-place "")) (setf *world* (make-world))