Files
gitea-docker/desktop/src-common/advent/screens/rooms/inside_antique.clj

87 lines
6.7 KiB
Clojure

(ns advent.screens.rooms.inside-antique
(:require [advent.screens.rooms :as rooms]
[advent.actions :as actions]
[advent.screens.items :as items]
[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 do-antique-dialogue [entities]
(actions/do-dialogue entities
:shopkeep "Welcome to my antique shop!"
:shopkeep "Can I help you?")
(actions/present-choices entities
{:choices ["What do you have for sale here?"
{:run #(actions/respond entities %
:shopkeep "For sale?"
:shopkeep "This is a very UNIQUE antique shop."
:shopkeep "Nothing's for sale, sonny."
:shopkeep "It's more like a museum."
:shopkeep "You can take look around at some of my items, but nothing is for sale.")
:choices ["How do you make money then?"
{:run #(actions/respond entities %
:shopkeep "Mostly insurance claims."
:shopkeep "When you run such an impressive shop as I do, items sometimes just go missing.")
:choices actions/previous-choices}
"Is there anything here you will sell?"
{:run #(actions/respond entities %
:shopkeep "No."
:shopkeep "But I do have some free magical fire mints that Gandarf brewed up."
:shopkeep "Careful! They're spicy.")
:choices actions/previous-choices}
"So in order to continue on my quest, I'll need to solve some puzzle here?"
{:run #(actions/respond entities %
:shopkeep "I have no idea what you're talking about, sonny.")
:choices actions/previous-choices}
"Something else"
{:choices actions/something-else}]}
(when (get-in @entities [:state :wants-toy])
"Listen, I really need that teddy bear you have.")
{:run #(actions/respond entities %
:shopkeep "Why?"
:shopkeep "Why should I give it to you?")
:choices ["I just need it ok?"
{:run #(actions/respond entities %
:shopkeep "I'm sorry, it's not for sale.")
:choices actions/something-else}
(when (get-in @entities [:state :knows-about-son])
"Your long lost son said I could have it.")
{:run #(actions/respond entities % :shopkeep "REALLY? You've met him?")}]}
"How's life in the antique shop biz?"
{:run #(do (actions/update-state entities (fn [state] (assoc state :knows-about-son true)))
(actions/respond entities %
:shopkeep "Pretty lonely."
:shopkeep "My long lost son used to help me run this shop, but he's been gone for five years now."
:shopkeep "I've been couped up in here by myself ever since."
:shopkeep "Now all I have is this grandfather clock to keep me company."))
:choices actions/previous-choices}
"Nevermind." {:run #(actions/respond entities % :shopkeep "Feel free to look around.")}]}))
(defn make [screen]
(let [shopkeep-sheet (texture! (texture "inside-antique/shopkeep-talk.png") :split 18 21)
shopkeep-stand (animation 0.1 (for [i (flatten [(repeat 30 0) 1 (repeat 50 0) 1 0 1 0 1])]
(aget shopkeep-sheet 0 i)))
shopkeep-talk (animation 0.15 (for [i [0 2 0 2 0 3 1 0]]
(aget shopkeep-sheet 0 i)))]
(rooms/make :music :inside-antique
:interactions
{:down {:box [60 0 290 25]
:cursor :down
:script (actions/get-script entities
(actions/walk-to entities :ego [222 3])
(actions/transition-background entities :inside-castle [182 90]))}}
:layers [(assoc (texture "inside-antique/background.png") :x 0 :y 0 :baseline 0)]
:entities {:shopkeep (actions/start-animation screen (assoc (animation->texture screen shopkeep-stand) :x 137 :y 128 :baseline 112
:stand shopkeep-stand
:talk shopkeep-talk
:script (actions/get-script entities (do-antique-dialogue entities))
)
:stand)}
:collision "inside-antique/collision.png"
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.50))))