From c7a91148238899e7d9405230912ec59eddb9308b Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Wed, 19 Aug 2015 06:46:49 -0700 Subject: [PATCH] returnable stuff. --- .../advent/screens/rooms/inside_antique.clj | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/desktop/src-common/advent/screens/rooms/inside_antique.clj b/desktop/src-common/advent/screens/rooms/inside_antique.clj index a8d20309..ae75f69a 100644 --- a/desktop/src-common/advent/screens/rooms/inside_antique.clj +++ b/desktop/src-common/advent/screens/rooms/inside_antique.clj @@ -92,6 +92,12 @@ (actions/add-entity entities :portrait (get-in @entities [:room :portrait])) (actions/remove-item entities :portrait)) +(defn return-teddy [entities] + (actions/walk-to entities :ego [242 49] :face :right) + (actions/play-animation entities :ego :reach) + (actions/add-entity entities :teddy (get-in @entities [:room :teddy])) + (actions/remove-item entities :teddy)) + (defn has-to-return-teddy? [entities] (and (actions/has-item? entities :teddy) (not (get-in @entities [:state :allowed-to-keep-teddy?])))) @@ -131,10 +137,7 @@ (when (actions/has-item? entities :portrait) (return-portrait entities)) (when (has-to-return-teddy? entities) - (actions/walk-to entities :ego [242 49] :face :right) - (actions/play-animation entities :ego :reach) - (actions/add-entity entities :teddy teddy) - (actions/remove-item entities :teddy))) + (return-teddy teddy))) (actions/walk-to entities :ego [235 15] :stop? false :skip-type :end) (actions/walk-straight-to entities :ego [320 -5]) @@ -144,6 +147,11 @@ :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-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))}} :window {:box [210 125 256 183] :script (actions/get-script entities (actions/talk entities :ego "It's a nice, big window.")) @@ -258,6 +266,7 @@ (actions/remove-entity entities :portrait) (actions/give entities :portrait) (actions/talk entities :ego "It's a portrait. There's something on the back but it's too dim to read.")))) + :teddy (rooms/make-entity :teddy teddy) :collision "inside-antique/collision.png" :apply-state (fn [_ entities] (as-> entities entities