diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index 621b9810..d65c849f 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -29,6 +29,14 @@ ((set (get-in entities [:state :inventory])) item) ((set (get-in @entities [:state :inventory])) item))) +(defn has-obtained? [entities item] + (if (map? entities) + ((get-in entities [:state :obtained-items]) item) + ((get-in @entities [:state :obtained-items]) item))) + +(defn has-obtained-one-of? [entities items] + (seq (set/intersection (get-in entities [:state :obtained-items]) (set items)))) + (defn has-one-of? [entities items] (seq (set/intersection (set (get-in entities [:state :inventory])) (set items)))) @@ -346,6 +354,7 @@ (-> entities (update-in [:state :inventory] #(conj % item)) + (update-in [:state :obtained-items] #(conj % item)) (assoc-in [:cursor :current] ((:all-items entities) item)))) (continue [this screen entities] entities) diff --git a/desktop/src-common/advent/screens/rooms/behind_house.clj b/desktop/src-common/advent/screens/rooms/behind_house.clj index 1e264466..4a20d82d 100644 --- a/desktop/src-common/advent/screens/rooms/behind_house.clj +++ b/desktop/src-common/advent/screens/rooms/behind_house.clj @@ -26,7 +26,7 @@ :mushrooms {:box [247 59 269 76] :script (actions/get-script entities - (if (actions/has-item? entities :mushrooms) + (if (actions/has-obtained? entities :mushrooms) (actions/talk entities :ego "I've already got a junk ton of mushrooms.") (do (actions/walk-to entities :ego [242 75]) @@ -74,7 +74,7 @@ (if (get-in entities [:state :opened-crack?]) (assoc-in entities [:room :entities :peeling :opacity] 0) entities) - (if (actions/has-one-of? entities [:stick :cat-toy]) + (if (actions/has-obtained? entities :stick) (update-in entities [:room :entities] #(dissoc % :stick)) entities))) :start-pos [172 122])) diff --git a/desktop/src-common/advent/screens/rooms/outside_castle.clj b/desktop/src-common/advent/screens/rooms/outside_castle.clj index 7645f52b..6ef10631 100644 --- a/desktop/src-common/advent/screens/rooms/outside_castle.clj +++ b/desktop/src-common/advent/screens/rooms/outside_castle.clj @@ -17,7 +17,7 @@ peddler-stand (animation 0.2 (for [i (flatten [(repeat 5 0) 6])] (aget peddler-sheet 0 i))) balloon-sheet (texture! (texture "outside-castle/balloons.png") :split 20 36) - balloon-stand (animation 0.3 (for [i [0 1 2 1]] + balloon-stand (animation 0.25 (for [i [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 0 1 2 1 0 1 2 1 0 1 2 1 0 1 2]] (aget balloon-sheet 0 i))) bird-sheet (texture! (texture "outside-castle/bird.png") :split 1 2) bird-stand (animation 0.15 (for [i [0 1]] @@ -56,7 +56,7 @@ :garden {:box [103 170 178 200] :script (actions/get-script entities - (if (actions/has-item? entities :carrot) + (if (actions/has-obtained? entities :carrot) (actions/talk entities :ego "If I steal any more, I might get caught.") (do (actions/walk-to entities :ego [128 180]) @@ -68,56 +68,64 @@ :script (actions/get-script entities (actions/walk-to entities :ego [191 90] :face :left) - - (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." - :ego "What 'wares' are you selling?" - :peddler "I have the choicest of all types of wares..." - :peddler "...I'm well stocked on used earplugs..." - :peddler "...glass eyes..." - :peddler "... and motivational tapes." - :peddler "And today, I have a one day special!" - :peddler "Every purchase comes with a free balloon!") - (actions/present-choices entities {:choices ["I'm interested in your earplugs." - {:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true))) - (actions/respond entities % - :peddler "A choice choice sir!" - :peddler "These earplugs have been used by the the choicest of wearers." - :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 "That'll just be 10 sheckels." - :ego "But I haven't got any money!" - :peddler "Well I'm afraid you won't have the choicest of earplugs." - :ego "Can't I give you something else for them?" - :peddler "Well, I am low on choice children's toys." - :peddler "If you can bring me one, and I mean the choicest of toys, I will give you the earplugs."))} - "I'm interested in a glass eye." - {:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true))) - (actions/respond entities % - :peddler "The choicest choice, young man!" - :peddler "This glass eye is made out of the choicest glass, from across the sea." - :peddler "And remember, every purchase comes with the choicest of balloons!" - :peddler "That'll just be 95 sheckels." - :ego "But I haven't got any money!" - :peddler "Well I'm afraid you won't have the choicest of glass eyes." - :ego "Can't I give you something else for them?" - :peddler "I'll tell you what, I don't have any thing for the kids that come to my stand." - :peddler "If you can bring me the choicest of toys, I will give you the glass eye."))} - "I'm interested in the motivational tapes." - {:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true))) - (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." - :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 "If you can bring me a nice kid's toy, I will give you the tapes."))} - "Nevermind." {:run #(actions/respond entities % :peddler "Goodbye, sir.")}]})) + (if (actions/has-obtained? entities :balloon) + (do (actions/do-dialogue entities + :ego "Hello there, peddler." + :peddler "Hello again, sir! I trust you are enjoying your goods!" + :ego "I sure am." + :peddler "I thought so!")) + + (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." + :ego "What 'wares' are you selling?" + :peddler "I have the choicest of all types of wares..." + :peddler "...I'm well stocked on used earplugs..." + :peddler "...glass eyes..." + :peddler "... and motivational tapes." + :peddler "And today, I have a one day special!" + :peddler "Every purchase comes with a free balloon!") + (actions/present-choices entities {:choices ["I'm interested in your earplugs." + {:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true))) + (actions/respond entities % + :peddler "A choice choice sir!" + :peddler "These earplugs have been used by the the choicest of wearers." + :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 "That'll just be 10 sheckels." + :ego "But I haven't got any money!" + :peddler "Well I'm afraid you won't have the choicest of earplugs." + :ego "Can't I give you something else for them?" + :peddler "Well, I am low on choice children's toys." + :peddler "If you can bring me one, and I mean the choicest of toys, I will give you the earplugs."))} + "I'm interested in a glass eye." + {:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true))) + (actions/respond entities % + :peddler "The choicest choice, young man!" + :peddler "This glass eye is made out of the choicest glass, from across the sea." + :peddler "And remember, every purchase comes with the choicest of balloons!" + :peddler "That'll just be 95 sheckels." + :ego "But I haven't got any money!" + :peddler "Well I'm afraid you won't have the choicest of glass eyes." + :ego "Can't I give you something else for them?" + :peddler "I'll tell you what, I don't have any thing for the kids that come to my stand." + :peddler "If you can bring me the choicest of toys, I will give you the glass eye."))} + "I'm interested in the motivational tapes." + {:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true))) + (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." + :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 "If you can bring me a nice kid's toy, I will give you the tapes."))} + "Nevermind." {:run #(actions/respond entities % :peddler "Goodbye, sir.")}]}))) + ) :scripts {:teddy (actions/get-script entities + (actions/walk-to entities :ego [191 90] :face :left) (actions/remove-item entities :teddy) (actions/do-dialogue entities :peddler "That is the choicest of teddy bears!" @@ -195,7 +203,7 @@ :stand) :flies (actions/start-animation screen (assoc (animation->texture screen flies-stand) - :x 241 + :x 201 :y 175 :baseline 240 :stand flies-stand) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 4a443fde..75b6a96b 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -219,6 +219,7 @@ {:object nil :active? true :last-room :outside-house + :obtained-items #{} :inventory [] :clues #{} :mints-eaten 0}))