peddler dialogue rework.

This commit is contained in:
Bryce Covert
2015-11-09 18:28:07 -08:00
parent ba1ad61a37
commit 2fd5ce988e

View File

@@ -16,64 +16,100 @@
(defn flies-vol [entities] (defn flies-vol [entities]
(utils/proximity-volume entities [201 175] :scale 0.20)) (utils/proximity-volume entities [201 175] :scale 0.20))
(defn do-initial-peddler-conversation [entities] (defn do-peddler-tree [entities]
(actions/do-dialogue entities
:ego "Hello there, peddler."
:peddler "Good day, sir! Care to see any of my wares?"
:peddler "I have only the choicest of wares." (actions/present-choices entities {:choices ["What \"wares\" are you selling?"
:ego "What \"wares\" are you selling?" {:run #(actions/respond entities %
:peddler "I have the choicest of all types of wares..." :peddler "The choicest of questions, sir!"
:peddler "...I'm well stocked on used earplugs..." :peddler "I have the choicest of all types of wares..."
:peddler "...glass eyes..." :peddler "...I'm well stocked on used earplugs..."
:peddler "... and motivational tapes." :peddler "...glass eyes..."
:peddler "And today, I have a one day special!" :peddler "... and motivational tapes."
:peddler "Every purchase comes with the choicest of balloons!") :peddler "And today, I have a one day special!"
(actions/present-choices entities {:choices ["I'm interested in your earplugs." :peddler "Every purchase comes with the choicest of balloons!")
{:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true))) :choices ["I'm interested in your earplugs."
(actions/respond entities % {:run #(do (actions/respond entities %
:peddler "A choice choice sir!" :peddler "A choice choice, sir!"
:peddler "These earplugs have been used by the choicest of wearers." :peddler "These earplugs have been used by the choicest of wearers."
:peddler "I can see a young man like yourself enjoying these choice earplugs for ages to come!" :peddler "I can see a young man like yourself enjoying these choice earplugs for ages to come!"
:peddler "And remember, every purchase comes with the choicest of balloons!" :peddler "And remember, every purchase comes with the choicest of balloons!"
:peddler "That'll just be 10 sheckels." )
:ego "But I haven't got any money!" (if (get-in @entities [:state :wants-toy])
:peddler "Well, I'm afraid you won't have the choicest of earplugs." (actions/do-dialogue entities :peddler "I will give them to you if you bring me the choicest of toys.")
:ego "Can't I give you something else for them?" (actions/do-dialogue entities
:peddler "I'll tell you what, I don't have any thing for the kids that come to my stand." :peddler "That'll just be 10 sheckels."
:peddler "If you can bring me the choicest of toys..." :ego "But I haven't got any money!"
:peddler "... and I mean the choicest of toys... " :peddler "Well, I'm afraid you won't have the choicest of earplugs."
:peddler "I will give you the earplugs."))} :ego "Can't I give you something else for them?"
"I'm interested in a glass eye." :peddler "I'll tell you what, I don't have any thing for the kids that come to my stand."
{:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true))) :peddler "If you can bring me the choicest of toys..."
(actions/respond entities % :peddler "... and I mean the choicest of toys... "
:peddler "The choicest choice, young man!" :peddler "I will give you the earplugs."))
:peddler "This glass eye is made out of the choicest glass from across the sea." (actions/update-state entities (fn [state] (assoc state :wants-toy true)))
:peddler "And remember, every purchase comes with the choicest of balloons!" )
:peddler "That'll just be 95 sheckels." :choices actions/previous-choices}
:ego "But I haven't got any money!" "I'm interested in a glass eye."
:peddler "Well, I'm afraid you won't have the choicest of glass eyes." {:run #(do
:ego "Can't I give you something else for them?" (actions/respond entities %
:peddler "I'll tell you what, I don't have anything for the kids that come to my stand." :peddler "The choicest choice, young man!"
:peddler "If you can bring me the choicest of toys..." :peddler "This glass eye is made out of the choicest glass from across the sea."
:peddler "... and I mean the choicest of toys... " :peddler "And remember, every purchase comes with the choicest of balloons!"
:peddler "Then I'll give you the glass eye."
))} )
"I'm interested in the motivational tapes." (if (get-in @entities [:state :wants-toy])
{:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true))) (actions/do-dialogue entities :peddler "I will give it to you if you bring me the choicest of toys.")
(actions/respond entities % (actions/do-dialogue entities
:peddler "Sure thing!" :peddler "That'll just be 95 sheckels."
:peddler "Has your luck got you down? Feeling pathetic?" :ego "But I haven't got any money!"
:peddler "These choicest of motivation tapes will convince you that life isn't so bad." :peddler "Well, I'm afraid you won't have the choicest of glass eyes."
:peddler "For only 3 easy payments of 29.99 scheckles, they're yours!" :ego "Can't I give you something else for them?"
:ego "But I'm broke!" :peddler "I'll tell you what, I don't have anything for the kids that come to my stand."
:peddler "Well, I'm afraid you won't have the choicest of motivational tapes." :peddler "If you can bring me the choicest of toys..."
:ego "Is there anything else you'd take instead?" :peddler "... and I mean the choicest of toys... "
:peddler "I'll tell you what, I don't have anything for the kids that come to my stand." :peddler "Then I'll give you the glass eye."))
:peddler "If you can bring me the choicest of toys..." (actions/update-state entities (fn [state] (assoc state :wants-toy true))))
:peddler "... and I mean the choicest of toys... " :choices actions/previous-choices}
:peddler "Then I'll give you the motivational tapes." "I'm interested in the motivational tapes."
))} {:run #(do
"Nevermind." {:run #(actions/respond entities % :peddler "Goodbye, sir.")}]})) (actions/respond entities %
:peddler "Sure thing!"
:peddler "Has your luck got you down? Feeling pathetic?"
:peddler "These choicest of motivation tapes will convince you that life isn't so bad.")
(if (get-in @entities [:state :wants-toy])
(actions/do-dialogue entities :peddler "I will give them to you if you bring me the choicest of toys.")
(actions/do-dialogue entities
:peddler "For only 3 easy payments of 29.99 scheckles, they're yours!"
:ego "But I'm broke!"
:peddler "Well, I'm afraid you won't have the choicest of motivational tapes."
:ego "Is there anything else you'd take instead?"
:peddler "I'll tell you what, I don't have anything for the kids that come to my stand."
:peddler "If you can bring me the choicest of toys..."
:peddler "... and I mean the choicest of toys... "
:peddler "Then I'll give you the motivational tapes."))
(actions/update-state entities (fn [state] (assoc state :wants-toy true))))
:choices actions/previous-choices}
"Something else."
{:choices actions/something-else}]}
(when (get-in @entities [:state :wants-toy])
"Tell me again about the toy you want.")
{:run #(actions/respond entities %
:peddler "But of course, sir!"
:peddler "I want a toy for the children who come by my stand."
:peddler "And I don't mean any toy."
:peddler "I need the choicest of toys!"
:peddler "If you bring me one, I'll give you any of my choicest of wares."
:peddler "And I'll throw in a balloon, free of charge!")
:choices actions/previous-choices}
"How's business?" {:run #(actions/respond entities %
:peddler "Excellent, sir!"
:peddler "This is the choicest location to find schmucks-"
:peddler "Err, customers, for my choicest of wares!")
:choices actions/previous-choices}
"See you later." {:run #(actions/respond entities %
:peddler "Goodbye, sir!"
:peddler "May today be the choicest day!")}]}))
(defn give-teddy [entities] (defn give-teddy [entities]
(actions/remove-item entities :teddy) (actions/remove-item entities :teddy)
@@ -98,14 +134,17 @@
(defn do-completed-peddler-conversation [entities] (defn do-completed-peddler-conversation [entities]
(actions/do-dialogue entities (actions/do-dialogue entities
:ego "Hello there, peddler." :ego "Hello there, peddler."
:peddler "Hello again, sir! I trust you are enjoying your goods!" :peddler "Well, well!"
:ego "I sure am." :peddler "If it isn't my choicest of customers!"
:peddler "I trust you are enjoying your choicest of wares?"
:ego "... I sure am."
:peddler "I thought so!")) :peddler "I thought so!"))
(defn do-wants-toy-conversation [entities] (defn do-wants-toy-conversation [entities]
(actions/do-dialogue entities (actions/do-dialogue entities
:ego "Hello there, peddler." :ego "Hello there, peddler."
:peddler "Hello again, sir! Have you found me the choicest jack-in-the box yet?" :peddler "Hello again, sir!"
:peddler "Have you found me the choicest jack-in-the box yet?"
:ego "... erm, no." :ego "... erm, no."
:peddler "Oh, well how about the choicest bouncy ball?" :peddler "Oh, well how about the choicest bouncy ball?"
:ego "... not quite yet." :ego "... not quite yet."
@@ -115,10 +154,9 @@
(actions/do-dialogue entities :ego "Well, I have this teddy bear.") (actions/do-dialogue entities :ego "Well, I have this teddy bear.")
(give-teddy entities)) (give-teddy entities))
(actions/do-dialogue entities :ego "No, no, and no." (do
:peddler "Well, come back when you have something I'm interested in." (actions/do-dialogue entities :ego "No, no, and no.")
:peddler "Remember, I have a one-day special going." (do-peddler-tree entities))))
:peddler "Every purchase comes with a free balloon!")))
(defn walk-to-peddler [entities] (defn walk-to-peddler [entities]
(actions/walk-to entities :ego [191 90] :face :left)) (actions/walk-to entities :ego [191 90] :face :left))
@@ -129,9 +167,14 @@
:peddler "Sorry, no refunds.")) :peddler "Sorry, no refunds."))
(defn do-peddler-dialogue [entities] (defn do-peddler-dialogue [entities]
(cond (actions/has-obtained? entities :balloon) (do-completed-peddler-conversation entities) (cond (actions/has-obtained? entities :balloon) (do-completed-peddler-conversation entities)
(get-in @entities [:state :wants-toy]) (do-wants-toy-conversation entities) (get-in @entities [:state :wants-toy]) (do-wants-toy-conversation entities)
:else (do-initial-peddler-conversation entities))) :else (do (actions/do-dialogue entities
:ego "Hello there, peddler."
:peddler "Good day, sir! Care to see any of my wares?"
:peddler "I have only the choicest of wares.")
(do-peddler-tree entities))))
(defn should-block? [entities] (defn should-block? [entities]
(and (= :night (get-in @entities [:state :time])) (and (= :night (get-in @entities [:state :time]))