diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index e8ea1df..3740f83 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -12,7 +12,7 @@ '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "name-world" "load-file" "start-place") + "define-race" "define-place" "name-world" "load-file" "start-place") '() ;; other commands (adjust this? '("\\.atl$") ;; files for which to activate this mode '(#'(lambda () (setq linum-mode T))) ;; other functions to call diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index e8ea1df..3740f83 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -12,7 +12,7 @@ '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "name-world" "load-file" "start-place") + "define-race" "define-place" "name-world" "load-file" "start-place") '() ;; other commands (adjust this? '("\\.atl$") ;; files for which to activate this mode '(#'(lambda () (setq linum-mode T))) ;; other functions to call diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 5a598d0..c95dd2f 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -3,7 +3,7 @@ ; @date 04/05/2015 ; TODO change the name of this command? -name-world "Los Alamos" +name-world "Westernesse" define-place "Nowhere" description "Welcome to Nowhere! @@ -21,7 +21,7 @@ neighbour "Nowhere" neighbour "Elysium" -load-file lisp-test.atl -load-file lisp-test2.atl +load-file lisp-test.atl ;Testing whether recursive loading is prevented +load-file races-classes.atl start-place "Nowhere" \ No newline at end of file diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index e8ea1df..3740f83 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -12,7 +12,7 @@ '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "name-world" "load-file" "start-place") + "define-race" "define-place" "name-world" "load-file" "start-place") '() ;; other commands (adjust this? '("\\.atl$") ;; files for which to activate this mode '(#'(lambda () (setq linum-mode T))) ;; other functions to call diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 5a598d0..c95dd2f 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -3,7 +3,7 @@ ; @date 04/05/2015 ; TODO change the name of this command? -name-world "Los Alamos" +name-world "Westernesse" define-place "Nowhere" description "Welcome to Nowhere! @@ -21,7 +21,7 @@ neighbour "Nowhere" neighbour "Elysium" -load-file lisp-test.atl -load-file lisp-test2.atl +load-file lisp-test.atl ;Testing whether recursive loading is prevented +load-file races-classes.atl start-place "Nowhere" \ No newline at end of file diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl deleted file mode 100644 index 3a4eadb..0000000 --- a/ATL/lisp-test2.atl +++ /dev/null @@ -1,27 +0,0 @@ -; Just a very small file to test whether the load function works properly -; @author Daniel Vedder -; @date 18/05/2015 - -define-race "Elf" - description "The oldest and wisest race of Middle Earth" - -define-race "Dwarf" - description "Sons of the Earth, descendants of Durin" - -define-race "Hobbit" - description "Peace-loving and kind, true gentlemen" - -define-class "Warrior" - description "Fighting as a passion!" - -define-class "Wizard" - description "Ancient, powerful, keepers of the Knowledge..." - special-item "staff" - -define-class "Burglar" - description "Breaking and entering taken to the max!" - special-item "lockpick" - special-item "torch" - -load-file lisp-test.atl -load-file test-extension.lisp \ No newline at end of file diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index e8ea1df..3740f83 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -12,7 +12,7 @@ '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "name-world" "load-file" "start-place") + "define-race" "define-place" "name-world" "load-file" "start-place") '() ;; other commands (adjust this? '("\\.atl$") ;; files for which to activate this mode '(#'(lambda () (setq linum-mode T))) ;; other functions to call diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 5a598d0..c95dd2f 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -3,7 +3,7 @@ ; @date 04/05/2015 ; TODO change the name of this command? -name-world "Los Alamos" +name-world "Westernesse" define-place "Nowhere" description "Welcome to Nowhere! @@ -21,7 +21,7 @@ neighbour "Nowhere" neighbour "Elysium" -load-file lisp-test.atl -load-file lisp-test2.atl +load-file lisp-test.atl ;Testing whether recursive loading is prevented +load-file races-classes.atl start-place "Nowhere" \ No newline at end of file diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl deleted file mode 100644 index 3a4eadb..0000000 --- a/ATL/lisp-test2.atl +++ /dev/null @@ -1,27 +0,0 @@ -; Just a very small file to test whether the load function works properly -; @author Daniel Vedder -; @date 18/05/2015 - -define-race "Elf" - description "The oldest and wisest race of Middle Earth" - -define-race "Dwarf" - description "Sons of the Earth, descendants of Durin" - -define-race "Hobbit" - description "Peace-loving and kind, true gentlemen" - -define-class "Warrior" - description "Fighting as a passion!" - -define-class "Wizard" - description "Ancient, powerful, keepers of the Knowledge..." - special-item "staff" - -define-class "Burglar" - description "Breaking and entering taken to the max!" - special-item "lockpick" - special-item "torch" - -load-file lisp-test.atl -load-file test-extension.lisp \ No newline at end of file diff --git a/ATL/races-classes.atl b/ATL/races-classes.atl new file mode 100644 index 0000000..659310f --- /dev/null +++ b/ATL/races-classes.atl @@ -0,0 +1,40 @@ +; A file to define all the races and character classes in my test world. +; @author Daniel Vedder +; @date 18/05/2015 + +;;; RACES + +define-race "Elf" + description "The oldest and wisest race of Middle Earth" + +define-race "Dwarf" + description "Sons of the Earth, descendants of Durin" + +define-race "Hobbit" + description "Peace-loving and kind, true gentlemen" + +define-race "Human" + description "Boring, exciting, ever-changing, never-changing man..." + + +;;; CLASSES + +define-class "Warrior" + description "Fighting as a passion!" + special-item "Sword" + +define-class "Wizard" + description "Ancient, powerful, keepers of the Knowledge..." + special-item "staff" + +define-class "Burglar" + description "Breaking and entering taken to the max!" + special-item "lockpick" + special-item "torch" + +define-class "Craftsman" + description "Maker of all things beautiful and useful" + special-item "hammer" + +load-file lisp-test.atl ;Again, a test for recursive loading +load-file test-extension.lisp ;Testing whether Lisp extensions are loaded \ No newline at end of file diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index e8ea1df..3740f83 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -12,7 +12,7 @@ '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "name-world" "load-file" "start-place") + "define-race" "define-place" "name-world" "load-file" "start-place") '() ;; other commands (adjust this? '("\\.atl$") ;; files for which to activate this mode '(#'(lambda () (setq linum-mode T))) ;; other functions to call diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 5a598d0..c95dd2f 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -3,7 +3,7 @@ ; @date 04/05/2015 ; TODO change the name of this command? -name-world "Los Alamos" +name-world "Westernesse" define-place "Nowhere" description "Welcome to Nowhere! @@ -21,7 +21,7 @@ neighbour "Nowhere" neighbour "Elysium" -load-file lisp-test.atl -load-file lisp-test2.atl +load-file lisp-test.atl ;Testing whether recursive loading is prevented +load-file races-classes.atl start-place "Nowhere" \ No newline at end of file diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl deleted file mode 100644 index 3a4eadb..0000000 --- a/ATL/lisp-test2.atl +++ /dev/null @@ -1,27 +0,0 @@ -; Just a very small file to test whether the load function works properly -; @author Daniel Vedder -; @date 18/05/2015 - -define-race "Elf" - description "The oldest and wisest race of Middle Earth" - -define-race "Dwarf" - description "Sons of the Earth, descendants of Durin" - -define-race "Hobbit" - description "Peace-loving and kind, true gentlemen" - -define-class "Warrior" - description "Fighting as a passion!" - -define-class "Wizard" - description "Ancient, powerful, keepers of the Knowledge..." - special-item "staff" - -define-class "Burglar" - description "Breaking and entering taken to the max!" - special-item "lockpick" - special-item "torch" - -load-file lisp-test.atl -load-file test-extension.lisp \ No newline at end of file diff --git a/ATL/races-classes.atl b/ATL/races-classes.atl new file mode 100644 index 0000000..659310f --- /dev/null +++ b/ATL/races-classes.atl @@ -0,0 +1,40 @@ +; A file to define all the races and character classes in my test world. +; @author Daniel Vedder +; @date 18/05/2015 + +;;; RACES + +define-race "Elf" + description "The oldest and wisest race of Middle Earth" + +define-race "Dwarf" + description "Sons of the Earth, descendants of Durin" + +define-race "Hobbit" + description "Peace-loving and kind, true gentlemen" + +define-race "Human" + description "Boring, exciting, ever-changing, never-changing man..." + + +;;; CLASSES + +define-class "Warrior" + description "Fighting as a passion!" + special-item "Sword" + +define-class "Wizard" + description "Ancient, powerful, keepers of the Knowledge..." + special-item "staff" + +define-class "Burglar" + description "Breaking and entering taken to the max!" + special-item "lockpick" + special-item "torch" + +define-class "Craftsman" + description "Maker of all things beautiful and useful" + special-item "hammer" + +load-file lisp-test.atl ;Again, a test for recursive loading +load-file test-extension.lisp ;Testing whether Lisp extensions are loaded \ No newline at end of file diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index e8ddc0b..0e0c3a7 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -14,6 +14,18 @@ (load 'client.lisp) +(defun development () + "A method to easily test whatever feature I am currently developing" + (load-file "../ATL/lisp-test.atl") + (let ((player (make-player :name "Bilbo" + :race (get-game-object 'race "Hobbit") + :class (get-game-object 'character-class "Burglar") + :place (world-starting-place *world*) + :strength 6 :constitution 12 + :dexterity 19 :intelligence 14))) + (add-game-object player) + (play-game (player-name player)))) + (defun start-server () "Start a new game on a server" (format t "~&What world file do you want to load?") @@ -62,17 +74,19 @@ (format t "~&-> (J)oin a game") (format t "~&-> (A)bout") (format t "~&-> (E)xit") + (format t "~&-> (D)evelop") ;XXX Remove later (input choice) - (cond ((equalp choice 's) (start-server)) - ((equalp choice 'j) (join-game)) - ((equalp choice 'a) + (cond ((eq choice 's) (start-server)) + ((eq choice 'j) (join-game)) + ((eq choice 'a) (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) + ((eq choice 'e) (format t "~&Goodbye!") (quit)) + ((eq choice 'd) (development)) (t (format t "~&Invalid choice!") (start-menu)))) (defun cmd-parameter (name &optional truth-value) @@ -89,7 +103,6 @@ (let ((server (cmd-parameter "--server")) (world-file (cmd-parameter "--world")) (client (cmd-parameter "--client"))) - ;(break) (if (or world-file server) ;TODO change OR to AND (load-file world-file) (format t "~&Sorry, the client is not yet available!")))) diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index e8ea1df..3740f83 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -12,7 +12,7 @@ '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "name-world" "load-file" "start-place") + "define-race" "define-place" "name-world" "load-file" "start-place") '() ;; other commands (adjust this? '("\\.atl$") ;; files for which to activate this mode '(#'(lambda () (setq linum-mode T))) ;; other functions to call diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 5a598d0..c95dd2f 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -3,7 +3,7 @@ ; @date 04/05/2015 ; TODO change the name of this command? -name-world "Los Alamos" +name-world "Westernesse" define-place "Nowhere" description "Welcome to Nowhere! @@ -21,7 +21,7 @@ neighbour "Nowhere" neighbour "Elysium" -load-file lisp-test.atl -load-file lisp-test2.atl +load-file lisp-test.atl ;Testing whether recursive loading is prevented +load-file races-classes.atl start-place "Nowhere" \ No newline at end of file diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl deleted file mode 100644 index 3a4eadb..0000000 --- a/ATL/lisp-test2.atl +++ /dev/null @@ -1,27 +0,0 @@ -; Just a very small file to test whether the load function works properly -; @author Daniel Vedder -; @date 18/05/2015 - -define-race "Elf" - description "The oldest and wisest race of Middle Earth" - -define-race "Dwarf" - description "Sons of the Earth, descendants of Durin" - -define-race "Hobbit" - description "Peace-loving and kind, true gentlemen" - -define-class "Warrior" - description "Fighting as a passion!" - -define-class "Wizard" - description "Ancient, powerful, keepers of the Knowledge..." - special-item "staff" - -define-class "Burglar" - description "Breaking and entering taken to the max!" - special-item "lockpick" - special-item "torch" - -load-file lisp-test.atl -load-file test-extension.lisp \ No newline at end of file diff --git a/ATL/races-classes.atl b/ATL/races-classes.atl new file mode 100644 index 0000000..659310f --- /dev/null +++ b/ATL/races-classes.atl @@ -0,0 +1,40 @@ +; A file to define all the races and character classes in my test world. +; @author Daniel Vedder +; @date 18/05/2015 + +;;; RACES + +define-race "Elf" + description "The oldest and wisest race of Middle Earth" + +define-race "Dwarf" + description "Sons of the Earth, descendants of Durin" + +define-race "Hobbit" + description "Peace-loving and kind, true gentlemen" + +define-race "Human" + description "Boring, exciting, ever-changing, never-changing man..." + + +;;; CLASSES + +define-class "Warrior" + description "Fighting as a passion!" + special-item "Sword" + +define-class "Wizard" + description "Ancient, powerful, keepers of the Knowledge..." + special-item "staff" + +define-class "Burglar" + description "Breaking and entering taken to the max!" + special-item "lockpick" + special-item "torch" + +define-class "Craftsman" + description "Maker of all things beautiful and useful" + special-item "hammer" + +load-file lisp-test.atl ;Again, a test for recursive loading +load-file test-extension.lisp ;Testing whether Lisp extensions are loaded \ No newline at end of file diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index e8ddc0b..0e0c3a7 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -14,6 +14,18 @@ (load 'client.lisp) +(defun development () + "A method to easily test whatever feature I am currently developing" + (load-file "../ATL/lisp-test.atl") + (let ((player (make-player :name "Bilbo" + :race (get-game-object 'race "Hobbit") + :class (get-game-object 'character-class "Burglar") + :place (world-starting-place *world*) + :strength 6 :constitution 12 + :dexterity 19 :intelligence 14))) + (add-game-object player) + (play-game (player-name player)))) + (defun start-server () "Start a new game on a server" (format t "~&What world file do you want to load?") @@ -62,17 +74,19 @@ (format t "~&-> (J)oin a game") (format t "~&-> (A)bout") (format t "~&-> (E)xit") + (format t "~&-> (D)evelop") ;XXX Remove later (input choice) - (cond ((equalp choice 's) (start-server)) - ((equalp choice 'j) (join-game)) - ((equalp choice 'a) + (cond ((eq choice 's) (start-server)) + ((eq choice 'j) (join-game)) + ((eq choice 'a) (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) + ((eq choice 'e) (format t "~&Goodbye!") (quit)) + ((eq choice 'd) (development)) (t (format t "~&Invalid choice!") (start-menu)))) (defun cmd-parameter (name &optional truth-value) @@ -89,7 +103,6 @@ (let ((server (cmd-parameter "--server")) (world-file (cmd-parameter "--world")) (client (cmd-parameter "--client"))) - ;(break) (if (or world-file server) ;TODO change OR to AND (load-file world-file) (format t "~&Sorry, the client is not yet available!")))) diff --git a/lisp/client.lisp b/lisp/client.lisp index 0c19f60..3a99a98 100644 --- a/lisp/client.lisp +++ b/lisp/client.lisp @@ -12,18 +12,24 @@ ;;; (let ((player NIL)) - (defun play-game (&optional player-name) + (defun play-game (player-name) "The main game loop" - ;; XXX Development - (when (y-or-n-p "~&Load the test world?") - (load-file "../ATL/lisp-test.atl")) ;; Initialize the player if necessary (when (null player) - (if player-name - (setf player (get-game-object 'player player-name)) - (error "~&No player name specified!"))) + (setf player (get-game-object 'player player-name))) (when (null player) - (setf player (create-player player-name))))) + (setf player (create-player player-name)) + (add-game-object player) + (set-object-attribute (get-game-object 'place (player-place player)) + 'player (player-name player))) + ;; The actual game loop + (let ((place (get-game-object 'place (player-place player)))) + (describe-place place) + (input-string command) + (while (!= (read-from-string command) 'quit) + (game-command command player) + (input-string command)) + (format t "~&Goodbye!")))) (defun create-player (player-name) "The user creates a new player" @@ -78,7 +84,36 @@ (simple-input val (concatenate 'string (symbol-name attr) ":"))) ;; FIXME Gives problems if two equal numbers are in char-points (let ((player-fn (build-symbol "player-" attr))) - ;; XXX Kludge! + ;; XXX Kludge ?! (eval `(setf (,player-fn ,player) ,val))) (setf character-points (remove-if #'(lambda (x) (= x val)) character-points))))) + +(defun describe-place (p) + "Print out a complete description of place p" + (format t "~&~%~A" (place-description p)) + (format t "~&Neighbouring places: ~A" (string-from-list (place-neighbour p))) + (format t "~&Players present: ~A" (string-from-list (place-player p))) + (format t "~&Items: ~A" (string-from-list (place-item p)))) + +(defun game-command (cmd player) + "Execute a typed-in game command" + (let ((space (position #\Space cmd))) + (if space + (call-function (read-from-string cmd) + (read-from-string (second (cut-string cmd space))) player) + (call-function (read-from-string cmd) player)))) + +;;; Here follow the functions that define the in-game commands. +;;; All of them have to take exactly two argument (the argument +;;; to the function and a player instance). + +(defun help (&optional arg player) + "Print out a list of in-game commands" + (format t "~&Sorry, not yet available!")) + +(defun goto (location player) + "Go to the specified location" + (set-object-attribute player 'place location) + (set-object-attribute (get-game-object 'place (player-place player)) + 'player (player-name player))) diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index e8ea1df..3740f83 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -12,7 +12,7 @@ '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "name-world" "load-file" "start-place") + "define-race" "define-place" "name-world" "load-file" "start-place") '() ;; other commands (adjust this? '("\\.atl$") ;; files for which to activate this mode '(#'(lambda () (setq linum-mode T))) ;; other functions to call diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 5a598d0..c95dd2f 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -3,7 +3,7 @@ ; @date 04/05/2015 ; TODO change the name of this command? -name-world "Los Alamos" +name-world "Westernesse" define-place "Nowhere" description "Welcome to Nowhere! @@ -21,7 +21,7 @@ neighbour "Nowhere" neighbour "Elysium" -load-file lisp-test.atl -load-file lisp-test2.atl +load-file lisp-test.atl ;Testing whether recursive loading is prevented +load-file races-classes.atl start-place "Nowhere" \ No newline at end of file diff --git a/ATL/lisp-test2.atl b/ATL/lisp-test2.atl deleted file mode 100644 index 3a4eadb..0000000 --- a/ATL/lisp-test2.atl +++ /dev/null @@ -1,27 +0,0 @@ -; Just a very small file to test whether the load function works properly -; @author Daniel Vedder -; @date 18/05/2015 - -define-race "Elf" - description "The oldest and wisest race of Middle Earth" - -define-race "Dwarf" - description "Sons of the Earth, descendants of Durin" - -define-race "Hobbit" - description "Peace-loving and kind, true gentlemen" - -define-class "Warrior" - description "Fighting as a passion!" - -define-class "Wizard" - description "Ancient, powerful, keepers of the Knowledge..." - special-item "staff" - -define-class "Burglar" - description "Breaking and entering taken to the max!" - special-item "lockpick" - special-item "torch" - -load-file lisp-test.atl -load-file test-extension.lisp \ No newline at end of file diff --git a/ATL/races-classes.atl b/ATL/races-classes.atl new file mode 100644 index 0000000..659310f --- /dev/null +++ b/ATL/races-classes.atl @@ -0,0 +1,40 @@ +; A file to define all the races and character classes in my test world. +; @author Daniel Vedder +; @date 18/05/2015 + +;;; RACES + +define-race "Elf" + description "The oldest and wisest race of Middle Earth" + +define-race "Dwarf" + description "Sons of the Earth, descendants of Durin" + +define-race "Hobbit" + description "Peace-loving and kind, true gentlemen" + +define-race "Human" + description "Boring, exciting, ever-changing, never-changing man..." + + +;;; CLASSES + +define-class "Warrior" + description "Fighting as a passion!" + special-item "Sword" + +define-class "Wizard" + description "Ancient, powerful, keepers of the Knowledge..." + special-item "staff" + +define-class "Burglar" + description "Breaking and entering taken to the max!" + special-item "lockpick" + special-item "torch" + +define-class "Craftsman" + description "Maker of all things beautiful and useful" + special-item "hammer" + +load-file lisp-test.atl ;Again, a test for recursive loading +load-file test-extension.lisp ;Testing whether Lisp extensions are loaded \ No newline at end of file diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index e8ddc0b..0e0c3a7 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -14,6 +14,18 @@ (load 'client.lisp) +(defun development () + "A method to easily test whatever feature I am currently developing" + (load-file "../ATL/lisp-test.atl") + (let ((player (make-player :name "Bilbo" + :race (get-game-object 'race "Hobbit") + :class (get-game-object 'character-class "Burglar") + :place (world-starting-place *world*) + :strength 6 :constitution 12 + :dexterity 19 :intelligence 14))) + (add-game-object player) + (play-game (player-name player)))) + (defun start-server () "Start a new game on a server" (format t "~&What world file do you want to load?") @@ -62,17 +74,19 @@ (format t "~&-> (J)oin a game") (format t "~&-> (A)bout") (format t "~&-> (E)xit") + (format t "~&-> (D)evelop") ;XXX Remove later (input choice) - (cond ((equalp choice 's) (start-server)) - ((equalp choice 'j) (join-game)) - ((equalp choice 'a) + (cond ((eq choice 's) (start-server)) + ((eq choice 'j) (join-game)) + ((eq choice 'a) (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) + ((eq choice 'e) (format t "~&Goodbye!") (quit)) + ((eq choice 'd) (development)) (t (format t "~&Invalid choice!") (start-menu)))) (defun cmd-parameter (name &optional truth-value) @@ -89,7 +103,6 @@ (let ((server (cmd-parameter "--server")) (world-file (cmd-parameter "--world")) (client (cmd-parameter "--client"))) - ;(break) (if (or world-file server) ;TODO change OR to AND (load-file world-file) (format t "~&Sorry, the client is not yet available!")))) diff --git a/lisp/client.lisp b/lisp/client.lisp index 0c19f60..3a99a98 100644 --- a/lisp/client.lisp +++ b/lisp/client.lisp @@ -12,18 +12,24 @@ ;;; (let ((player NIL)) - (defun play-game (&optional player-name) + (defun play-game (player-name) "The main game loop" - ;; XXX Development - (when (y-or-n-p "~&Load the test world?") - (load-file "../ATL/lisp-test.atl")) ;; Initialize the player if necessary (when (null player) - (if player-name - (setf player (get-game-object 'player player-name)) - (error "~&No player name specified!"))) + (setf player (get-game-object 'player player-name))) (when (null player) - (setf player (create-player player-name))))) + (setf player (create-player player-name)) + (add-game-object player) + (set-object-attribute (get-game-object 'place (player-place player)) + 'player (player-name player))) + ;; The actual game loop + (let ((place (get-game-object 'place (player-place player)))) + (describe-place place) + (input-string command) + (while (!= (read-from-string command) 'quit) + (game-command command player) + (input-string command)) + (format t "~&Goodbye!")))) (defun create-player (player-name) "The user creates a new player" @@ -78,7 +84,36 @@ (simple-input val (concatenate 'string (symbol-name attr) ":"))) ;; FIXME Gives problems if two equal numbers are in char-points (let ((player-fn (build-symbol "player-" attr))) - ;; XXX Kludge! + ;; XXX Kludge ?! (eval `(setf (,player-fn ,player) ,val))) (setf character-points (remove-if #'(lambda (x) (= x val)) character-points))))) + +(defun describe-place (p) + "Print out a complete description of place p" + (format t "~&~%~A" (place-description p)) + (format t "~&Neighbouring places: ~A" (string-from-list (place-neighbour p))) + (format t "~&Players present: ~A" (string-from-list (place-player p))) + (format t "~&Items: ~A" (string-from-list (place-item p)))) + +(defun game-command (cmd player) + "Execute a typed-in game command" + (let ((space (position #\Space cmd))) + (if space + (call-function (read-from-string cmd) + (read-from-string (second (cut-string cmd space))) player) + (call-function (read-from-string cmd) player)))) + +;;; Here follow the functions that define the in-game commands. +;;; All of them have to take exactly two argument (the argument +;;; to the function and a player instance). + +(defun help (&optional arg player) + "Print out a list of in-game commands" + (format t "~&Sorry, not yet available!")) + +(defun goto (location player) + "Go to the specified location" + (set-object-attribute player 'place location) + (set-object-attribute (get-game-object 'place (player-place player)) + 'player (player-name player))) diff --git a/lisp/game-objects.lisp b/lisp/game-objects.lisp index 959a76b..81c61ce 100644 --- a/lisp/game-objects.lisp +++ b/lisp/game-objects.lisp @@ -13,12 +13,14 @@ (defstruct place (name "") (description "") + ;; Missing 's' in the following list names due to parsing issues (neighbour NIL) + (player NIL) (item NIL) (monster NIL) (npc NIL)) -;;; INCOMPLETE STRUCTS >>> +;;; WORK IN PROGRESS >>> (defstruct npc (name "")