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

101 lines
5.9 KiB
Clojure

(ns advent.screens.rooms.common
(:require [clojure.core.async :refer [chan]]
[advent.screens.rooms :as rooms]
[advent.actions :as actions]
[advent.screens.items :as items]
[advent.utils :as utils]
[advent.pathfind]
[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 go-to-jail [entities]
(actions/update-state entities #(assoc % :time :night))
(actions/update-state entities #(assoc % :chest-contents (concat (remove #{:key} (:inventory %)) (:chest-contents %))))
(actions/update-state entities #(assoc % :inventory []))
(actions/update-state entities #(assoc % :opened-bars? false))
(actions/transition-background entities :inside-jail [130 85]))
(defn make-wizard [screen wizard-spec]
(let [wizard-sheet (texture! (texture "wizard/talk.png") :split 20 46)
wizard-stand (animation 0.2 (for [i (flatten [(repeat 10 0) 1])]
(aget wizard-sheet 0 i)))
wizard-disappear (utils/make-anim "wizard/disappear.png" [20 46] 0.075 (range 19))
wizard-talk (animation 0.2 (for [i [0 2 0 2 1 2 0 3 0 2 0 1 0 2]]
(aget wizard-sheet 0 i)))]
(actions/start-animation screen (merge (assoc (animation->texture screen wizard-stand)
:left {:talk (utils/flip wizard-talk)
:stand (utils/flip wizard-stand)
:disappear (utils/flip wizard-disappear)}
:right {:talk wizard-talk
:stand wizard-stand
:disappear wizard-disappear}
:talk-color (color 0.95 0.3 1.0 1.0)
:facing :left) wizard-spec)
:stand)))
(defn read-note-1 [entities]
(actions/do-dialogue entities
:ego "It's a note from Gandarf! It says:"
:ego "'Boy, I have been kidnapped by Blergh.'"
:ego "'He's got me locked up in his fortress of doom.'"
:ego "'It's actually pretty comfortable, despite the name.'"
:ego "'You must cast the spell to restore magic to the Slinger's Shot yourself.'"
:ego "'You still do have The Slinger's Shot, don't you?'"
:ego "'I will do my best to help you along the way.'"
:ego "'You will need to add to your flask the ashes of magic, and the sound of buzzing.'"
:ego "'Then stir with the gift of flight.'"
:ego "'Then pour the contents in the cauldron.'"
:ego "'I will give you more instructions when I can.'"
:ego "'And please hurry, because we're being forced into a karaoke competition.'"
:ego "'I'm about at my witt's end.'"
:ego "'P.S., Guard that slingshot with your life!'"
:ego "'P.P.S., If anything goes wrong, you can look for my secret stash of helpful stuff behind a nearby r...'"
:ego "It just cuts off there."))
(defn read-note-2 [entities]
(actions/do-dialogue entities
:ego "It's a Bingo card."
:ego "Look's like there's a note on the back."
:ego "'Boy, the situation is dire. I don't have much time. Please hurry.'"
:ego "'We've been forced into playing bingo for the last 3 hours.'"
:ego "'You are almost done with the spell to restore magic to The Slinger's Shot.'"
:ego "'You haven't lost it, right?'"
:ego "'You need to add the root of all evil to the cauldron.'"
:ego "'Also, you'll need to add a split second.'"
:ego "'Then, dip the Slinger's Shot in to complete the spell.'"
:ego "'Don't forget about my secret stash of helpful stuff.'"))
(defn listen-1 [entities]
(actions/talk entities :ego "Did you see the look on Faceplant's face when we took his stuff?" :animate? false :stop? false)
(actions/talk entities :ego "It looked like he was about to pee his pants." :animate? false :stop? false)
(actions/talk entities :ego "Am I right boys?" :animate? false :stop? false))
(defn listen-2 [entities]
(actions/talk entities :ego "Hey Bubba, did you put our spoils in our secret stash yet?" :animate? false :stop? false)
(actions/talk entities :ego "You don't remember where it's at?" :animate? false :stop? false)
(actions/talk entities :ego "It's right outside the jail." :animate? false :stop? false)
(actions/talk entities :ego "You just have to pull the secret lever." :animate? false :stop? false)
(actions/update-state entities #(assoc % :knows-about-stash? true :stop? false)))
(defn listen-3 [entities]
(actions/talk entities :ego "We're going to be rich after we fence this stuff we've stolen." :animate? false :stop? false)
(actions/talk entities :ego "Am I right boys?" :animate? false :stop? false))
(defn listen-to-frankie [entities]
(if (get-in @entities [:room :entities :frankie])
(do
(actions/play-animation entities :ego :reach-up :stop? false)
(Thread/sleep 1000)
(actions/play-animation entities :ego :reach-down :stop? false)
(actions/talk entities :ego "I don't hear anything in it."))
(do
(actions/talk entities :ego "I'll just give it a listen.")
(actions/play-animation entities :ego :reach-up :stop? false)
((rand-nth [listen-1 listen-2 listen-3]) entities)
(actions/play-animation entities :ego :reach-down))))