Reset all of player's properties when dealing cards

This commit is contained in:
Sasha 2018-07-28 19:23:16 +02:00
parent 4d1a2f7fee
commit 46071152a4
1 changed files with 2 additions and 2 deletions

View File

@ -45,11 +45,11 @@ get key (Players playersByKey) = playersByKey ! key
set :: Ord key => key -> Player key yakus -> Players key yakus -> Players key yakus
set key player (Players playersByKey) = Players $ insert key player playersByKey
deal :: Ord key => Players key yakus -> [[Card]] -> Players key yakus
deal :: (Ord key, Monoid yakus) => Players key yakus -> [[Card]] -> Players key yakus
deal (Players playersByKey) hands =
Players $ snd $ foldl dealTo (fst $ findMin playersByKey, playersByKey) hands
where
setHand cards player = player {hand = packOfCards cards}
setHand cards (Player {nextPlayer}) = (new nextPlayer) {hand = packOfCards cards}
dealTo (key, m) hand = (nextPlayer $ m ! key, adjust (setHand hand) key m)
plays :: Player key yakus -> Card -> Either String (Player key yakus)