diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index 3f7e00e..04c4b69 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -10,6 +10,7 @@ define-item "Hunny" description "A jar full to the brim of delicious, golden honey. Hmmmm..." + command "eat" define-item "Letter" description "A closed letter, addressed to Somebody in Christopher Robin's @@ -48,6 +49,7 @@ define-item "Berries" description "Scrumptious, fresh wild berries: blueberries, blackberries, strawberries... Just don't eat too many!" + command "eat" infinite define-item "Bellrope" @@ -70,6 +72,7 @@ ................................... ................................... " + fixed define-item "Magic map" description "This is a strange map. It always seems to be changing. One @@ -100,6 +103,7 @@ description "Kanga is Roo's mother. She is very responsible, but also very loving and affectionate. Don't disobey her, though!" says "Hello Pooh, have you come to play with Roo?" + interaction-hook "kanga-healing" define-npc "Roo" description "Roo is Pooh's youngest friend. He loves a good romp, especially diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index 3f7e00e..04c4b69 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -10,6 +10,7 @@ define-item "Hunny" description "A jar full to the brim of delicious, golden honey. Hmmmm..." + command "eat" define-item "Letter" description "A closed letter, addressed to Somebody in Christopher Robin's @@ -48,6 +49,7 @@ define-item "Berries" description "Scrumptious, fresh wild berries: blueberries, blackberries, strawberries... Just don't eat too many!" + command "eat" infinite define-item "Bellrope" @@ -70,6 +72,7 @@ ................................... ................................... " + fixed define-item "Magic map" description "This is a strange map. It always seems to be changing. One @@ -100,6 +103,7 @@ description "Kanga is Roo's mother. She is very responsible, but also very loving and affectionate. Don't disobey her, though!" says "Hello Pooh, have you come to play with Roo?" + interaction-hook "kanga-healing" define-npc "Roo" description "Roo is Pooh's youngest friend. He loves a good romp, especially diff --git a/ATL/Pooh/pooh-extensions.lisp b/ATL/Pooh/pooh-extensions.lisp new file mode 100644 index 0000000..217a1bf --- /dev/null +++ b/ATL/Pooh/pooh-extensions.lisp @@ -0,0 +1,27 @@ +; The 100 Acre Wood was invented by A.A. Milne for his Winnie-the-Pooh stories. +; This Atlantis world is based on the novels. +; +; This file holds Lisp functions for hooks and the like, to expand on the +; capabilities of the basic Atlantis framework. +; +; author: Daniel Vedder +; date: 20/07/2017 + +(defun eat (player &optional arg) + "Allow the player to eat something." + (cond ((null arg) (format t "~&What do you want to eat?")) + ((and (equalp arg "berries") + (member "berries" (player-item player) :test #'equalp)) + (format t "~&Mmmh, these berries are really delicious!") + (remove-object-attribute player 'item "berries")) + ((and (or (equalp arg "hunny") (equalp arg "honey")) + (member "Hunny" (player-item player) :test #'equalp)) + (format t "~&The honey looks incredibly tempting, but perhaps you should save it for later.")) + (T (format t "~&You can't eat that!")))) + +(defun kanga-healing (player) + "If the player is hurt, Kanga looks after him." + (when (< (player-health player) (player-max-health player)) + (format t "~&KANGA: Oh my dear, you look hurt! Here, let me take care of you.") + (format t "~&~%Kanga bandages your wounds. You feel better.") + (setf (player-health player) (player-max-health player)))) diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index 3f7e00e..04c4b69 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -10,6 +10,7 @@ define-item "Hunny" description "A jar full to the brim of delicious, golden honey. Hmmmm..." + command "eat" define-item "Letter" description "A closed letter, addressed to Somebody in Christopher Robin's @@ -48,6 +49,7 @@ define-item "Berries" description "Scrumptious, fresh wild berries: blueberries, blackberries, strawberries... Just don't eat too many!" + command "eat" infinite define-item "Bellrope" @@ -70,6 +72,7 @@ ................................... ................................... " + fixed define-item "Magic map" description "This is a strange map. It always seems to be changing. One @@ -100,6 +103,7 @@ description "Kanga is Roo's mother. She is very responsible, but also very loving and affectionate. Don't disobey her, though!" says "Hello Pooh, have you come to play with Roo?" + interaction-hook "kanga-healing" define-npc "Roo" description "Roo is Pooh's youngest friend. He loves a good romp, especially diff --git a/ATL/Pooh/pooh-extensions.lisp b/ATL/Pooh/pooh-extensions.lisp new file mode 100644 index 0000000..217a1bf --- /dev/null +++ b/ATL/Pooh/pooh-extensions.lisp @@ -0,0 +1,27 @@ +; The 100 Acre Wood was invented by A.A. Milne for his Winnie-the-Pooh stories. +; This Atlantis world is based on the novels. +; +; This file holds Lisp functions for hooks and the like, to expand on the +; capabilities of the basic Atlantis framework. +; +; author: Daniel Vedder +; date: 20/07/2017 + +(defun eat (player &optional arg) + "Allow the player to eat something." + (cond ((null arg) (format t "~&What do you want to eat?")) + ((and (equalp arg "berries") + (member "berries" (player-item player) :test #'equalp)) + (format t "~&Mmmh, these berries are really delicious!") + (remove-object-attribute player 'item "berries")) + ((and (or (equalp arg "hunny") (equalp arg "honey")) + (member "Hunny" (player-item player) :test #'equalp)) + (format t "~&The honey looks incredibly tempting, but perhaps you should save it for later.")) + (T (format t "~&You can't eat that!")))) + +(defun kanga-healing (player) + "If the player is hurt, Kanga looks after him." + (when (< (player-health player) (player-max-health player)) + (format t "~&KANGA: Oh my dear, you look hurt! Here, let me take care of you.") + (format t "~&~%Kanga bandages your wounds. You feel better.") + (setf (player-health player) (player-max-health player)))) diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index 7ffe87a..b2c3a45 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -8,19 +8,16 @@ name-world "100 Acre Wood" +load-file "pooh-extensions.lisp" load-file "objects.atl" load-file "woods.atl" define-player "Winnie the Pooh" description "A small but lovable bear of Very Little Brain." place "Pooh's home" + max-health 20 health 20 strength 1 dexterity 4 constitution 4 -;; XXX Created during development -;define-player "Christopher Robin" -; description "Pooh's best friend." -; place "Western woods" - diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index 3f7e00e..04c4b69 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -10,6 +10,7 @@ define-item "Hunny" description "A jar full to the brim of delicious, golden honey. Hmmmm..." + command "eat" define-item "Letter" description "A closed letter, addressed to Somebody in Christopher Robin's @@ -48,6 +49,7 @@ define-item "Berries" description "Scrumptious, fresh wild berries: blueberries, blackberries, strawberries... Just don't eat too many!" + command "eat" infinite define-item "Bellrope" @@ -70,6 +72,7 @@ ................................... ................................... " + fixed define-item "Magic map" description "This is a strange map. It always seems to be changing. One @@ -100,6 +103,7 @@ description "Kanga is Roo's mother. She is very responsible, but also very loving and affectionate. Don't disobey her, though!" says "Hello Pooh, have you come to play with Roo?" + interaction-hook "kanga-healing" define-npc "Roo" description "Roo is Pooh's youngest friend. He loves a good romp, especially diff --git a/ATL/Pooh/pooh-extensions.lisp b/ATL/Pooh/pooh-extensions.lisp new file mode 100644 index 0000000..217a1bf --- /dev/null +++ b/ATL/Pooh/pooh-extensions.lisp @@ -0,0 +1,27 @@ +; The 100 Acre Wood was invented by A.A. Milne for his Winnie-the-Pooh stories. +; This Atlantis world is based on the novels. +; +; This file holds Lisp functions for hooks and the like, to expand on the +; capabilities of the basic Atlantis framework. +; +; author: Daniel Vedder +; date: 20/07/2017 + +(defun eat (player &optional arg) + "Allow the player to eat something." + (cond ((null arg) (format t "~&What do you want to eat?")) + ((and (equalp arg "berries") + (member "berries" (player-item player) :test #'equalp)) + (format t "~&Mmmh, these berries are really delicious!") + (remove-object-attribute player 'item "berries")) + ((and (or (equalp arg "hunny") (equalp arg "honey")) + (member "Hunny" (player-item player) :test #'equalp)) + (format t "~&The honey looks incredibly tempting, but perhaps you should save it for later.")) + (T (format t "~&You can't eat that!")))) + +(defun kanga-healing (player) + "If the player is hurt, Kanga looks after him." + (when (< (player-health player) (player-max-health player)) + (format t "~&KANGA: Oh my dear, you look hurt! Here, let me take care of you.") + (format t "~&~%Kanga bandages your wounds. You feel better.") + (setf (player-health player) (player-max-health player)))) diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index 7ffe87a..b2c3a45 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -8,19 +8,16 @@ name-world "100 Acre Wood" +load-file "pooh-extensions.lisp" load-file "objects.atl" load-file "woods.atl" define-player "Winnie the Pooh" description "A small but lovable bear of Very Little Brain." place "Pooh's home" + max-health 20 health 20 strength 1 dexterity 4 constitution 4 -;; XXX Created during development -;define-player "Christopher Robin" -; description "Pooh's best friend." -; place "Western woods" - diff --git a/ATL/Pooh/woods.atl b/ATL/Pooh/woods.atl index ab2cde1..ce1da37 100644 --- a/ATL/Pooh/woods.atl +++ b/ATL/Pooh/woods.atl @@ -257,6 +257,7 @@ define-place "Misty forest" description "TODO" + item "Berries" neighbour "Sandy pit" define-place "The World" diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index 3f7e00e..04c4b69 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -10,6 +10,7 @@ define-item "Hunny" description "A jar full to the brim of delicious, golden honey. Hmmmm..." + command "eat" define-item "Letter" description "A closed letter, addressed to Somebody in Christopher Robin's @@ -48,6 +49,7 @@ define-item "Berries" description "Scrumptious, fresh wild berries: blueberries, blackberries, strawberries... Just don't eat too many!" + command "eat" infinite define-item "Bellrope" @@ -70,6 +72,7 @@ ................................... ................................... " + fixed define-item "Magic map" description "This is a strange map. It always seems to be changing. One @@ -100,6 +103,7 @@ description "Kanga is Roo's mother. She is very responsible, but also very loving and affectionate. Don't disobey her, though!" says "Hello Pooh, have you come to play with Roo?" + interaction-hook "kanga-healing" define-npc "Roo" description "Roo is Pooh's youngest friend. He loves a good romp, especially diff --git a/ATL/Pooh/pooh-extensions.lisp b/ATL/Pooh/pooh-extensions.lisp new file mode 100644 index 0000000..217a1bf --- /dev/null +++ b/ATL/Pooh/pooh-extensions.lisp @@ -0,0 +1,27 @@ +; The 100 Acre Wood was invented by A.A. Milne for his Winnie-the-Pooh stories. +; This Atlantis world is based on the novels. +; +; This file holds Lisp functions for hooks and the like, to expand on the +; capabilities of the basic Atlantis framework. +; +; author: Daniel Vedder +; date: 20/07/2017 + +(defun eat (player &optional arg) + "Allow the player to eat something." + (cond ((null arg) (format t "~&What do you want to eat?")) + ((and (equalp arg "berries") + (member "berries" (player-item player) :test #'equalp)) + (format t "~&Mmmh, these berries are really delicious!") + (remove-object-attribute player 'item "berries")) + ((and (or (equalp arg "hunny") (equalp arg "honey")) + (member "Hunny" (player-item player) :test #'equalp)) + (format t "~&The honey looks incredibly tempting, but perhaps you should save it for later.")) + (T (format t "~&You can't eat that!")))) + +(defun kanga-healing (player) + "If the player is hurt, Kanga looks after him." + (when (< (player-health player) (player-max-health player)) + (format t "~&KANGA: Oh my dear, you look hurt! Here, let me take care of you.") + (format t "~&~%Kanga bandages your wounds. You feel better.") + (setf (player-health player) (player-max-health player)))) diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index 7ffe87a..b2c3a45 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -8,19 +8,16 @@ name-world "100 Acre Wood" +load-file "pooh-extensions.lisp" load-file "objects.atl" load-file "woods.atl" define-player "Winnie the Pooh" description "A small but lovable bear of Very Little Brain." place "Pooh's home" + max-health 20 health 20 strength 1 dexterity 4 constitution 4 -;; XXX Created during development -;define-player "Christopher Robin" -; description "Pooh's best friend." -; place "Western woods" - diff --git a/ATL/Pooh/woods.atl b/ATL/Pooh/woods.atl index ab2cde1..ce1da37 100644 --- a/ATL/Pooh/woods.atl +++ b/ATL/Pooh/woods.atl @@ -257,6 +257,7 @@ define-place "Misty forest" description "TODO" + item "Berries" neighbour "Sandy pit" define-place "The World" diff --git a/lisp/ui.lisp b/lisp/ui.lisp index 992ea75..5859726 100644 --- a/lisp/ui.lisp +++ b/lisp/ui.lisp @@ -55,7 +55,7 @@ (if cmd-fn (if space (funcall cmd-fn player arg) (funcall cmd-fn player)) - (progn (format t "~&Sorry, this command does not exist!") + (progn (format t "~&Sorry, this command is not available!") (format t "~&Type 'help' for a list of commands."))))) ;;; @@ -295,7 +295,7 @@ (when (item-command item) (format t "~&This item provides commands: ~A" (string-from-list (item-command item)))) - (when (item-pickup-hook item) + (unless (zerop (length (item-pickup-hook item))) (funcall (read-from-string (item-pickup-hook item)) player)))) (format t "~&Sorry, this item is not here!")))) @@ -314,7 +314,7 @@ (set-object-attribute (get-game-object 'place (player-place player)) 'item item) (format t "~&You have dropped: ~A" item) - (when (item-drop-hook (get-game-object 'item item)) + (unless (zerop (length (item-drop-hook (get-game-object 'item item)))) (funcall (read-from-string (item-drop-hook (get-game-object 'item item))) player)))