effect_execution.clj

Branches > facts > c88c7b3 > files / src / net / bowmap / stormbow / effect_execution.clj

(ns net.bowmap.stormbow.effect-execution
  (:require
   [clojure.core.async :refer [put!]]
   [net.bowmap.protocol.client :as client]
   [net.bowmap.protocol.packet :as pk]
   [net.bowmap.protocol.packet.clientbound :as clientbound]
   [net.bowmap.stormbow.effect :as effect]))

(defmulti execute-effect!
  (fn [effect]
    (::effect/id effect)))

(defmethod execute-effect! ::effect/send-server-list [effect]
  (let [{:keys! [::client/client server-list-response]} effect
        {::client/keys! [clientbound-packets]} client
        packet {::pk/id ::clientbound/status-response
                :response server-list-response}]
    (put! clientbound-packets packet)))

(defn execute-effects! [effects]
  (run! execute-effect! effects))