(ns sekai.core.selector
  (:require [sekai.core.gamestate :refer [game-state]]))

(defmulti gather :type)

(defn just [entity] {:type :just :data entity})
(defmethod gather :just [{:keys [data]}]
  #{data})

(defn with-tag [tag] {:type :with-tag :data tag})
(defmethod gather :with-tag [{:keys [data]}]
  (-> @game-state :tags data))

(defn all [] {:type :all :data nil})
(defmethod gather :all [_]
  (-> @game-state :entities keys set))

(defn do-selector [selector fn]
  (map fn (gather selector)))
