From e224e02e861a7aceee45beb13d8b10353cb7d199 Mon Sep 17 00:00:00 2001 From: Sebastian Crane Date: Sat, 1 Jan 2022 17:57:47 +0000 Subject: [PATCH] Add function with tests to remove player from game Signed-off-by: Sebastian Crane --- src/game.clj | 3 +++ test/game_test.clj | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/game.clj b/src/game.clj index cd32e03..29e947e 100644 --- a/src/game.clj +++ b/src/game.clj @@ -8,3 +8,6 @@ (defn add-player-of-game [state game player] (update-in state [:games game] #(conj % player))) + +(defn remove-player-of-game [state game player] + (update-in state [:games game] #(disj % player))) diff --git a/test/game_test.clj b/test/game_test.clj index 39b6c55..1706c94 100644 --- a/test/game_test.clj +++ b/test/game_test.clj @@ -18,3 +18,8 @@ (is (= '#{"player-one" "player-two" "player-four"} (get-in (add-player-of-game test-state :quasi-rts "player-one") [:games :quasi-rts])))) + +(deftest remove-player-of-game-test + (is (= + '#{"player-one" "player-three"} + (get-in (remove-player-of-game test-state :imaginary-rpg "player-four") [:games :imaginary-rpg]))))