180 lines
11 KiB
Clojure
180 lines
11 KiB
Clojure
(ns advent.screens.items
|
|
(:require [advent.actions :as actions]))
|
|
|
|
(def make-cat-toy
|
|
(actions/get-script entities
|
|
(actions/remove-item entities :stick :quiet? true)
|
|
(actions/remove-item entities :wool :quiet? true)
|
|
(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 :quiet? true)
|
|
(actions/remove-item entities :flask-1-with-milk :quiet? true)
|
|
(actions/remove-item entities :mushrooms :quiet? true)
|
|
(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 :quiet? true)
|
|
(actions/remove-item entities :slobber :quiet? true)
|
|
(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 :quiet? true)
|
|
(actions/remove-item entities :mandrake :quiet? true)
|
|
(actions/give entities :flask-1-strength)
|
|
(actions/talk entities :ego "It's the completed strength potion!")
|
|
(actions/glad entities)))
|
|
|
|
|
|
(defn make-water-and-ash [entities]
|
|
(actions/remove-item entities :flask-water :quiet? true)
|
|
(actions/remove-item entities :ash :quiet? true)
|
|
(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 :quiet? true)
|
|
(actions/remove-item entities :flies :quiet? true)
|
|
(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 :quiet? true)
|
|
(actions/remove-item entities :flask-water-ash :quiet? true)
|
|
(actions/remove-item entities :flask-water-flies :quiet? true)
|
|
(actions/remove-item entities :ash :quiet? true)
|
|
(actions/remove-item entities :flies :quiet? true)
|
|
(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 :quiet? true)
|
|
(actions/remove-item entities :feather :quiet? true)
|
|
(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 :quiet? true)
|
|
(actions/remove-item entities :mushrooms :quiet? true)
|
|
(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."))))
|
|
|
|
(defn not-ready
|
|
([] (not-ready "I don't think it's quite ready for that."))
|
|
([msg]
|
|
(actions/get-script entities
|
|
(if (actions/has-item? entities :recipe)
|
|
(actions/do-dialogue entities :ego msg
|
|
:ego "Maybe I should double-check the recipe.")
|
|
(actions/talk entities :ego "I'm not sure I could get it back out.")))))
|
|
|
|
(declare items)
|
|
(defn mix-ingredients [base]
|
|
(fn [other]
|
|
(let [is-using-flask? (seq (filter (comp :flask? items) [base other]))
|
|
items-used (set [base other])]
|
|
(cond (= 1 (count items-used))
|
|
nil
|
|
is-using-flask?
|
|
(actions/get-script entities
|
|
(if (actions/has-item? entities :note-1)
|
|
(condp = items-used
|
|
#{: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.")))
|
|
:else
|
|
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
|
|
:scripts {:mandrake (not-ready) :slobber (not-ready "I've got the mushrooms, but I'm missing the cream.")}}
|
|
: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))
|
|
:slobber (not-ready)
|
|
:mandrake (not-ready)}}
|
|
|
|
: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)
|
|
:mandrake (not-ready)
|
|
:slobber (not-ready)}}
|
|
:trophy {:name "Trophy of Wisdom" :value :trophy :cursor :trophy}
|
|
: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-mushrooms (not-ready) :flask-1-with-milk (not-ready) :flask-1 (not-ready) :flask-1-with-cream-of-mushroom (add-slobber)}}
|
|
:flask-1-with-cream-of-mushroom {:name "Flask with Cream of Mushroom Soup" :value :flask-1-with-cream-of-mushroom :cursor :flask-with-contents
|
|
:scripts {:slobber (add-slobber) :mandrake (not-ready)}}
|
|
:flask-1-slobber {:name "Cream of Mushroom 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)
|
|
:flask-1-with-cream-of-mushroom (not-ready)
|
|
:flask-1-with-milk (not-ready)
|
|
:flask-1-with-mushrooms (not-ready)
|
|
:flask-1 (not-ready)}}
|
|
: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 Ashes" :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}
|
|
:charcoal {:name "Piece of Charcoal" :value :charcoal :cursor :charcoal}
|
|
: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}
|
|
:tune {:name "A Safe's Sound" :value :tune :cursor :tune}})
|