Created
November 27, 2014 04:39
-
-
Save bhenry/2579fe49e06bf875ec55 to your computer and use it in GitHub Desktop.
blog2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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