(ns advent.screens.rooms.behind-house
  (:require [advent.screens.rooms :as rooms]
            [advent.actions :as actions]
            [advent.utils :as utils]
            [clojure.zip :as zip]
            [play-clj.core :refer :all]
            [play-clj.ui :refer :all]
            [play-clj.utils :refer :all]
            [play-clj.g2d :refer :all]))

(defn make [screen]
  (rooms/make :interactions
              {:left-dir {:box [0 131 20 224]
                          :script (actions/get-script
                                   entities
                                   (actions/walk-to entities :ego [122 140])
                                   (actions/transition-background entities :outside-house [244 150])
                                   (actions/walk-to entities :ego [195 140]))
                          :cursor :left}
               :crack {:box [68 100 73 114]
                       :script (actions/get-script
                                entities
                                (actions/walk-to entities :ego [70 80])
                                (actions/talk entities :ego "I can see Fangald, the wizard inside.")
                                (actions/talk entities :ego "It looks like he's opening his Magi-safe.")
                                (actions/talk entities :ego "[todo: sounds play.]")
                                (actions/talk entities :ego "A lot of good it'll do me to know his password while he's still there."))}
               :mushrooms {:box [247 59 269 76]
                           :script (actions/get-script
                                    entities
                                    (if ((get-in @entities [:state :inventory]) :mushrooms)
                                      (actions/talk entities :ego "I've already got a junk ton of mushrooms.")
                                      (do
                                        (actions/walk-to entities :ego [242 75])
                                        (actions/give entities :mushrooms)
                                        (actions/talk entities :ego "Perfectly ripe mushrooms!"))))}
               :window {:box [103 44 130 140]
                        :script (actions/get-script
                                 entities
                                 (actions/walk-to entities :ego [128 100])
                                 (actions/talk entities :ego "I can see Fangald moving around in there but it's hard to see at this angle."))}}
              :layers [(assoc (texture "behindhouse/background.png") :x 0 :y 0 :baseline 0)
                       (assoc (texture "behindhouse/house.png") :x 0 :y 0 :baseline 122)
                       (assoc (texture "behindhouse/brush.png") :x 0 :y 0 :baseline 240)]
              :entities {}
              :collision "behindhouse/collision.png"
              :scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00)))
