(ns advent.screens.items (:require [advent.actions :as actions])) (def make-cat-toy (actions/get-script entities (actions/remove-item entities :stick) (actions/remove-item entities :wool) (actions/give entities :cat-toy) (actions/talk entities :ego "It makes a little cat toy!"))) (defn make-cream-of-mushroom [entities] (actions/remove-item entities :flask-1-with-mushrooms) (actions/remove-item entities :flask-1-with-milk) (actions/remove-item entities :mushrooms) (actions/give entities :flask-1-with-cream-of-mushroom) (actions/talk entities :ego "It's just like cream of mushroom soup.")) (defn add-slobber [] (actions/get-script entities (actions/remove-item entities :flask-1-with-cream-of-mushroom) (actions/remove-item entities :slobber) (actions/give entities :flask-1-slobber) (actions/talk entities :ego "I put the slobber in with the cream of mushroom."))) (defn make-strength-potion [] (actions/get-script entities (actions/remove-item entities :flask-1-slobber) (actions/remove-item entities :mandrake) (actions/give entities :flask-1-strength) (actions/talk entities :ego "It's the completed strength potion!"))) (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 [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 [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 [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 (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)) :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 :scripts {:mushrooms (actions/get-script entities (make-cream-of-mushroom entities))}} :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 (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} :stick {:name "Stick" :value :stick :cursor :stick :scripts {:wool make-cat-toy}} :balloon {:name "Choicest of balloons" :value :balloon :cursor :balloon} :frog-legs {:name "Frog legs" :value :frog-legs :cursor :frog-legs} :ladder {:name "Ladder" :value :ladder :cursor :ladder} :teddy {:name "Teddy Bear" :value :teddy :cursor :teddy} :portrait {:name "Portrait" :value :portrait :cursor :portrait} :recipe {:name "Strength potion recipe" :value :recipe :cursor :recipe} :glass-eye {:name "Choicest of glass eyes" :value :glass-eye :cursor :glass-eye} :motivational-tapes {:name "Choicest motivational tapes" :value :motivational-tapes :cursor :motivational-tapes} :used-earplugs {:name "Choicest used earplugs" :value :used-earplugs :cursor :used-earplugs} :grass {:name "High protein grass" :value :grass :cursor :grass} :slobber {:name "Bull slobber" :value :slobber :cursor :slobber :scripts {:flask-1-with-cream-of-mushroom (add-slobber)}} :flask-1-with-cream-of-mushroom {:name "Flask with cream of mushrooms soup" :value :flask-1-with-cream-of-mushroom :cursor :flask-with-contents :scripts {:slobber (add-slobber)}} :flask-1-slobber {:name "Cream of mushrooms soup and bull slobber" :value :flask-1-slobber :cursor :flask-with-contents :scripts {:mandrake (make-strength-potion)}} :medal {:name "Medal of strength" :value :medal :cursor :medal} :kiss {:name "Kiss for courage" :value :kiss :cursor :kiss} :sword {:name "Sword of Blergh" :value :sword :cursor :sword} :mandrake {:name "Mandrake root" :value :mandrake :cursor :mandrake :scripts {:flask-1-slobber (make-strength-potion) }} :ball-n-chain {:name "Ball-n-chain" :value :ball-n-chain :cursor :ball-n-chain} :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? 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 (mix-ingredients :ash)} :sack-lunch {:name "Pungent sack lunch" :value :sack-lunch :cursor :sack-lunch} :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 (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} :broken-clock {:name "Sliced time-keeping device" :value :broken-clock :cursor :broken-clock} :slingshot {:name "The Slinger's Shot" :value :slingshot :cursor :slingshot} :note-2 {:name "Bingo card" :value :note-2 :cursor :note-2} :camera {:name "Image taking device" :value :camera :cursor :camera} :walkie-talkies {:name "Communication devices" :value :walkie-talkies :cursor :walkie-talkies} :walkie-talkie {:name "Communication device" :value :walkie-talkie :cursor :walkie-talkie} :alarm-clock {:name "Time-keeping device" :value :alarm-clock :cursor :alarm-clock} :magic-slingshot {:name "The Slinger's Shot" :value :magic-slingshot :cursor :magic-slingshot} :shovel {:name "Shovel" :value :shovel :cursor :shovel} :broom {:name "Broom" :value :broom :cursor :broom} :dream-sword {:name "Sword" :value :dream-sword :cursor :sword}})