Created
October 17, 2017 19:56
-
-
Save rojoangel/4e5c685f5c65211400898aa8ad772648 to your computer and use it in GitHub Desktop.
BCN Clojure Community - Pigs Kata - 2017/10/17 Session
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 pigs.core-test | |
(:require [clojure.test :refer :all] | |
[pigs.core :refer :all])) | |
(defn hold [player] | |
{:score (+ (:score player) (reduce + (:rolls player))) :rolls []}) | |
(defn add-roll [player roll] | |
(update player :rolls conj roll)) | |
(defn lose-turn [player] | |
(update player :rolls empty)) | |
(deftest hold-test | |
(testing "hold adds rolls to score" | |
(is (= {:score 67 :rolls []} (hold {:score 55 :rolls [5 4 3]}))))) | |
(deftest add-roll-test | |
(testing "add roll adds result to the turn" | |
(is (= {:score 55 :rolls [5 4 3 5]} (add-roll {:score 55 :rolls [5 4 3]} 5))))) | |
(deftest lose-turn-test | |
(testing "" | |
(is (= {:score 55 :rolls []} (lose-turn {:score 55 :rolls [5 4 2]}))))) | |
(comment "work in progress" | |
(deftest roll-test | |
(testing "rolling" | |
(is (= (roll fx {:score 22 :rolls [6 4 2] :round 4 | |
}) )))) | |
) | |
(comment | |
"possible game structure" | |
{:round 5 | |
:player 1 | |
:rolls [2 4] | |
:scores [ 33 34 ]} | |
) | |
(comment | |
"another possible game structure" | |
{:player1 10 :player2 22 :current-player :player1 :current-rolls [4 2 3 5]} | |
; roll leads to | |
{:player1 10 :player2 22 :current-player :player1 :current-rolls [4 2 3 5 6]} | |
; hold or 1 leads to | |
{:player1 77 :player2 22 :current-player :player2 :current-rolls []} | |
) | |
(comment | |
"a possible ui" | |
;player 1 - round 1> roll | |
;5 | |
;score p1: 10 p2: 22 | |
;player 1 - round 2> hold | |
;score p1: 15 p2: 22 | |
;player 2 - round 3> roll | |
;6 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment