Last active
March 14, 2017 13:21
-
-
Save deque-blog/25ac8379e9d2c8bb2e954b651c88fec4 to your computer and use it in GitHub Desktop.
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
(defprotocol ITurn | |
(-next-turn [turn transition] "Move to the next turn of the game") | |
(-transitions [turn] "Provides the list of transitions to next turns") | |
(-turn-status [turn] "Provides the status of the board, player and scores")) | |
;; The turn that is being manipulated in the API | |
(s/def ::turn | |
#(satisfies? ITurn %)) | |
;; Instantiate a new turn (for example with reify) | |
(s/fdef new-init-turn | |
:ret ::turn) | |
;; Moving from one turn to the next | |
(s/fdef next-turn | |
:args (s/cat :turn ::turn | |
:transition ::transition/transition) | |
:ret ::turn) | |
;; Getting the transitions to the next turns | |
(s/fdef transitions | |
:args (s/cat :turn ::turn) | |
:ret (s/map-of ::transition/destination ::transition/transition)) | |
;; The data that we can retrieve from a turn | |
(s/def ::turn-data | |
(s/keys :req-un | |
[::board/board | |
::player/player | |
::scores/scores])) | |
;; A way to retrieve the current state information | |
(s/fdef turn->info | |
:args (s/cat :turn ::turn) | |
:ret ::turn-data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment