Skip to content

Instantly share code, notes, and snippets.

@bhenry
Created November 27, 2014 04:39
Show Gist options
  • Save bhenry/2579fe49e06bf875ec55 to your computer and use it in GitHub Desktop.
Save bhenry/2579fe49e06bf875ec55 to your computer and use it in GitHub Desktop.
blog2
(ns scoreboard.test
(:require [scoreboard.events :as e :refer [publish!]]
[scoreboard.core :as s]))
(def score-range (range 0 150))
(def timeouts-range (range 1 4))
(def paths-values
[[[:home :score] score-range]
[[:home :timeouts] timeouts-range]
[[:away :score] score-range]
[[:away :timeouts] timeouts-range]
[[:ball-on] (range 0 101)]
[[:to-go] (range 0 101)]
[[:down] (range 1 5)]
[[:qtr] (range 1 5)]])
(defn update-number-events []
(map
(fn [[path possible-values]]
(e/event ::s/update-number {:path path
:max (max possible-values)
:min (min possible-values)
:number (rand-nth possible-values)}))
paths-values))
(defn event-bag []
(concat [(e/event ::s/change-possession)]
(update-number-events)))
(defn publish-random-event []
(publish! (rand-nth (event-bag))))
(defn main []
(.setInterval js/window publish-random-event 10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment