Skip to content

Instantly share code, notes, and snippets.

Last active Mar 3, 2017
What would you like to do?
(defn new-game []
(defn current-turn
(peek game))
(defn play-move
"Play current player move at the provided coordinate"
[game coord]
(if-let [new-turn (turn/next-turn (current-turn game) coord)]
(conj game new-turn)
(defn undo-last-move
"Remove the last game if there is enough game played"
(if (< 1 (count game)) (pop game) game))
(defn handle-event
"Callback to dispath the event on the game"
[game event]
(= event :restart) (new-game)
(= event :undo) (undo-last-move game)
:else (play-move game event)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment