From e956b11dbab2117be7e6b6808a05f3a529f684d4 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Fri, 21 Aug 2015 09:39:34 -0700 Subject: [PATCH] randomize dialogue antique. --- desktop/gametodos.txt | 8 +- desktop/src-common/advent/actions.clj | 19 +++-- .../advent/screens/rooms/inside_antique.clj | 74 ++++++++++++------- 3 files changed, 64 insertions(+), 37 deletions(-) diff --git a/desktop/gametodos.txt b/desktop/gametodos.txt index 950d44ba..2e286b0e 100644 --- a/desktop/gametodos.txt +++ b/desktop/gametodos.txt @@ -14,10 +14,8 @@ PROGRAMMING + proper save/settings file location + descriptions for all items when used on self. + try to have dialogue for every wrong interaction -+ Antique shop dialogue - + Have a gag that is that the room is dark - + Have to open curtains - + "Specialty lava mints, hand delivered by Gandarf!" ++ Have to open curtains ++ grime on portrait AUDIO + Walking + blink @@ -55,3 +53,5 @@ AUDIO + step backwards creep + snore + shoot slinger's + + + new music for night diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index 6d055f92..03394826 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -413,12 +413,17 @@ (recur (inc so-far) (zip/right zipper))))) (defn make-zipper [tree] - (zip/zipper map? (comp #(map second %) #(filter first (partition 2 %)) :choices) (fn [n c] nil) tree)) + (zip/zipper map? + #(apply concat (filter first (partition 2 (:choices %)))) + (fn [n c] + (assoc n :choices (vec c))) + tree)) (defn present-choices [entities choices] (loop [zipper (make-zipper choices)] (let [selected-index (atom nil) node (zip/node zipper) + _ (clojure.pprint/pprint node) dialogue-choices (filter first (partition 2 (:choices node)))] (run-action entities (begin [this screen entities] @@ -438,16 +443,20 @@ (skip-type [this screen entities] :skip)) - (let [zipper (nth-child zipper @selected-index) - node (zip/node zipper)] + (let [zipper (nth-child zipper (inc (* 2 @selected-index))) + node (zip/node zipper) + _ (clojure.pprint/pprint node)] (when-let [run (:run node)] (run (-> dialogue-choices (nth @selected-index) first))) - (when-let [next-choices (:choices node)] + (when-let [next-choices (or (when-let [choice-fn (:choice-fn node)] + (choice-fn)) + (:choices node))] (if (fn? next-choices) + (recur (next-choices zipper)) - (recur zipper))))))) + (recur (zip/edit zipper assoc :choices next-choices)))))))) (defn update-entities [entities f & {:keys [use-screen?] :or {use-screen? false}}] (run-action entities diff --git a/desktop/src-common/advent/screens/rooms/inside_antique.clj b/desktop/src-common/advent/screens/rooms/inside_antique.clj index 40fc5235..53e9aa46 100644 --- a/desktop/src-common/advent/screens/rooms/inside_antique.clj +++ b/desktop/src-common/advent/screens/rooms/inside_antique.clj @@ -9,6 +9,10 @@ [play-clj.utils :refer :all] [play-clj.g2d :refer :all])) +(def boy-names + ["Steve" "Bob" "Bud" "Clement" "Terrence" "Flapjack" "Ticklemonster" "Peter" "Greg" "Dave" "Stu" "Calsbad" "Fatso" "Tanner" "Klug" + "Griswold" "Leonardo" "Donatello" "Raphael" "Michelangelo" "Francis" "Ebeneezer" "Pierre" "Finn" "Slade" "Gilbert" "Graham" + "Ralphie" "Arthur" "Barney" "Harry" "Gus" "Mortimer" "Walt"]) (defn do-antique-dialogue [entities] (actions/do-dialogue entities @@ -74,38 +78,45 @@ "Listen, I really need that teddy bear you have.") {:run #(actions/respond entities % :shopkeep "Why?" - :shopkeep "It belonged to my long lost son." + :shopkeep "It's my son's favorite toy!" :shopkeep "Why should I give it to you?") :choices ["Because it's the choicest toy I've ever seen!" {:run #(actions/respond entities % :shopkeep "I'm sorry, it's not for sale.") :choices actions/something-else} - "Your long lost son said I could have it." + "Your son said I could have it." {:run #(do (actions/respond entities % :shopkeep "REALLY? You've met him?" :ego "... erm. Yes!" :shopkeep "If you really met him, you'll have to prove it." :shopkeep "What is my son's name?")) - :choices ["... Bud?" - {:run #(do (actions/respond entities % :shopkeep "No. That's not it.") - (actions/play-animation entities :shopkeep :sigh) - (actions/do-dialogue entities :ego "Oh. I must be thinking of another long lost son."))} - "... Steve?" - {:run #(do (actions/respond entities % :shopkeep "No. That's not it.") - (actions/play-animation entities :shopkeep :sigh) - (actions/do-dialogue entities :ego "Oh. I must be thinking of another long lost son."))} - "... Bob?" - {:run #(do (actions/respond entities % :shopkeep "No. That's not it.") - (actions/play-animation entities :shopkeep :sigh) - (actions/do-dialogue entities :ego "Oh. I must be thinking of another long lost son."))} - (when ((get-in @entities [:state :clues]) :name) - "Herb.") - {:run #(do (actions/respond entities % - :shopkeep "Yes, that's it!" - :shopkeep "You must have really met my son!" - :shopkeep "Of course you can keep the teddy bear.") - - (actions/update-state entities (fn [s] (assoc s :allowed-to-keep-teddy? true))))}]}]} + :choice-fn (fn make-choices [] + (let [names (shuffle boy-names)] + (into + (vec (interleave + (take 3 (map #(str "Is it... " % "?") + names)) + (repeat {:run #(do (actions/respond entities % :shopkeep "No. That's not it.") + (actions/play-animation entities :shopkeep :sigh) + (actions/do-dialogue entities :ego "Oh. I must be thinking of another long lost son.")) + :choices #(-> % + zip/left + (zip/edit (fn [_] (str "Is it... " (rand-nth names) "?"))) + + zip/up + )}))) + [(when ((get-in @entities [:state :clues]) :name) + "Herb.") + {:run #(do (actions/respond entities % + :shopkeep "Yes, that's it!" + :shopkeep "You must have really met my son!" + :shopkeep "Of course you can keep the teddy bear.") + + (actions/update-state entities (fn [s] (assoc s :allowed-to-keep-teddy? true))))} + "It must have slipped my mind." + {:run #(do (actions/respond entities % + :shopkeep "I was afraid you might say that.")) + :choices #(-> % zip/up zip/up zip/up)}])))}]} "Nevermind." {:run #(actions/respond entities % :shopkeep "Feel free to look around.")}]}))) @@ -131,7 +142,7 @@ (aget shopkeep-sheet 0 i))) shopkeep-talk (animation 0.15 (for [i [0 2 0 2 0 3 1 0]] (aget shopkeep-sheet 0 i))) - shopkeep-sigh (utils/make-anim "inside-antique/antique-sigh.png" [22 21] 0.2 (flatten [ (range 9) 0 0 0 0 0 0 ])) + shopkeep-sigh (utils/make-anim "inside-antique/antique-sigh.png" [22 21] 0.12 (flatten [ (range 9) 0 0 ])) beard (utils/make-anim "inside-antique/beard.png" [26 52] 0.5 [0 1 0 2]) teddy (assoc (texture "inside-antique/teddy.png") @@ -147,7 +158,8 @@ (actions/do-dialogue entities :ego "Aww, a cute teddy bear!" :shopkeep "Don't get any fast ideas." - :shopkeep "That teddy bear does not leave my store."))))] + :shopkeep "That teddy bear does not leave my store." + :shopkeep "My son would be stricken with grief to find it missing."))))] (rooms/make :music :inside-antique :interactions {:right {:box [250 0 320 75] @@ -169,12 +181,16 @@ :return-portrait {:box [103 70 206 116] :script (actions/get-script entities (actions/talk entities :ego "It's the shopkeep's desk.")) :scripts {:portrait (actions/get-script entities - (return-portrait entities))}} + (return-portrait entities)) + :teddy (actions/get-script entities + (return-teddy entities))}} :return-teddy {:box [227 90 301 105] :script (actions/get-script entities (actions/talk entities :ego "It's a shelf.")) :scripts {:teddy (actions/get-script entities - (return-teddy entities))}} + (return-teddy entities)) + :portrait (actions/get-script entities + (return-portrait entities))}} :window {:box [210 125 256 183] :script (actions/get-script entities (actions/talk entities :ego "It's a nice, big window.")) @@ -225,8 +241,10 @@ (if (get-in @entities [:state :allowed-to-keep-teddy?]) (actions/talk entities :shopkeep "That's a portrait of my little Herb. " :shopkeep "Please put it back before you leave." ) - (actions/talk entities :shopkeep "That's a portrait of my long lost son. " - :shopkeep "Please put it back before you leave."))) + (actions/do-dialogue entities + :shopkeep "Put that back!" + :shopkeep "It's been six years since I last saw my son." + :shopkeep "I won't let you keep my only portrait of him."))) (actions/get-script entities (actions/talk entities :shopkeep "No thanks, sonny.")))) :stand)