diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 7fc97d1..a1bc6fd 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -13,6 +13,7 @@ description "This is where you want to be when you are six feet under..." neighbour "Nowhere" +load-file lisp-test.atl load-file lisp-test2.atl start-place "Nowhere" \ No newline at end of file diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 7fc97d1..a1bc6fd 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -13,6 +13,7 @@ description "This is where you want to be when you are six feet under..." neighbour "Nowhere" +load-file lisp-test.atl load-file lisp-test2.atl start-place "Nowhere" \ No newline at end of file diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl index bf51367..8669177 100644 --- a/ATL/lisp-test2.atl +++ b/ATL/lisp-test2.atl @@ -6,3 +6,13 @@ description "Precisely where you do NOT want to end up..." neighbour "Nowhere" neighbour "Elysium" + +define-race "Elf" + description "The oldest and wisest race of Middle Earth" + +define-class "Burglar" + description "Breaking and entering taken to the max!" + special-item "lockpick" + special-item "torch" + +load-file lisp-test.atl \ No newline at end of file diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 7fc97d1..a1bc6fd 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -13,6 +13,7 @@ description "This is where you want to be when you are six feet under..." neighbour "Nowhere" +load-file lisp-test.atl load-file lisp-test2.atl start-place "Nowhere" \ No newline at end of file diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl index bf51367..8669177 100644 --- a/ATL/lisp-test2.atl +++ b/ATL/lisp-test2.atl @@ -6,3 +6,13 @@ description "Precisely where you do NOT want to end up..." neighbour "Nowhere" neighbour "Elysium" + +define-race "Elf" + description "The oldest and wisest race of Middle Earth" + +define-class "Burglar" + description "Breaking and entering taken to the max!" + special-item "lockpick" + special-item "torch" + +load-file lisp-test.atl \ No newline at end of file diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index eecc9e5..79b5a58 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -19,11 +19,21 @@ (format t "~&Making place ~A" name) (make-place :name name)) -(defun start-place (place) - ;not yet defined - ) +(defun define-race (name) + (format t "~&Making race ~A" name) + (make-race :name name)) -(let ((world-directory NIL)) +(defun define-class (name) + (format t "~&Making class ~A" name) + (make-character-class :name name)) + +(defun start-place (place) + ;; TODO + (format t "~&Starting place is ~A" place)) + + +(let ((world-directory NIL) + (loaded-files NIL)) (defun load-file (file-name) "Load and interpret an ATL source file" ;; save/load the current working directory @@ -32,7 +42,13 @@ :directory world-directory :name (pathname-name file-name) :type (pathname-type file-name))) - (setf world-directory (pathname-directory file-name))) + (progn + (setf world-directory (pathname-directory file-name)) + (setf file-name (parse-namestring file-name)))) + ;; check if this file has already been loaded + (if (member file-name loaded-files :test #'equalp) + (return-from load-file) + (setf loaded-files (cons file-name loaded-files))) ;; 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)) @@ -43,7 +59,6 @@ (incf line-nr) (setf line (concatenate 'string line (nth line-nr source)))) (cond ((zerop (length line)) - ;; TODO (when current-object (add-game-object current-object)) (setf current-object NIL)) ((eql (aref line 0) #\;)) ;Comments are ignored diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 7fc97d1..a1bc6fd 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -13,6 +13,7 @@ description "This is where you want to be when you are six feet under..." neighbour "Nowhere" +load-file lisp-test.atl load-file lisp-test2.atl start-place "Nowhere" \ No newline at end of file diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl index bf51367..8669177 100644 --- a/ATL/lisp-test2.atl +++ b/ATL/lisp-test2.atl @@ -6,3 +6,13 @@ description "Precisely where you do NOT want to end up..." neighbour "Nowhere" neighbour "Elysium" + +define-race "Elf" + description "The oldest and wisest race of Middle Earth" + +define-class "Burglar" + description "Breaking and entering taken to the max!" + special-item "lockpick" + special-item "torch" + +load-file lisp-test.atl \ No newline at end of file diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index eecc9e5..79b5a58 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -19,11 +19,21 @@ (format t "~&Making place ~A" name) (make-place :name name)) -(defun start-place (place) - ;not yet defined - ) +(defun define-race (name) + (format t "~&Making race ~A" name) + (make-race :name name)) -(let ((world-directory NIL)) +(defun define-class (name) + (format t "~&Making class ~A" name) + (make-character-class :name name)) + +(defun start-place (place) + ;; TODO + (format t "~&Starting place is ~A" place)) + + +(let ((world-directory NIL) + (loaded-files NIL)) (defun load-file (file-name) "Load and interpret an ATL source file" ;; save/load the current working directory @@ -32,7 +42,13 @@ :directory world-directory :name (pathname-name file-name) :type (pathname-type file-name))) - (setf world-directory (pathname-directory file-name))) + (progn + (setf world-directory (pathname-directory file-name)) + (setf file-name (parse-namestring file-name)))) + ;; check if this file has already been loaded + (if (member file-name loaded-files :test #'equalp) + (return-from load-file) + (setf loaded-files (cons file-name loaded-files))) ;; 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)) @@ -43,7 +59,6 @@ (incf line-nr) (setf line (concatenate 'string line (nth line-nr source)))) (cond ((zerop (length line)) - ;; TODO (when current-object (add-game-object current-object)) (setf current-object NIL)) ((eql (aref line 0) #\;)) ;Comments are ignored diff --git a/lisp/player.lisp b/lisp/player.lisp index 220e23b..bc050e8 100644 --- a/lisp/player.lisp +++ b/lisp/player.lisp @@ -19,3 +19,19 @@ (intelligence 0) (items NIL) (weapons NIL)) + + +(defstruct race + (name "") + (description "") + (strength-bonus 0) + (dexterity-bonus 0) + (constitution-bonus 0) + (intelligence-bonus 0) + (special-ability NIL)) + +(defstruct character-class + (name "") + (description "") + (special-item NIL) + (special-ability NIL)) diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 7fc97d1..a1bc6fd 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -13,6 +13,7 @@ description "This is where you want to be when you are six feet under..." neighbour "Nowhere" +load-file lisp-test.atl load-file lisp-test2.atl start-place "Nowhere" \ No newline at end of file diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl index bf51367..8669177 100644 --- a/ATL/lisp-test2.atl +++ b/ATL/lisp-test2.atl @@ -6,3 +6,13 @@ description "Precisely where you do NOT want to end up..." neighbour "Nowhere" neighbour "Elysium" + +define-race "Elf" + description "The oldest and wisest race of Middle Earth" + +define-class "Burglar" + description "Breaking and entering taken to the max!" + special-item "lockpick" + special-item "torch" + +load-file lisp-test.atl \ No newline at end of file diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index eecc9e5..79b5a58 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -19,11 +19,21 @@ (format t "~&Making place ~A" name) (make-place :name name)) -(defun start-place (place) - ;not yet defined - ) +(defun define-race (name) + (format t "~&Making race ~A" name) + (make-race :name name)) -(let ((world-directory NIL)) +(defun define-class (name) + (format t "~&Making class ~A" name) + (make-character-class :name name)) + +(defun start-place (place) + ;; TODO + (format t "~&Starting place is ~A" place)) + + +(let ((world-directory NIL) + (loaded-files NIL)) (defun load-file (file-name) "Load and interpret an ATL source file" ;; save/load the current working directory @@ -32,7 +42,13 @@ :directory world-directory :name (pathname-name file-name) :type (pathname-type file-name))) - (setf world-directory (pathname-directory file-name))) + (progn + (setf world-directory (pathname-directory file-name)) + (setf file-name (parse-namestring file-name)))) + ;; check if this file has already been loaded + (if (member file-name loaded-files :test #'equalp) + (return-from load-file) + (setf loaded-files (cons file-name loaded-files))) ;; 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)) @@ -43,7 +59,6 @@ (incf line-nr) (setf line (concatenate 'string line (nth line-nr source)))) (cond ((zerop (length line)) - ;; TODO (when current-object (add-game-object current-object)) (setf current-object NIL)) ((eql (aref line 0) #\;)) ;Comments are ignored diff --git a/lisp/player.lisp b/lisp/player.lisp index 220e23b..bc050e8 100644 --- a/lisp/player.lisp +++ b/lisp/player.lisp @@ -19,3 +19,19 @@ (intelligence 0) (items NIL) (weapons NIL)) + + +(defstruct race + (name "") + (description "") + (strength-bonus 0) + (dexterity-bonus 0) + (constitution-bonus 0) + (intelligence-bonus 0) + (special-ability NIL)) + +(defstruct character-class + (name "") + (description "") + (special-item NIL) + (special-ability NIL)) diff --git a/lisp/world.lisp b/lisp/world.lisp index c9eea68..b93c634 100644 --- a/lisp/world.lisp +++ b/lisp/world.lisp @@ -18,6 +18,8 @@ (defstruct world (players NIL) + (character-classs NIL) ;Bad English because of parsing issues + (races NIL) (places NIL) (monsters NIL) (npcs NIL)