diff --git a/desktop/src-common/advent/screens/items.clj b/desktop/src-common/advent/screens/items.clj index 2db32262..a1fd3e43 100644 --- a/desktop/src-common/advent/screens/items.clj +++ b/desktop/src-common/advent/screens/items.clj @@ -31,43 +31,67 @@ (actions/talk entities :ego "It's the completed strength potion!"))) -(defn make-water-and-ash [] - (actions/get-script entities - (actions/remove-item entities :flask-water) - (actions/remove-item entities :ash) - (actions/give entities :flask-water-ash) - (actions/talk entities :ego "I added the ashes to the water."))) +(defn make-water-and-ash [entities] + (actions/remove-item entities :flask-water) + (actions/remove-item entities :ash) + (actions/give entities :flask-water-ash) + (actions/talk entities :ego "I added the ashes to the water.")) -(defn make-water-and-flies [] - (actions/get-script entities - (actions/remove-item entities :flask-water) - (actions/remove-item entities :flies) - (actions/give entities :flask-water-flies) - (actions/talk entities :ego "I put those flies in the flask."))) +(defn make-water-and-flies [entities] + (actions/remove-item entities :flask-water) + (actions/remove-item entities :flies) + (actions/give entities :flask-water-flies) + (actions/talk entities :ego "I put those flies in the flask.")) -(defn make-flies-ash [] - (actions/get-script entities - (actions/remove-item entities :flask-water) - (actions/remove-item entities :flask-water-ash) - (actions/remove-item entities :flask-water-flies) - (actions/remove-item entities :ash) - (actions/remove-item entities :flies) - (actions/give entities :flask-flies-ash) - (actions/talk entities :ego "Now it's got the fountain water, flies, and the ashes in it."))) +(defn make-flies-ash [entities] + (actions/remove-item entities :flask-water) + (actions/remove-item entities :flask-water-ash) + (actions/remove-item entities :flask-water-flies) + (actions/remove-item entities :ash) + (actions/remove-item entities :flies) + (actions/give entities :flask-flies-ash) + (actions/talk entities :ego "Now it's got the fountain water, flies, and the ashes in it.")) -(defn make-finished-component [] +(defn make-finished-component [entities] + (actions/talk entities :ego "I'll just mix this up.") + (actions/remove-item entities :flask-flies-ash) + (actions/remove-item entities :feather) + (actions/play-animation entities :ego :reach) + (actions/give entities :spell-component) + (actions/talk entities :ego "It looks like it's ready!")) + +(defn add-mushrooms-to-flask [] (actions/get-script entities - (actions/talk entities :ego "I'll just mix this up.") - (actions/remove-item entities :flask-flies-ash) - (actions/remove-item entities :feather) - (actions/play-animation entities :ego :reach) - (actions/give entities :spell-component) - (actions/talk entities :ego "It looks like it's ready!"))) + (if (actions/has-item? entities :recipe) + (do (actions/remove-item entities :flask-1) + (actions/remove-item entities :mushrooms) + (actions/give entities :flask-1-with-mushrooms) + (actions/talk entities :ego "I'll just put a few of these in here.")) + (actions/talk entities :ego "I don't know if I could get them back out.")))) + +(declare items) +(defn mix-ingredients [base] + (fn [other] + (let [is-using-flask? (seq (filter (comp :flask? items) [base other]))] + (if is-using-flask? + (actions/get-script entities + (if (actions/has-item? entities :note-1) + (condp = #{base other} + #{:ash :flask-water} (make-water-and-ash entities) + #{:flies :flask-water} (make-water-and-flies entities) + #{:flies :flask-water-ash} (make-flies-ash entities) + #{:ash :flask-water-flies} (make-flies-ash entities) + #{:feather :flask-flies-ash} (make-finished-component entities) + (actions/talk entities :ego "I'm not sure if that goes in there.")) + + (actions/talk entities :ego "I should really find out from Gandarf before I put anything in there."))) + nil)))) (def items {:wool {:name "Wool" :value :wool :cursor :wool :scripts {:stick make-cat-toy}} :mushrooms {:name "Mushrooms" :value :mushrooms :cursor :mushrooms - :scripts {:flask-1-with-milk (actions/get-script entities (make-cream-of-mushroom entities))}} + :scripts {:flask-1-with-milk (actions/get-script entities (make-cream-of-mushroom entities)) + :flask-1 (add-mushrooms-to-flask)}} :carrot {:name "Carrot" :value :carrot :cursor :carrot} :flask-1-with-mushrooms {:name "Flask with mushrooms" :value :flask-1-with-mushrooms :cursor :flask-with-contents} :flask-1-with-milk {:name "Flask with milk" :value :flask-1-with-milk :cursor :flask-with-contents @@ -75,11 +99,7 @@ :flask-1-strength {:name "Strength potion" :value :flask-1-strength :cursor :flask-with-strength} :flask-1 {:name "Flask" :value :flask-1 :cursor :flask - :scripts {:mushrooms (actions/get-script entities - (actions/remove-item entities :flask-1) - (actions/remove-item entities :mushrooms) - (actions/give entities :flask-1-with-mushrooms) - (actions/talk entities :ego "I'll just put a few of these in here."))}} + :scripts {:mushrooms (add-mushrooms-to-flask)}} :trophy {:name "Trophy of wisdom" :value :trophy :cursor :trophy} :cheat-deck {:name "Warlock's Tower cheat deck" :value :cheat-deck :cursor :cheat-deck} :cat-toy {:name "Cat toy" :value :cat-toy :cursor :cat-toy} @@ -108,18 +128,18 @@ :key {:name "Jail key" :value :key :cursor :key} :rope {:name "Rope" :value :rope :cursor :rope} :crowbar {:name "Crowbar" :value :crowbar :cursor :crowbar} - :flask-2 {:name "Flask" :value :flask-2 :cursor :flask} - :flask-water {:name "Water from fountain" :value :flask-water :cursor :flask-water :scripts {:ash (make-water-and-ash) :flies (make-water-and-flies)}} - :flask-water-ash {:name "Water and ashes" :value :flask-water-ash :cursor :flask-water-stuff :scripts {:flies (make-flies-ash)}} - :flask-water-flies {:name "Water and flies" :value :flask-water-flies :cursor :flask-water-stuff :scripts {:ash (make-flies-ash)}} - :flask-flies-ash {:name "Water, flies, and ash" :value :flask-flies-ash :cursor :flask-water-stuff-2 :scripts {:feather (make-finished-component)}} + :flask-2 {:name "Flask" :value :flask-2 :cursor :flask :flask? true} + :flask-water {:name "Water from fountain" :flask? true :value :flask-water :cursor :flask-water :scripts (mix-ingredients :flask-water) } + :flask-water-ash {:name "Water and ashes" :flask? true :value :flask-water-ash :cursor :flask-water-stuff :scripts (mix-ingredients :flask-water-ash) } + :flask-water-flies {:name "Water and flies" :flask? true :value :flask-water-flies :cursor :flask-water-stuff :scripts (mix-ingredients :flask-water-flies)} + :flask-flies-ash {:name "Water, flies, and ash" :flask? true :value :flask-flies-ash :cursor :flask-water-stuff-2 :scripts (mix-ingredients :flask-flies-ash)} :note-1 {:name "Note from Gandarf" :value :note-1 :cursor :note-1} - :ash {:name "Ashes" :value :ash :cursor :ash :scripts {:flask-water (make-water-and-ash) :flask-water-flies (make-flies-ash)}} + :ash {:name "Ashes" :value :ash :cursor :ash :scripts (mix-ingredients :ash)} :sack-lunch {:name "Pungent sack lunch" :value :sack-lunch :cursor :sack-lunch} - :flies {:name "Flies" :value :flies :cursor :flies :scripts {:flask-water (make-water-and-flies) :flask-water-ash (make-flies-ash)}} + :flies {:name "Flies" :value :flies :cursor :flies :scripts (mix-ingredients :flies)} :spear {:name "Spear" :value :spear :cursor :spear} :monocle {:name "Monocle" :value :monocle :cursor :monocle} - :feather {:name "Feather" :value :feather :cursor :feather :scripts {:flask-flies-ash (make-finished-component)}} + :feather {:name "Feather" :value :feather :cursor :feather :scripts (mix-ingredients :feather)} :spell-component {:name "Spell component" :value :spell-component :cursor :spell-component} :money {:name "Money" :value :money :cursor :money} :watch {:name "Watch" :value :watch :cursor :watch} diff --git a/desktop/src-common/advent/screens/rooms/outside_house.clj b/desktop/src-common/advent/screens/rooms/outside_house.clj index e24e16c5..ad2a3459 100644 --- a/desktop/src-common/advent/screens/rooms/outside_house.clj +++ b/desktop/src-common/advent/screens/rooms/outside_house.clj @@ -561,7 +561,7 @@ (actions/has-item? entities :note-1) (actions/do-dialogue entities :ego "According to Gandarf's note..." - :ego "I need to some stuff up in a flask and dump it in here.") + :ego "I need to mix some stuff up in a flask and dump it in here.") :else (actions/talk entities :ego "That's a big cauldron!")))) @@ -681,14 +681,16 @@ (actions/update-state entities (fn [s] (assoc s :coaxed-sheep? true))) (leave-sheep entities)) :flask-1 (actions/get-script entities - (if (is-sheep-close? @entities) - (do (walk-to-sheep entities) - (actions/play-animation entities :ego :milk) - (actions/remove-item entities :flask-1) - (actions/give entities :flask-1-with-milk) - (actions/talk entities :ego "Sheeps milk.") - (leave-sheep entities)) - (actions/talk entities :ego "She's too far away."))) + (if (actions/has-item? entities :recipe) + (if (is-sheep-close? @entities) + (do (walk-to-sheep entities) + (actions/play-animation entities :ego :milk) + (actions/remove-item entities :flask-1) + (actions/give entities :flask-1-with-milk) + (actions/talk entities :ego "Sheeps milk.") + (leave-sheep entities)) + (actions/talk entities :ego "She's too far away.")) + (actions/talk entities :ego "I don't need any milk."))) :flask-1-with-mushrooms (actions/get-script entities (if (is-sheep-close? @entities)