can't open chest twice.
This commit is contained in:
@@ -563,3 +563,4 @@
|
||||
|
||||
(defn respond [entities line & more]
|
||||
(apply do-dialogue entities :ego line more))
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
(ns advent.screens.rooms.inside-jail
|
||||
(:require [clojure.core.async :refer [chan]]
|
||||
[advent.screens.rooms :as rooms]
|
||||
[advent.screens.rooms.common :as common]
|
||||
[advent.actions :as actions]
|
||||
[advent.screens.items :as items]
|
||||
[advent.utils :as utils]
|
||||
@@ -24,25 +25,35 @@
|
||||
(actions/update-entities entities #(remove-lock %))
|
||||
(actions/update-state entities #(assoc % :opened-bars? true)))
|
||||
|
||||
(defn touch-chest [entities]
|
||||
(if (get-in @entities [:state :opened-bars?])
|
||||
(do (actions/walk-to entities :ego [192 66] :face :right)
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(actions/do-dialogue entities
|
||||
:ego "Hey!"
|
||||
:ego "All my possessions are in here!")
|
||||
(actions/update-state entities #(-> %
|
||||
(assoc :inventory (concat (:inventory %) (:chest-contents %)))
|
||||
(assoc :chest-contents [])))
|
||||
(when (not (actions/has-obtained? entities :rope))
|
||||
(actions/do-dialogue entities :ego "Looks like there's some rope in here too.")))
|
||||
(defn chest-full? [entities]
|
||||
(seq (get-in @entities [:state :chest-contents])))
|
||||
|
||||
(do (actions/walk-to entities :ego [179 81] :face :right)
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(actions/do-dialogue entities :ego "I can't reach it!")
|
||||
(when (not (get-in @entities [:state :warden-sleeping?]))
|
||||
(actions/do-dialogue entities :warden "Quit yer yappin'!"
|
||||
:warden "You're not escaping while I'm on watch, so just give it up.")))))
|
||||
(defn touch-chest [entities]
|
||||
(cond
|
||||
(not (chest-full? entities))
|
||||
(do (actions/walk-to entities :ego [192 66] :face :right)
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(actions/do-dialogue entities :ego "It's empty now."))
|
||||
|
||||
(get-in @entities [:state :opened-bars?])
|
||||
(do (actions/walk-to entities :ego [192 66] :face :right)
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(actions/do-dialogue entities
|
||||
:ego "Hey!"
|
||||
:ego "All my possessions are in here!")
|
||||
(actions/update-state entities #(-> %
|
||||
(assoc :inventory (concat (:inventory %) (:chest-contents %)))
|
||||
(assoc :chest-contents [])))
|
||||
(when (not (actions/has-obtained? entities :rope))
|
||||
(actions/do-dialogue entities :ego "Looks like there's some rope in here too.")))
|
||||
|
||||
:else
|
||||
(do (actions/walk-to entities :ego [179 81] :face :right)
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(actions/do-dialogue entities :ego "I can't reach it!")
|
||||
(when (not (get-in @entities [:state :warden-sleeping?]))
|
||||
(actions/do-dialogue entities :warden "Quit yer yappin'!"
|
||||
:warden "You're not escaping while I'm on watch, so just give it up.")))))
|
||||
|
||||
|
||||
(defn do-warden-dialogue [entities]
|
||||
@@ -125,11 +136,7 @@
|
||||
:ego "Maybe you should give it a rest.")))
|
||||
(actions/update-state entities #(assoc % :hay-searches (inc hay-searches)))))
|
||||
|
||||
(defn go-to-jail [entities]
|
||||
(actions/update-state entities #(assoc % :chest-contents (remove #{:key} (:inventory %))))
|
||||
(actions/update-state entities #(assoc % :inventory []))
|
||||
(actions/update-state entities #(assoc % :opened-bars? false))
|
||||
(actions/transition-background entities :inside-jail [130 85]))
|
||||
|
||||
|
||||
|
||||
(defn make [screen]
|
||||
@@ -168,7 +175,9 @@
|
||||
(if (get-in @entities [:state :opened-bars?])
|
||||
(do
|
||||
(actions/walk-to entities :ego [279 57])
|
||||
(actions/transition-background entities :outside-jail [50 46] ))
|
||||
(if (chest-full? entities)
|
||||
(actions/talk entities :ego "I probably shouldn't leave without my belongings.")
|
||||
(actions/transition-background entities :outside-jail [50 46] )))
|
||||
(actions/talk entities :ego "Do you really think I can walk down those steps while I'm locked up?")))}}
|
||||
:layers [(assoc (texture "inside-jail/background.png") :x 0 :y 0 :baseline 0)
|
||||
(assoc (texture "inside-jail/bars.png") :x 0 :y 0 :baseline 165)
|
||||
@@ -189,7 +198,7 @@
|
||||
:ego "Oops!"
|
||||
:warden "Hey! What are you doing?"
|
||||
:warden "Get back in jail.")
|
||||
(go-to-jail entities)
|
||||
(common/go-to-jail entities)
|
||||
(actions/do-dialogue entities :warden "Now don't let me catch you trying to escape again.")
|
||||
(actions/play-animation entities :warden :fall-asleep :stop? false)
|
||||
(actions/begin-animation entities :warden :sleep)) entities)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(ns advent.screens.rooms.space
|
||||
(:require [advent.screens.rooms :as rooms]
|
||||
[advent.screens.rooms.common :as common]
|
||||
[advent.actions :as actions]
|
||||
[advent.screens.items :as items]
|
||||
[advent.utils :as utils]
|
||||
@@ -53,7 +54,8 @@
|
||||
(actions/walk-straight-to entities :ego [100 45] :anim :squat :override-dir :right :speed 3.0)
|
||||
(actions/do-dialogue entities :ego "Ouch!"
|
||||
:blergh "My turn.")
|
||||
(actions/transition-background entities :inside-jail [130 85])
|
||||
|
||||
(common/go-to-jail entities)
|
||||
(actions/do-dialogue entities :ego "Hey!"
|
||||
:ego "What's going on? I was just about to teach Blergh a lesson!"))}))
|
||||
:entities {}
|
||||
|
||||
Reference in New Issue
Block a user